This forum contains outdated content and is available for reading only. Please contact technical support if you have any questions.

Notification

Icon
Error

Options
Go to last post Go to first unread
Michel  
#1 Posted : Wednesday, May 11, 2005 7:12:00 PM(UTC)
Michel

Rank: Member

Groups: Guest
Joined: 4/24/2005(UTC)
Posts: 15

Hello!!

I want to draw antialiasing text on a image but it seems that pixels which are no longer used for the font are white. The problem is that the text become unreadable (with small size : 10 - 12).

Is it possible to apply a transparent or a color background to the font?

Thank you,

Michel

Dmitry  
#2 Posted : Wednesday, May 11, 2005 10:23:00 PM(UTC)
Dmitry

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,

To obtain more antialised text you should increase tolerance of transparentize transformation (in the following example the value is set to 0.5):

Code:
bitmapText.Channels.Transparentize(Aurigma.GraphicsMill.RgbColor.White, 0.5)

Try to set different values in range [0, 1] (minimum value (0) means exact match of the colors, maximum value (1) means that any color matches during transparentize) and evaluate the results.

Edited by user Sunday, December 23, 2007 6:13:16 PM(UTC)  | Reason: Not specified

Sincerely yours,

Dmitry Sevostyanov

UserPostedImage Follow Aurigma on Twitter!

Michel  
#3 Posted : Wednesday, May 18, 2005 10:12:00 PM(UTC)
Michel

Rank: Member

Groups: Guest
Joined: 4/24/2005(UTC)
Posts: 15

Hello,

I've tried many ways to render my text better but it seems that the antialiasing property is not considered. The result is the same if I put the Antialiased value in true or false.

Here is a part of my code :

Code:
Dim stream As New System.IO.MemoryStream(Image)

Dim bitmap As New Aurigma.GraphicsMill.Bitmap(stream)
bitmap.ColorManagement.ConvertToContinuous(Aurigma.GraphicsMill.ColorSpace.Rgb, True, False)

Dim BitmapHeight As Integer = bitmap.height
Dim BitmapWidth As Integer = bitmap.width

Dim bitmapText As New Aurigma.GraphicsMill.Bitmap(Aurigma.GraphicsMill.RgbColor.White, BitmapWidth, BitmapHeight, Aurigma.GraphicsMill.PixelFormat.Format24bppRgb)
Dim graphics As Aurigma.GraphicsMill.Drawing.GdiGraphics = bitmapText.GetGdiGraphics()

[...]

Dim font As New Aurigma.GraphicsMill.Drawing.Font(police, TAILLE, STYLE_POLICE_GRAS, STYLE_POLICE_ITALIQUE)
font.AntiAliased = false/true

[...]

bitmapText.Channels.Transparentize(Aurigma.GraphicsMill.RgbColor.White, 0.5)

[...]

Can someone help me?

Thank you

Michel

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

Dmitry  
#4 Posted : Thursday, May 19, 2005 11:00:00 PM(UTC)
Dmitry

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

Sincerely yours,

Dmitry Sevostyanov

UserPostedImage Follow Aurigma on Twitter!

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.