Rank: Advanced Member
Groups: Guest
Joined: 8/3/2003(UTC) Posts: 1,070
Thanks: 1 times Was thanked: 12 time(s) in 12 post(s)
|
Hello, I offer you to try another way to draw antialiased text without transparentize transformation. The main idea of this method is to separately prepare alpha channel of the temporary image on which shadow is applied. Code:'Create bitmap object which contains image on which we want to draw text
Dim bitmap As New Aurigma.GraphicsMill.Bitmap(Aurigma.GraphicsMill.RgbColor.Green, 200, 200, Aurigma.GraphicsMill.PixelFormat.Format24bppRgb)
bitmap.ColorManagement.ConvertToContinuous(Aurigma.GraphicsMill.ColorSpace.Rgb, False, False)
'Get width and height of the loaded image
Dim BitmapHeight = bitmap.Height
Dim BitmapWidth = bitmap.Width
'Set text output properties
Dim font As New Aurigma.GraphicsMill.Drawing.Font("Arial", 12, True, False)
'Create bitmap with transparent background
Dim bitmapText As New Aurigma.GraphicsMill.Bitmap(Aurigma.GraphicsMill.RgbColor.Green, BitmapWidth, BitmapHeight, _
Aurigma.GraphicsMill.PixelFormat.Format24bppRgb)
Dim graphics As Aurigma.GraphicsMill.Drawing.GdiGraphics = bitmapText.GetGdiGraphics()
'Draw text
Dim brush As New Aurigma.GraphicsMill.Drawing.SolidBrush(Aurigma.GraphicsMill.RgbColor.Blue)
graphics.DrawString("Merci jack", font, brush, 5, 5)
'Dispose graphics
graphics.Dispose()
'Create alpha channel mask
Dim bitmapAlphaText As New Aurigma.GraphicsMill.Bitmap(Aurigma.GraphicsMill.RgbColor.Black, BitmapWidth, BitmapHeight, _
Aurigma.GraphicsMill.PixelFormat.Format24bppRgb)
graphics = bitmapAlphaText.GetGdiGraphics()
'Draw text on alpha channel mask
brush = New Aurigma.GraphicsMill.Drawing.SolidBrush(Aurigma.GraphicsMill.RgbColor.White)
graphics.DrawString("Merci jack", font, brush, 5, 5)
'Dispose alpha channel mask graphics
graphics.Dispose()
bitmapAlphaText.ColorManagement.ConvertToContinuous(Aurigma.GraphicsMill.ColorSpace.GrayScale, False, False)
'Add alpha channel
bitmapText.Channels.AddAlpha(0)
bitmapText.Channels(Aurigma.GraphicsMill.ColorChannel.Alpha) = bitmapAlphaText
'Apply shadow effect on text
bitmapText.Transforms.Shadow(Aurigma.GraphicsMill.RgbColor.Black, 8, 8, 4, False)
'Draw text on bitmap
bitmapText.Draw(bitmap, 0, 0, bitmapText.Width, bitmapText.Height, Aurigma.GraphicsMill.Transforms.CombineMode.Alpha, _
1, Aurigma.GraphicsMill.Transforms.InterpolationMode.LowQuality)
bitmap.Save("c:\1.png")
If quality of generated images is not appropriate, unfortunately we have to use GDI+ graphics to render text on image with alpha channel. Edited by user Sunday, December 23, 2007 6:13:52 PM(UTC)
| Reason: Not specified |
|