G
Guest
I have 2 questions that are just the opposite to one another:
(1) I need to read an image file (like bitmap, jpeg etc.) and to save only
its data, I need to save his data in a raw data format, meaning; I don't want
to save the image header, only the pixels data.
the raw data should be saved in a byte array.
The direct way is to do a loop over the image pixels and to copy pixel by
pixel to the byte array.
I'm looking for another way to do that. Is there a .NET function/method that
does it?
The following code is not good because it saves also the bitmap header to
the byte array:
Bitmap img = Bitmap.FromFile(@"C:\WINDOWS\Blue Lace 16.bmp", true) as Bitmap;
MemoryStream ms = new MemoryStream();
img.Save(ms, img.RawFormat);
byte[] rawData = ms.ToArray();
(1) I have a raw data image in a byte array, and I need to build a bitmap
from it.
The raw data does not contain the image format (width and height), but I do
have it in other variables (int width; int height).
How do I do that?
(1) I need to read an image file (like bitmap, jpeg etc.) and to save only
its data, I need to save his data in a raw data format, meaning; I don't want
to save the image header, only the pixels data.
the raw data should be saved in a byte array.
The direct way is to do a loop over the image pixels and to copy pixel by
pixel to the byte array.
I'm looking for another way to do that. Is there a .NET function/method that
does it?
The following code is not good because it saves also the bitmap header to
the byte array:
Bitmap img = Bitmap.FromFile(@"C:\WINDOWS\Blue Lace 16.bmp", true) as Bitmap;
MemoryStream ms = new MemoryStream();
img.Save(ms, img.RawFormat);
byte[] rawData = ms.ToArray();
(1) I have a raw data image in a byte array, and I need to build a bitmap
from it.
The raw data does not contain the image format (width and height), but I do
have it in other variables (int width; int height).
How do I do that?