Using GDI+ to crop PNGs without loosing their transparency

EFileTahi-A

Well-known member
Joined
Aug 8, 2004
Messages
539
Location
Portugal / Barreiro
I can crop them easly but the minute I draw it back it becomes opaque :(
Code:
Bitmap bitSize = new Bitmap(32, 32);
Image pic = Bitmap.FromFile(sCurrentFile,true);
Graphics g = Graphics.FromImage(bitSize);
g.DrawImage(pic, dstRectangle, srcRectangle, GraphicsUnit.Pixel) ;

I really dont know how to make it working, I think when I load the image to the Bitmap object it simply looses its tranparency alpha channel, no?
 
Try explicitly specifying an ARGB format in the Bitmap constructor . If that doesnt work, try setting the compositing mode of the graphics object to CompositingMode.SourceCopy. The default is SourceOver, which performs an alpha blend. SourceCopy copies the alpha data instead of blending it.
 
Back
Top