Image t_image = Image.FromFile(ResourceFile);
MemoryStream t_ms = new MemoryStream();
t_image.Save(t_ms, System.Drawing.Imaging.ImageFormat.Bmp);
byte[] t_byte = new byte[t_ms.Length - 54];
t_ms.Position = 54;
t_ms.Read(t_byte, 0, (int)t_ms.Length - 54);
That's how I'm accomplishing it right now. I know that the bmp header is 54 bytes.
Thanks,
Giawa
MemoryStream Image without header
Hello,
I'm trying to write a System.Drawing.Image into a MemoryStream without the header information. I only want to byte array that makes up the pixel data. Does anyone know of a way to do this? Right now I have to save the image into a MemoryStream and then copy that memory stream to a new byte array with a 54 byte offset.
I got it working, but something weird is happening. The image is being flipped on the y-axis. Any ideas of why this is happening? I can fix it with RotateFlip(RotateFlipType.RotateNoneFlipY); but I'd prefer to find out why it is happening in the first place. Thanks!
Giawa
Image t_bitmap = Bitmap.FromFile(ResourceFile);t_bitmap.RotateFlip(RotateFlipType.RotateNoneFlipY);System.Drawing.Imaging.BitmapData t_data = ((Bitmap)t_bitmap).LockBits(new Rectangle(0, 0, t_bitmap.Width, t_bitmap.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, t_bitmap.PixelFormat);
Giawa
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement