Hi folks,
Thanks in advance to all of you geniouses.
Here is what I am doing:
This is an ASP.net 2.0 with C# problem.
I am reading an image file (either: gif, jpg or png of any dimension) as such:
Image rImg = Image.FromFile(RawFilePath)
Next I create a Bitmap and extract graphic as such:
Bitmap wImage = new Bitmap(200, 200, PixelFormat.Format24bppRgb)
Graphics g = Graphics.FromImage(wImage)
Next I draw the Image in the graphic using only 50x50 square from the topleft corner of the rImg as such:
g.DrawImage(rImg, new Rectangle(0, 0, 200, 200), new Rectangle(0,0,50,50), GraphicsUnit.Pixel);
Finally I save the bitmap to disk as such:
wImg.Save(filePath, ImageFormat.Png);
Now here is the problem:
By design I can accept any of the three types of images (gif, png, jpg) and of any dimension. I must also by design only select the 50x50 square from the topleft corner and save as 200x200. Now here is the issue: My objective is to preserve transperencey, especially in case of png files. Right now when I try to read a PNG that has transperency it save the transparent part of the image as black. How can I have it save the transaparent part as transparent? Thanks guys
Thanks in advance to all of you geniouses.
Here is what I am doing:
This is an ASP.net 2.0 with C# problem.
I am reading an image file (either: gif, jpg or png of any dimension) as such:
Image rImg = Image.FromFile(RawFilePath)
Next I create a Bitmap and extract graphic as such:
Bitmap wImage = new Bitmap(200, 200, PixelFormat.Format24bppRgb)
Graphics g = Graphics.FromImage(wImage)
Next I draw the Image in the graphic using only 50x50 square from the topleft corner of the rImg as such:
g.DrawImage(rImg, new Rectangle(0, 0, 200, 200), new Rectangle(0,0,50,50), GraphicsUnit.Pixel);
Finally I save the bitmap to disk as such:
wImg.Save(filePath, ImageFormat.Png);
Now here is the problem:
By design I can accept any of the three types of images (gif, png, jpg) and of any dimension. I must also by design only select the 50x50 square from the topleft corner and save as 200x200. Now here is the issue: My objective is to preserve transperencey, especially in case of png files. Right now when I try to read a PNG that has transperency it save the transparent part of the image as black. How can I have it save the transaparent part as transparent? Thanks guys