I am working with GDI+ using its colormap constructor, problem is when GDI pulls in the image to recolor its doing it backwards. The images I pull in are .PNG line art images and the actual line art is black, however when i try to replace the black lines with say, green, my script colors the background not the actual line art! Heres my code:
<%@Page Language="vb" debug="true"%>
<%@import NameSpace = "System.Drawing"%>
<%@import NameSpace = "System.Drawing.Graphics"%>
<%@import NameSpace = "System.Drawing.Text"%>
<%@import NameSpace = "System.Drawing.Imaging"%>
<%@import NameSpace = "System.Drawing.Drawing2D"%>
<%
Response.Clear()
Dim strImgPath as String = "../images/clipart/xero.png"
Dim orgImage As System.Drawing.Image = System.Drawing.Image.FromFile(server.mappath(strImgPath))
Dim swpImage as New Bitmap(orgImage)
Dim g as Graphics = Graphics.FromImage(swpImage)
Dim clrMap(0) As System.Drawing.Imaging.ColorMap
clrMap(0) = new System.Drawing.Imaging.ColorMap()
clrMap(0).OldColor = color.black
clrMap(0).NewColor = Color.green
Dim attr As ImageAttributes = New ImageAttributes()
attr.SetRemapTable(clrMap)
Dim rec as New Rectangle(0,0,swpImage.width, swpImage.height)
g.drawImage(swpImage, rec,0,0,swpImage.Width, swpImage.Height, GraphicsUnit.Pixel, attr)
swpImage.Save(Response.OutputStream, ImageFormat.gif)
%>
The extra namespaces are in there for code that I have to add later. Any help with this would be greatly appreciated.
<%@Page Language="vb" debug="true"%>
<%@import NameSpace = "System.Drawing"%>
<%@import NameSpace = "System.Drawing.Graphics"%>
<%@import NameSpace = "System.Drawing.Text"%>
<%@import NameSpace = "System.Drawing.Imaging"%>
<%@import NameSpace = "System.Drawing.Drawing2D"%>
<%
Response.Clear()
Dim strImgPath as String = "../images/clipart/xero.png"
Dim orgImage As System.Drawing.Image = System.Drawing.Image.FromFile(server.mappath(strImgPath))
Dim swpImage as New Bitmap(orgImage)
Dim g as Graphics = Graphics.FromImage(swpImage)
Dim clrMap(0) As System.Drawing.Imaging.ColorMap
clrMap(0) = new System.Drawing.Imaging.ColorMap()
clrMap(0).OldColor = color.black
clrMap(0).NewColor = Color.green
Dim attr As ImageAttributes = New ImageAttributes()
attr.SetRemapTable(clrMap)
Dim rec as New Rectangle(0,0,swpImage.width, swpImage.height)
g.drawImage(swpImage, rec,0,0,swpImage.Width, swpImage.Height, GraphicsUnit.Pixel, attr)
swpImage.Save(Response.OutputStream, ImageFormat.gif)
%>
The extra namespaces are in there for code that I have to add later. Any help with this would be greatly appreciated.