Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
nishanthe  
#1 Posted : Monday, December 26, 2005 6:51:58 PM(UTC)
nishanthe

Rank: Member

Groups: Member
Joined: 10/7/2005(UTC)
Posts: 10

Though this forum seems dead, and my few questions waiting for a long time without any attention, I decided to post another question, hoping the mercy of Andrew or Fedor whom are the only persons could be answer this question.

This is my ASP code

Code:
<%
Dim intOpacity
Dim intColor
intOpacity = 255
newColor = &hFF0E0304
newColor2 = &h0000FF
Set objcolor = Server.CreateObject("GraphicsMill.Color")
h_color = objcolor.getHue(newColor)
s_color = objcolor.getSaturation(newColor)
l_color = objcolor.getLightness(newColor)


intColor = "&hFFFFFFFF"
Dim objGuitarBitmap ' File containing the guitar image

Dim objMask ' File containing the guitar body mask
Dim objColorLayer ' Colored layer which will be blended with original image
Set objGuitarBitmap = Server.CreateObject("GraphicsMill.Bitmap")
Set objGuitarBitmap1 = Server.CreateObject("GraphicsMill.Bitmap")
Set objGuitarBitmap2 = Server.CreateObject("GraphicsMill.Bitmap")
Set objGuitarBitmap3 = Server.CreateObject("GraphicsMill.Bitmap")
Set objGuitarBitmap4 = Server.CreateObject("GraphicsMill.Bitmap")
Set objGuitarBitmap5 = Server.CreateObject("GraphicsMill.Bitmap")
Set objMask = Server.CreateObject("GraphicsMill.Bitmap")
Set objColorLayer = Server.CreateObject("GraphicsMill.Bitmap")

' Load the original file and the mask
objGuitarBitmap5.LoadFromFile Server.MapPath("obj_color4.png")
objGuitarBitmap4.LoadFromFile Server.MapPath("obj_color3.png")
objGuitarBitmap3.LoadFromFile Server.MapPath("obj_color2.png")
objGuitarBitmap2.LoadFromFile Server.MapPath("obj_color1.png")
objGuitarBitmap1.LoadFromFile Server.MapPath("obj_color.png")
objGuitarBitmap.LoadFromFile Server.MapPath("walnut2.jpg")
objMask.LoadFromFile Server.MapPath("test_obj_mask.jpg")


objGuitarBitmap2.adjustHSL objcolor.getHue(newColor2), objcolor.getSaturation(newColor2), objcolor.getLightness(newColor2)




' Creating the color layer. It should be of the same size as mask
objColorLayer.CreateNew objMask.Width, objMask.Height, Format32bppArgb, intColor

' Use the mask as an alpha channel for the color layer. Now when we try to 
' alpha blend objColorLayer with objGuitarBitmap, colors will be blended
' according to the mask


' Blend 
objGuitarBitmap1.DrawOnBitmap objGuitarBitmap, , , , , , , , , 1, 120
objGuitarBitmap5.DrawOnBitmap objGuitarBitmap, , , , , , , , , 1, intOpacity
objGuitarBitmap4.DrawOnBitmap objGuitarBitmap, , , , , , , , , 1, intOpacity
objGuitarBitmap3.DrawOnBitmap objGuitarBitmap, , , , , , , , , 1, intOpacity
objGuitarBitmap2.DrawOnBitmap objGuitarBitmap, , , , , , , , , 1, intOpacity

objColorLayer.Replace objMask, 3
objColorLayer.DrawOnBitmap objGuitarBitmap, , , , , , , , , 1, intOpacity

objGuitarBitmap.AddAlpha
objGuitarBitmap.Transparentize &hFFFDFDFD,10
objGuitarBitmap.Formats.SelectCurrent "PNG"
objGuitarBitmap.SaveToFile Server.MapPath("SaveToPng1.png") 
objGuitarBitmap.SaveToStream Response

%>

Though I am setting the color value to '0000FF', Final Images Color value has changed to 'FC7EFC'. Can somebody explain this please?

-Nishanthe

Edited by user Sunday, December 23, 2007 4:36:29 PM(UTC)  | Reason: Not specified

Andrew  
#2 Posted : Friday, January 6, 2006 1:14:08 PM(UTC)
Andrew

Rank: Advanced Member

Groups: Member, Administration
Joined: 8/2/2003(UTC)
Posts: 876

Thanks: 2 times
Was thanked: 27 time(s) in 27 post(s)
I am sorry for a long absence. End of year 2005 was crazy... :(

The problem is that AdjustHsl works not in the way you expect. It does not replace hue, saturation, and lightness to the value you specify (in this case you would loose the image and get all pixels equal to the same value). It adds specified hue, saturation, and lightness (in fact it handles lightness parameter smarter, but anyway, it does not just replace it). This way if you want to change colors to some value, you should know the source color, and pass the difference of these colors into the AdjustHsl method.

Code:
objBitmap.ColorAdjustment.AdjustHsl objcolor.getHue(newColor) - objcolor.getHue(oldColor),  _
objcolor.getSaturation(newColor) - objcolor.getSaturation(oldColor), _
objcolor.getLightness(newColor) - objcolor.getLightness(oldColor)

However could you tell why the way I described before did not work (when you created empty bitmap of necessary color and cut it with a mask image)?

Edited by user Sunday, December 23, 2007 4:36:41 PM(UTC)  | Reason: Not specified

nishanthe  
#3 Posted : Tuesday, February 14, 2006 2:31:41 PM(UTC)
nishanthe

Rank: Member

Groups: Member
Joined: 10/7/2005(UTC)
Posts: 10

Hi Andrew,

Thanks for the late reply and I can understand perfectly why it was that late. Actually I put that project on-hold and refunded the client, but It still available if I could find a solution for color distortion. I found that Aurigma GM 3.5 for .Net have fixed the bug. If so I am planning to hire a .net programmer to do the job for me.

Quote:

However could you tell why the way I described before did not work (when you created empty bitmap of necessary color and cut it with a mask image)?

I am sorry, I cant explain it. Only thing I know is, when I apply the mask, colors got changed, Since my application is going to be an on-line custom guitar creation tool, It is necessarily wants accurate color manipulations. If you are interested I can send you all the files for review. Thank you for being helpful :)

-Nish

Andrew  
#4 Posted : Friday, February 17, 2006 12:43:56 PM(UTC)
Andrew

Rank: Advanced Member

Groups: Member, Administration
Joined: 8/2/2003(UTC)
Posts: 876

Thanks: 2 times
Was thanked: 27 time(s) in 27 post(s)
Quote:
I found that Aurigma GM 3.5 for .Net have fixed the bug.

This is not a bug. This is a behaviour by design.

Did you try the solution from my previous post?

Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.