Rank: Member
Groups: Member
Joined: 8/30/2005(UTC) Posts: 5
|
Does anyone know how I can crop an elipticle image using Graphics Mill 2.0? I have been playing with the following code: mybitmap.Graphics.DrawEllipse -(x / 2), -(y / 2) - intOffset, 140 * 1.5, 175, False, True to try to achieve the same effect as cropping an ellipse but with little effect. I would rather use the crop method. Any assistance would be appreciated. Please send any response to iwhitney@iwdata.comThanks
|
|
|
|
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)
|
Hi Ira, To emulate a crop effect with non-rectangular shape, you need to do it in two steps: - Crop the image using the bounding rectangle of the shape you need.
- Draw the mask image which will contain the ellipse which you want to have and replace an alpha channel of the image by this mask. The areas you want to hide should be black (i.e. background), the areas you want to display should be white (i.e. the ellipse).
For example, let's assume that you have an ellipse described by its bounding rectangle. The code sample below demonstrates how to do it: Code:<!-- METADATA TYPE="typelib" UUID="{3CE48541-DE7A-4909-9314-9D0ED0D1CA5A}"-->
<%
Dim objBitmap, objMask
Dim ellipseX, ellipseY, ellipseWidth, ellipseHeight
ellipseX = 30
ellipseY = 50
ellipseWidth = 200
ellipseHeight = 150
' Create Bitmap object
Set objBitmap = Server.CreateObject("GraphicsMill.Bitmap")
Set objMask = Server.CreateObject("GraphicsMill.Bitmap")
' Load the image and crop it to fit the bounding rectangle of the ellipse
objBitmap.LoadFromFile Server.MapPath("source_image.jpg")
objBitmap.ConvertTo32bppArgb
objBitmap.Transforms.Crop ellipseX, ellipseY, ellipseWidth, ellipseHeight
' Create and initialize the mask image
objMask.CreateNew ellipseWidth, ellipseHeight, Format24bppRgb, ColorBlack
objMask.Graphics.Engine = DrawingEngineGdiplus
objMask.Graphics.Brush.PrimaryColor = ColorWhite
objMask.Graphics.DrawEllipse 0, 0, ellipseWidth, ellipseHeight, True, False
objMask.ConvertTo8bppGrayscale
objBitmap.Channels.Replace objMask, 3
objBitmap.Formats.SelectCurrent "PNG"
objBitmap.SaveToStream Response
%>
Edited by user Sunday, December 23, 2007 5:05:06 PM(UTC)
| Reason: Not specified
|
|
|
|
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.