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
Taylor Nicholls  
#1 Posted : Monday, December 17, 2007 3:10:47 AM(UTC)
Taylor Nicholls

Rank: Newbie

Groups: Guest
Joined: 12/17/2007(UTC)
Posts: 2

Hello All,

I have a quick question about the proper syntax to assign a know colour (i.e. white or 255,255,255) to be transparent when I save the processed tile. I have provided a code snippet as an example. It may be a problem that I "Transparentize" a channel then continue onto convert that same image to an indexed format.

Thanks in advance, Taylor

Code:

                            Aurigma.GraphicsMill.Bitmap oOutputMap = new Aurigma.GraphicsMill.Bitmap(256, 256, Aurigma.GraphicsMill.PixelFormat.Format24bppRgb);
                            Aurigma.GraphicsMill.Drawing.GdiGraphics oOutputMapGraphic = oOutputMap.GetGdiGraphics();

                            oOutputMapGraphic.DrawImage(bitmap, new RectangleF(0, 0, 256, 256), new RectangleF(0, 0, 256, 256), Aurigma.GraphicsMill.Transforms.CombineMode.Copy, 1, Aurigma.GraphicsMill.Transforms.InterpolationMode.Bilinear);

                            oOutputMap.Channels.Transparentize(Aurigma.GraphicsMill.Color.FromRgb(255, 255, 255), 0);

                            oOutputMap.ColorManagement.PaletteEntryCount = 8;
                            oOutputMap.ColorManagement.ConvertToIndexed(8, Aurigma.GraphicsMill.ColorPaletteType.Adaptive, null);
                            
                            oOutputMap.Save("1.png");

                            oOutputMap.Dispose();
                            oOutputMapGraphic.Dispose();

Edited by user Monday, December 17, 2007 9:15:26 AM(UTC)  | Reason: Not specified

Taylor Nicholls  
#2 Posted : Monday, December 17, 2007 3:23:29 AM(UTC)
Taylor Nicholls

Rank: Newbie

Groups: Guest
Joined: 12/17/2007(UTC)
Posts: 2

Thanks to all,

This seems to enable the "Transparentize" function to operate as expected, it was placed directly ahead of that call:

Code:

                            if (!oOutputMap.HasAlpha)
                            {
                                oOutputMap.Channels.AddAlpha(1);
                                oOutputMap.ColorManagement.BuildAdaptivePaletteWithAlpha = true;
                                oOutputMap.ColorManagement.PaletteAlphaThresholdUsed = true;
                                oOutputMap.ColorManagement.PaletteAlphaThreshold = 255;
                            }

Have a great day. Taylor

Edited by user Monday, December 17, 2007 9:15:53 AM(UTC)  | Reason: Not specified

Dmitry  
#3 Posted : Monday, December 17, 2007 2:24:10 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,

Thanks for your post.

We have made a modification in the last versions of Graphics Mill for .NET: now if you try to create Aurigma.GraphicsMill.Drawing.GdiGraphics on ARGB32 bitmap exception is thrown. It was made because GDI does not work with alpha channels correctly. So I have modified your code and now it should work with the last versions of Graphics Mill for .NET.

Code:

using(Aurigma.GraphicsMill.Bitmap bitmap = new Aurigma.GraphicsMill.Bitmap("c:/pattern.png"))
{
    using(Aurigma.GraphicsMill.Bitmap oOutputMap = new Aurigma.GraphicsMill.Bitmap(
        256, 256, Aurigma.GraphicsMill.PixelFormat.Format24bppRgb))
    {
        bitmap.Draw(oOutputMap, new System.Drawing.RectangleF(0, 0, 256, 256), 
            new System.Drawing.RectangleF(0, 0, 256, 256), 
            Aurigma.GraphicsMill.Transforms.CombineMode.Copy, 1, 
            Aurigma.GraphicsMill.Transforms.InterpolationMode.Bilinear);
        oOutputMap.Channels.Transparentize(Aurigma.GraphicsMill.Color.FromRgb(255, 255, 255), 0);

        oOutputMap.ColorManagement.BuildAdaptivePaletteWithAlpha = true;
        oOutputMap.ColorManagement.PaletteAlphaThresholdUsed = true;
        oOutputMap.ColorManagement.PaletteAlphaThreshold = 255;
        oOutputMap.ColorManagement.ConvertToIndexed(8, Aurigma.GraphicsMill.ColorPaletteType.Adaptive, null);

        oOutputMap.Save("c:/1.png");
    }
} 
Sincerely yours,

Dmitry Sevostyanov

UserPostedImage Follow Aurigma on Twitter!

Users browsing this topic
Guest (3)
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.