The current version of IEvolution cannot transfer transparency to .net Image object.
You can try the following workaround:
ieViewer1.Image.LoadImage(“test.png");
pictureBox1.Image = CreateImageWithTransparency(ieViewer1.Image);
Where CreateImageWithTransparency is defined as:
public static Image CreateImageWithTransparency(IEImage image)
{
const int bytesPerPixel = 4;
Image originalImage = image.GetNetImage();
if ((originalImage.PixelFormat & PixelFormat.Indexed) == PixelFormat.Indexed)
{
return originalImage;
}
Bitmap bmp = new Bitmap(originalImage);
PixelFormat pxf = PixelFormat.Format32bppArgb;
Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height);
BitmapData bmpData = bmp.LockBits(rect, ImageLockMode.ReadWrite, pxf);
IntPtr ptr = bmpData.Scan0;
int numBytes = bmp.Width * bmp.Height * bytesPerPixel;
byte[] argbValues = new byte[numBytes];
System.Runtime.InteropServices.Marshal.Copy(ptr, argbValues, 0, numBytes);
for (int counter = 0, x = 0, y = 0; counter < argbValues.Length; counter += bytesPerPixel)
{
int pos = 0;
pos++; // B value
pos++; // G value
pos++; // R value
argbValues[counter + pos] = (byte)image.GetAlpha(x, y);
if (++x == bmp.Width)
{
x = 0;
++y;
}
}
System.Runtime.InteropServices.Marshal.Copy(argbValues, 0, ptr, numBytes);
bmp.UnlockBits(bmpData);
return bmp;
}
Nigel
Xequte Software
www.xequte.com
nigel@xequte.com