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

Reduce capacity of image

Hi,

I have downloaded the trial version to check some function i need before buying. Your component does great work on combining, rotating, reisize images. But how can i reduce the the capicity of a .png or .gif file (transparent image)? Please help!!

Thanks,
Hi,

When I reduce the file size by applying "Color reduction for Web", some transparent part on the image file become white. How can i deal with the problem? Please help!!
Hello,

As palette can contain no more than 256 colors, you can specify only transparent regions in your image. By-default if you convert image to indexed format, it discards alpha channel. To avoid this problem you should blend your image with some unique color - let's name this color "transparent color". So all transparent regions are marked by this "transparent color. Then you should convert your image to indexed format and then set element of palette which corresponds to "transparent color" as transparent.

Here is small code sample which illustrates this idea:
// Color by which transparent pixels will be marked.
Aurigma.GraphicsMill.RgbColor transparentColor = Aurigma.GraphicsMill.RgbColor.Blue;

// Source bitmap with transparency.
Aurigma.GraphicsMill.Bitmap bitmap = new Aurigma.GraphicsMill.Bitmap(@"d:/images/test/Transptest.png");

// Mark all transparent pixels by transparentColor.
bitmap.Channels.DiscardAlpha(transparentColor);

// Convert image to indexed.
bitmap.ColorManagement.ConvertToIndexed(8, Aurigma.GraphicsMill.ColorPaletteType.Adaptive, null, 0, Aurigma.GraphicsMill.Transforms.DitheringType.FloydSteinberg, 1.0f);

// Set element in palette which corresponds to transparentColor as transparent.
int transparentIndex = bitmap.Palette.FindNearestIndex(transparentColor);
Aurigma.GraphicsMill.RgbColor color = bitmap.Palette[transparentIndex];
bitmap.Palette[transparentIndex] = Aurigma.GraphicsMill.Color.FromArgb(0, color.R, color.G, color.B);

// Saves the result.
bitmap.Save(@"d:/temp/test.gif");