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

Notification

Icon
Error

Options
Go to last post Go to first unread
ark2  
#1 Posted : Sunday, July 10, 2005 12:17:00 AM(UTC)
ark2

Rank: Member

Groups: Member
Joined: 7/5/2005(UTC)
Posts: 9

Hi,

I have a layer in my image, which is used as a glare on the image:

Code:
objGlareBitmap.CreateNew objEdgeBitmap.Width, objEdgeBitmap.Height/2, Format32bppArgb, &h66FFFFFF

objGlareBitmap.DrawOnBitmap objFaceBitmap, 3, 6, 26, 10, , , , ,CombineModeAlpha



I did receive a sample code from Andrew, who helped me A LOT! but I still don't get it...

I want to have an ellipse shape drawn, which is not going to show up in the final image, but instead will cut out a part of the objGlareBitmap, I guess that's mask, and I have no clue how to use those.

can I achieve this with one of the combine modes? And if so could someone show me some code how to cut out the pixels from the objGlareBitmap image using a shape of an ellipse?


tia

Edited by user Sunday, December 23, 2007 5:53:24 PM(UTC)  | Reason: Not specified

Andrew  
#2 Posted : Sunday, July 10, 2005 5:39:00 PM(UTC)
Andrew

Rank: Advanced Member

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

Thanks: 2 times
Was thanked: 25 time(s) in 25 post(s)
The sample I sent you contains the following block:

Code:
'''''''''''''''''MASK CODE SAMPLE'''''''''''''''''''''''''''''''''''''
Dim objMaskBitmap
Set objMaskBitmap = Server.CreateObject("GraphicsMill.Bitmap")

' Black = 00 = transparent
' White = FF = 100% opaque 
' Gray (between 00 and FF) - semitransparent.
'
' So we need to draw gray objects on the black background. 
objMaskBitmap.CreateNew objGlareBitmap.Data.Width, objGlareBitmap.Data.Height, Format24bppRgb, ColorBlack

' NOTE, after you replace alpha channel, the transparency which you specify 
' during creation of objGlareBitmap will be discarded. So you need to draw
' gray object rather than white (to make it semitransparent)
objMaskBitmap.Graphics.Brush.PrimaryColor = &hFF555555

objMaskBitmap.Graphics.Engine = DrawingEngineGdiplus
objMaskBitmap.Graphics.DrawEllipse 0,0,objGlareBitmap.Data.Width, objGlareBitmap.Data.Height,True,False

' To replace the glare's alpha channel by this image, we need to convert
' it to 8-bit grayscale. We could not make it earlier, because GDI and GDI+
' do not support drawing on grayscale bitmaps.
objMaskBitmap.Data.ConvertTo8bppGrayscale
' Alpha channel is always the very last channel in the bitmap.
objGlareBitmap.Channels.Replace objMaskBitmap, 3'objGlareBitmap.Channels.Count - 1
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''


Here the script creates an empty black bitmap which has the same dimensions as our glare bitmap. Then it draws a gray ellipse. You can draw any other shape here if necessary. After that this bitmap is converted to grayscale and inserted into the glare bitmap.

Those pixels which corresponds to black pixels in the mask are clipped. The brightness of the mask pixel specifies an opacity of the corresponding pixel in the main bitmap. That is why the gray ellipse drawn on the mask will clip the glare bitmap outside of this ellipse and make pixels inside the ellipse semitransparent.

Edited by user Sunday, December 23, 2007 5:53:37 PM(UTC)  | Reason: Not specified

ark2  
#3 Posted : Sunday, July 10, 2005 6:50:00 PM(UTC)
ark2

Rank: Member

Groups: Member
Joined: 7/5/2005(UTC)
Posts: 9

Andrew,

I need it the other way around, the code you posted above creates a translucent ellipse in the end.

I need the glare layer to have a hole the shape of the ellipse in the end....

The other way around....
Andrew  
#4 Posted : Sunday, July 10, 2005 9:57:00 PM(UTC)
Andrew

Rank: Advanced Member

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

Thanks: 2 times
Was thanked: 25 time(s) in 25 post(s)
If you need a hole, it means that you need to draw black ellipse on white (or gray) background.
ark2  
#5 Posted : Sunday, July 10, 2005 10:02:00 PM(UTC)
ark2

Rank: Member

Groups: Member
Joined: 7/5/2005(UTC)
Posts: 9

Oh my god! now I get it =) thank you! I'm learning all this as I go along, I have 0 experience with any of this...

thanks!
Users browsing this topic
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.