T
Telmo Costa
Hi.
I'm trying to load an image and copy it to an array of bytes.
The image is a png 32bit format. The code I have is:
-------------------------------------------------------------
public void LoadImage(path) {
Bitmap image = new Bitmap(path);
byte[] pixels = new byte[image.Width*image.Height*4];
int offset;
for (int x=0; x<image.Width; x++) {
for (int y=0; y<image.Height; y++) {
Color c = image.GetPixel(x, y);
offset = (y*image.Width + x)*4;
pixels[offset] = c.R;
pixels[offset+1] = c.G;
pixels[offset+2] = c.B;
pixels[offset+3] = c.A;
)
);
}
I'm trying to load an image and copy it to an array of bytes.
The image is a png 32bit format. The code I have is:
-------------------------------------------------------------
public void LoadImage(path) {
Bitmap image = new Bitmap(path);
byte[] pixels = new byte[image.Width*image.Height*4];
int offset;
for (int x=0; x<image.Width; x++) {
for (int y=0; y<image.Height; y++) {
Color c = image.GetPixel(x, y);
offset = (y*image.Width + x)*4;
pixels[offset] = c.R;
pixels[offset+1] = c.G;
pixels[offset+2] = c.B;
pixels[offset+3] = c.A;
)
);
}