|
|
Rank: Newbie Groups: Member
Joined: 12/17/2007 Posts: 2 Points: -91
|
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();
|
|
Rank: Newbie Groups: Member
Joined: 12/17/2007 Posts: 2 Points: -91
|
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
|
|
Rank: Advanced Member Groups: Administration
, Member
Joined: 8/3/2003 Posts: 607 Points: 651
|
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.
|
|
|
Guest |