Proper image format to use for Alpha images?

  • Thread starter Andrew Christiansen
  • Start date
A

Andrew Christiansen

Hey all. The images I create in photoshop with semi-transparent pixels (for
instance in Photoshop text with a dropshadow with a transparent canvas) I've
been saving in PNG format and then using them in my VB.NET app using the
picturebox control. I was really happy when I learned that you could use
PNG images in VB.NET so your images could blend in with the form's
background color. But, is PNG the ideal image format to use with these
types of images? I don't know if there is some other format that is
recommended for Alpha images other than PNG.

No big deal, just curious. Thanks.

Andrew
 
H

Herfried K. Wagner [MVP]

* "Andrew Christiansen said:
Hey all. The images I create in photoshop with semi-transparent pixels (for
instance in Photoshop text with a dropshadow with a transparent canvas) I've
been saving in PNG format and then using them in my VB.NET app using the
picturebox control. I was really happy when I learned that you could use
PNG images in VB.NET so your images could blend in with the form's
background color. But, is PNG the ideal image format to use with these
types of images? I don't know if there is some other format that is
recommended for Alpha images other than PNG.

Why not? If PNG fits your requirements, it's perfect. Personally, I
like the PNG format and prefer it to GIF or JPEG.
 
O

One Handed Man [ OHM# ]

Why do you prefer it ?

Regards - OHM
Why not? If PNG fits your requirements, it's perfect. Personally, I
like the PNG format and prefer it to GIF or JPEG.

Regards - OHM# OneHandedMan{at}BTInternet{dot}com
 
O

One Handed Man [ OHM# ]

Im not that familiar with it, what are the basic differences, ( things you
can do with PNG ) that you cant with the JPEg for example ?

OHM
It's an open and very flexible format.

Regards - OHM# OneHandedMan{at}BTInternet{dot}com
 
O

One Handed Man [ OHM# ]

Hey dont worry, PNG looks good.


http://www.aurigma.com/support/defa...src=Help/GraphicsProcessor/PNGEncoderInfo.htm


Andrew said:
Hey all. The images I create in photoshop with semi-transparent
pixels (for instance in Photoshop text with a dropshadow with a
transparent canvas) I've been saving in PNG format and then using
them in my VB.NET app using the picturebox control. I was really
happy when I learned that you could use PNG images in VB.NET so your
images could blend in with the form's background color. But, is PNG
the ideal image format to use with these types of images? I don't
know if there is some other format that is recommended for Alpha
images other than PNG.

No big deal, just curious. Thanks.

Andrew

Regards - OHM# OneHandedMan{at}BTInternet{dot}com
 
C

Cor

Hi Herfried,

Serious, I also want to know that as OHM.

Because I thougth JPG has more posibilities in .Net
(I did not see much with encoding at PNG, but I can be wrong)

Cor
 
H

Herfried K. Wagner [MVP]

* "Cor said:
Serious, I also want to know that as OHM.

Because I thougth JPG has more posibilities in .Net
(I did not see much with encoding at PNG, but I can be wrong)

It depends on what you want to do...
 
A

Andrew Christiansen

Hey everyone. Maybe I can clear up PNG format really quickly cause it seems
not a lot of people are taking advantage of PNG image support in VB.NET.
PNG has way more possibilities than JPEG, GIF, or BMP. The PNG format can
hold pixels that are semi-transparent (commonly called Alpha blending). For
instance in the JPEG, GIF, or BMP format, either a pixel is transparent (the
pixel behind the transparent pixel in the image is shown completely through)
or its not transparent (the pixel behind isn't visible at all). But, the
PNG format can have pixels that let the pixel behind it shine through
half-way on a scale 0 - 255 (0 being totally transparent, 255 being totally
opaque). VB.NET supports the PNG format, so you can create high quality
anti-aliased images with, for instance, drop shadows that blend in with your
form's background color, not matter what color it is.

To demonstrate, create a new Photoshop image that is 16x16 in size with a
transparent background. Create a new layer. Choose a solid red color (R:
255, G: 0, B: 0), and use the paint bucket to fill the new layer with the
color. Set the opacity of the new layer to 50% (that means all the pixels
in that layer let any pixels underneath it shine through it just half way).
Because there is nothing underneath that layer, you should see a slight
glimpse of the checkerboard through the solid red pixels (in Photoshop the
checkerboard symbolizes transparency). Now click File > Save As... > and
save as a PNG file. Create a VB.NET project and add a picturebox to the
form and load the PNG image into the picture box. Wow! Notice how the
BackColor of the picturebox is shining 50% through the solid red. Now
change the BackColor to a different color, see, it always blends 50% with
the solid red pixels. Now try saving as a JPEG and loading it into the
picture box, the 50% red pixels don't blend with the background color,
because JPEG doesn't support Alpha blending.

Whew. Tried my best to explain that as best I could, hopefully I didn't get
anything wrong. In my opinion everybody should use PNG images in their .NET
projects. Hope this helps anyone out.

Andrew
 
C

Crirus

I agree with you... I have only one objection to it... is quite big reported
to the other ones... a 10k gif is 150K png... ok, no levels of transparency
only 1 or 0 ...
Depending on application it whould like to have a function that take the
full opaque image, a grayscale mask and render a translucent image
acordingly to the levels of grays ...
I whould like that implemented in Framework, to avoid using unmanaged code
to do it myself... speed is an issue for managed code
 
C

Crirus

Yeah, I tryed all I could find about transparency as I work with sprites and
shadows on my game graphics... I have a internet explorer client that should
be transfered on player machine and connect back to server for data..anyway
I try to shrink as much as possible the client to minimise the data
transfered....
Now, with a set of sprites as png, my client becamed so quick 2 Mega on size
so I dropped the ideea...
I use gifs instead and sime tricks to do shadows... but still whould be
better to have a maskBlt in GDI+, as fast as possible, without need of
unmanaged memory :)
 
H

Herfried K. Wagner [MVP]

* "Andrew Christiansen said:
Whew. Tried my best to explain that as best I could, hopefully I didn't get
anything wrong. In my opinion everybody should use PNG images in their .NET
projects. Hope this helps anyone out.

Thank you for the really excellent explanation!
 
H

Herfried K. Wagner [MVP]

* "Crirus said:
I agree with you... I have only one objection to it... is quite big reported
to the other ones... a 10k gif is 150K png... ok, no levels of transparency
only 1 or 0 ...

.... and a limitation to 256 colors in GIF format.
Depending on application it whould like to have a function that take the
full opaque image, a grayscale mask and render a translucent image
acordingly to the levels of grays ...
I whould like that implemented in Framework, to avoid using unmanaged code
to do it myself... speed is an issue for managed code

Yopu will have to use C# + 'unsafe' blacks in order to archieve a good
performance:

Part 1: <http://www.codeproject.com/cs/media/csharpgraphicfilters11.asp>
Part 2: <http://www.codeproject.com/cs/media/csharpfilters.asp>
Part 3: <http://www.codeproject.com/cs/media/edge_detection.asp>
Part 4: <http://www.codeproject.com/cs/media/imageprocessing4.asp>
Part 5: <http://www.codeproject.com/cs/media/DisplacementFilters.asp>
 
C

Cor

Hi Andrew,

Thanks you also, it gives a new shining on my knowledge of this, when the
time is there I will try it, but for now I know it and because of your
explanation I believe you without trying it.

Thanks.

Cor
 
C

Cor

Hi Herfried,

What is the different between posters, when I was begging to you for this
links I got nothing, now I am busy with something else but I think then it
could have helped me.

Cor
 
H

Herfried K. Wagner [MVP]

* "Cor said:
What is the different between posters, when I was begging to you for this
links I got nothing, now I am busy with something else but I think then it
could have helped me.

You really wanted these links?

;-)))
 

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