PNG to byte[]

Memorice

New member
Joined
Feb 24, 2007
Messages
3
Programming Experience
3-5
Hey,

I would like to convert a png file (in ARGB format) to a byte array. And a byte array back to a png file.

Example:

A png file with height 10 and width 15 in ARGB format would be a byte array with 10*15*4 bytes. The alpha value of the first pixel would be at index 0, the Red value at index 1, etc...

At the moment I have a program in C# that can do this, by using a pointer to the pixels of the Gdk.Pixbuf from Gtk# library. But the problem is that this requires at least to install gtk runtime environment.

Thanks in advance,

Memorice
 
So you're using .Net 3.0 (with WPF PngBitmapDecoder class) and not .Net 2.0?
You can also use Bitmap.LockBits to get the BitmapData, there's some code in post 3 here.
 
Back
Top