Get RAW Bitmap Data from a file



Hi All,

I have some Windows BMP, 1BPP, monochrome files that I need to get the
raw data from to load a graphics buffer on a Roll Printer (which I
know can be done). Lets forget about the Roll Printer in this equation
as I am not sure I am getting the correct "raw" image from the file.

However, when I print what I think is the raw data, I get the image
size, but the information within the image looks nothing like it
should be, and looks like it is an out of sync TV, or interlaced not
progressive. But, the image itself is unreadable, nothing looking even
remotely to the original.

What I need to verify (or am asking for help) is to get the raw data
out of the bitmap file correctly. Here is some code that I use to get
the raw data (I think).

Dim bmBitmap As Image = New Bitmap("test.bmp")
(also tried Dim bmBitmap As bitmap= New Bitmap("test.bmp") )

Dim raw As System.Drawing.Imaging.BitmapData = Nothing 'used to get
attributes of the image
Dim rawImage() As Byte = Nothing 'the image as a byte[]

Try
'Freeze the image in memory
raw = bmbitmap.LockBits(New Rectangle(0, 0,
bmbitmap.Width, bmbitmap.Height),
System.Drawing.Imaging.ImageLockMode.ReadOnly,
Imaging.PixelFormat.Format1bppIndexed)

Dim size As Integer = raw.Height * raw.Stride
rawImage = New Byte(size - 1)

'Copy the image into the byte()
System.Runtime.InteropServices.Marshal.Copy(raw.Scan0,
rawImage, 0, size)
Finally
If Not raw Is Nothing Then
'Unfreeze the memory for the image
bmbitmap.UnlockBits(raw)
End If
End Try


The rawimage is what I try to print.

Am I doing something wrong or am I missing some steps.

I have also tried to load the RAWIMAGE returned bytes in a PictureBox,
with the following code

Dim ms As New IO.MemoryStream(rawimage)
pbPicture.Image = Image.FromStream(ms) <-- errors here

but get the "PARAMETER IS INCORRECT" error message, and I know from
other posts, this is usually because the BYTE data is invalid (or not
raw), although the byte length returned is 2880 bytes, which does
equate to the width*height*8 of the image.

So, to state again, I just need the raw bytes that makeup the image
within the bmp files.. I am sure I am close, but I am also sure I
might be missing out on one step.

Any help/links most appreciated.

Thanks,
Robert
.



Relevant Pages

  • Re: Could you actually see photos made from RAW files?
    ... interpolation if the raw data is written to file in unmodified form. ... This is likely to involve interpolation. ... Bayer sensor data to jpeg. ...
    (rec.photo.digital)
  • Re: Could you actually see photos made from RAW files?
    ... interpolation if the raw data is written to file in unmodified form. ... This is likely to involve interpolation. ... Bayer sensor data to jpeg. ...
    (rec.photo.digital)
  • Re: RAW vs JPEGs - Does RAW show more detail?
    ... conversion settings that the user chose when converting it. ... technically it is not saving to the raw file itself, ... JPEG reflects the most recent tweaks you've made. ... and regenerate the image each time from the raw data. ...
    (rec.photo.digital.slr-systems)
  • Re: RAW is WAR
    ... >> That is preceisely the point with RAW. ... >> great surprise to anyone that the digital camera consists of a lot more ... >> automatically in converting the RAW data to superfine JPG surpasses what ... >> really grasping how digital photography works. ...
    (alt.photography)
  • Re: RAW is WAR
    ... >> 1DS, and then converted them to sRGB, they are flat and colourless prints ... I assume that RAW files are left deliberately "flat" so that ... great surprise to anyone that the digital camera consists of a lot more than ... automatically in converting the RAW data to superfine JPG surpasses what I ...
    (alt.photography)

Loading