Save Bitmap as PNG with transparency?

B

Bjorn Brox

Hi!

Windows Mobile 6.0, CF 3.5

I noticed that Bitmap.Save(xxx, ImageFormat.Png) (and Gif) does not
preserve transparency when inspecting the image in for example PhotoShop.

I even tried to run through each pixel before the save by executing
if (bmp.GetPixel(x, y) == Color.White)
bmp.SetPixel(x, y, Color.Transparent);
(debug showed that the SetPixel statement was executed)

Does anyone have some solution on how to save a bitmap as PNG (or gif)
where white is made total transparent?
 
P

patash

Hi!

Windows Mobile 6.0, CF 3.5

I noticed that Bitmap.Save(xxx, ImageFormat.Png) (and Gif) does not
preserve transparency when inspecting the image in for example PhotoShop.

I even tried to run through each pixel before the save by executing
if (bmp.GetPixel(x, y) == Color.White)
bmp.SetPixel(x, y, Color.Transparent);
(debug showed that the SetPixel statement was executed)

Does anyone have some solution on how to save a bitmap as PNG (or gif)
where white is made total transparent?


Well instead try setting the white color as transparent in your code
and paint.

Ashish
 
P

patash

Hi!

Windows Mobile 6.0, CF 3.5

I noticed that Bitmap.Save(xxx, ImageFormat.Png) (and Gif) does not
preserve transparency when inspecting the image in for example PhotoShop.

I even tried to run through each pixel before the save by executing
if (bmp.GetPixel(x, y) == Color.White)
bmp.SetPixel(x, y, Color.Transparent);
(debug showed that the SetPixel statement was executed)

Does anyone have some solution on how to save a bitmap as PNG (or gif)
where white is made total transparent?

Hi,
Instead mark the white color transparent while painting.

Ashish
 
B

Bjorn Brox

(e-mail address removed) skrev:
Hi,
Instead mark the white color transparent while painting.

Ashish

The debugger shows that Color.Transparent is Color.White with alpha
channel set to zero.

An initial _graphics.Clear(Color.Transparent) did not help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top