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
Todd Kneib  
#1 Posted : Thursday, May 11, 2006 5:19:36 AM(UTC)
Todd Kneib

Rank: Advanced Member

Groups: Guest
Joined: 5/10/2006(UTC)
Posts: 32

Thanks: 6 times
I'm evaluating the GraphicsMill package and am having a show stopper of an issue.

When I create a new, empty bitmap and draw a string on it, the text come out transparent. Specifically, when I display the aurigma bitmap in bitmapViewer or convert the bitmap to a GDI Bitmap and display that in a gdi picturebox, or when I save it as a png, the text ends up transparent. If I save it as a jpg, then the text is drawn in color.

Assembly Versions:

Aurigma.GraphicsMill, Version 3.5.405.0

Aurigma.GraphicsMill.WinControls, Version 3.5.2309.16502

Sample code

Code:
         Aurigma.GraphicsMill.Bitmap resultBitmap = 
            new Aurigma.GraphicsMill.Bitmap(Aurigma.GraphicsMill.RgbColor.CornflowerBlue, 300, 
                  200, Aurigma.GraphicsMill.PixelFormat.Format32bppArgb);

         Aurigma.GraphicsMill.Drawing.Font font = 
            new Aurigma.GraphicsMill.Drawing.Font("Futura Md BT", 20);
         font.HorizontalAlignment = Aurigma.GraphicsMill.Drawing.HorizontalAlignment.Center;

         Aurigma.GraphicsMill.Drawing.SolidBrush textBrush = 
            new Aurigma.GraphicsMill.Drawing.SolidBrush( Aurigma.GraphicsMill.RgbColor.Yellow);
         Aurigma.GraphicsMill.Drawing.SolidBrush backgroundBrush = 
            new Aurigma.GraphicsMill.Drawing.SolidBrush(Aurigma.GraphicsMill.RgbColor.CadetBlue);

         Aurigma.GraphicsMill.Drawing.GdiGraphics graphics2;
         graphics2 = resultBitmap.GetGdiGraphics();
         //This shows transparent except as jpg too
         //graphics2.FillRectangle(backgroundBrush, 0, 0, resultBitmap.Width, resultBitmap.Height);
         graphics2.DrawString("Aurigma Graphics Mill", font, textBrush, 150, 0);
         resultBitmap.SaveState();
         graphics2.Dispose();

         string filename = @"C:\AugWFTest_" + DateTime.Now.ToString("mmss");
         resultBitmap.Save(filename + ".jpg");
         resultBitmap.Save(filename + ".png");
         pictureBox1.Image = resultBitmap.ToGdiplusBitmap();
         bitmapViewerRendered.Bitmap = resultBitmap;
         pictureBox2.Image = Image.FromFile(filename + ".jpg");
         pictureBox3.Image = Image.FromFile(filename + ".png");

Attached is a screen shot. The bottom left is the display of the jpg, which is the only one that looks correct. The first is the BitmapViewer, and the others are PictureBoxes.

Note that it is not just drawing text. When I tried FillRectangle, it also had the same effect.

What do I need todo to get this working?

Thanks,

Todd

Edited by user Thursday, December 20, 2007 4:36:32 PM(UTC)  | Reason: Not specified

Todd Kneib attached the following image(s):
BadTransparentSample.PNG
Dmitry  
#2 Posted : Thursday, May 11, 2006 1:11:24 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 Todd,

Jpeg format doesn't support alpha channel, when you save an image into this format, alpha channel is just discarded.

Sincerely yours,

Dmitry Sevostyanov

UserPostedImage Follow Aurigma on Twitter!

Todd Kneib  
#3 Posted : Thursday, May 11, 2006 11:18:59 PM(UTC)
Todd Kneib

Rank: Advanced Member

Groups: Guest
Joined: 5/10/2006(UTC)
Posts: 32

Thanks: 6 times
Sorry, I didn't make myself clear. The transparency is unwanted. I did not specify an alpha value when creating the brushes (I did experiment though by adjusting it to 255, 128 and 0 of the color of the brush without any change), so I assume that the color should be opaque. I expect the Bitmap to display and save, regardless of file format, with no transparency at all. I do realize that jpgs don't support transparency. I do know that pngs do.

Please review the code in my original post and tell me what I'm doing wrong.

Note, that although this example does not use the alpha channel, I will need to be able to draw Images onto this bitmap that do have transparency, so I cannot just change the Bit format of the Bitmap to eliminate the alpha channel. I am using the PSD addon to change the text in the PSD and then render that out, much like Business Card demo webapp (but mine is a winform app).

I need to make sure I can get this to work before I have my manager purchase licenses.

Thanks,

Todd

Dmitry  
#4 Posted : Sunday, May 14, 2006 9:26:54 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 get it... You use Format32bppArgb pixel format, Windows GDI doesn't support this pixel format correctly, when you draw something onto 32bpp Argb format - it nulls alpha channel. Our GdiGraphics class incapsulates calls to Windows GDI, so when you draw a text, GDI sets alpha channel of pixels where text is drawn to 0. If you save result image with alpha channel (png) - you see your text as transparent, but if you store your image without it (jpeg) - everything is ok.

Try to change pixel format from Format32bppArgb to Format24bppRgb, and the problem should go out.

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.