Qbasicnews.com

Full Version: I need code to copy a 16bit screen to bmp file
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
you have the line

n$ = SPACE$(xRes * 3)

That seems to imply, given how you're using n$, that you're writing three bytes per pixel. If I remember right what I read in my BMP format document, isn't there a fourth padding byte for each pixel?
it still doesn't work. I tried 128 as a padding byte.
"4" instead of "3"?
yes, I did.
No, there's no padding after each pixel, but there is padding after each scanline - you have to add enough zero bytes to make the length a multiple of 4 - in other word the scanlines must be dword aligned.

You know what would be so much easiler? Forget the header, just output only the 24 bit pixels, and save it as a .RAW file. Then you can open it in Paint Shop Pro (or possibly Photoshop). All you have to do is specify the width and height of the image, tell it the image isn't planar, and whether the image is in rgb order or bgr. Then making it a bitmap is as simple as File->Save As... That's what I do.

I'm sure a lot of other Windows image editors can handle raw format.
EDIT: NM.

Thanks Sterling Christensen for the help. It now works! COOL! Smile
(I'm once again screwing around at work.) I would've mentioned the requirement that the byte width be a multiple of 4 but I figured the (apparently mythological) fourth padding byte for each pixel would take care of that.

Quote:No, there's no padding after each pixel, but there is padding after each scanline - you have to add enough zero bytes to make the length a multiple of 4 - in other word the scanlines must be dword aligned.

You know what would be so much easiler? Forget the header, just output only the 24 bit pixels, and save it as a .RAW file. Then you can open it in Paint Shop Pro (or possibly Photoshop). All you have to do is specify the width and height of the image, tell it the image isn't planar, and whether the image is in rgb order or bgr. Then making it a bitmap is as simple as File->Save As... That's what I do.

I'm sure a lot of other Windows image editors can handle raw format.
Still, it'd be nice to be able to convert to a bmp.

This header is messed up, SOMEwhere:

EDIT: I compared a bmp header and this one, and this is what I came up with:

Code:
prstring$ = CHR$(0) + CHR$(0) + CHR$(1) + CHR$(0) + CHR$(24)
prstring$ = prstring$ + STRING$(6, CHR$(0))
prstring$ = prstring$ + CHR$(249) + CHR$(21) + CHR$(0)
prstring$ = prstring$ + CHR$(196) + CHR$(14) + CHR$(0) + CHR$(0) + CHR$(196)
prstring$ = prstring$ + CHR$(14) + STRING$(10, CHR$(0))
n$ = "BM": PUT #1, , n$
n& = xRes: n& = n& * yRes * 3: n& = n& + 54: PUT #1, , n&
n% = 0: PUT #1, , n%
n% = 0: PUT #1, , n%
n% = 54: PUT #1, , n%
n% = 0: PUT #1, , n%
n% = 40: PUT #1, , n%
n% = 0: PUT #1, , n%
n% = xRes: PUT #1, , n%
n% = 0: PUT #1, , n%
n% = yRes: PUT #1, , n%
PUT #1, , prstring$

And now it works. Yeergh!
Pages: 1 2