Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I need code to copy a 16bit screen to bmp file
#11
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?
ravelling Curmudgeon
(geocities sites require copying and pasting URLs.)
I liked spam better when it was something that came in a can.
Windows should be defenestrated.
Reply
#12
it still doesn't work. I tried 128 as a padding byte.
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#13
"4" instead of "3"?
ravelling Curmudgeon
(geocities sites require copying and pasting URLs.)
I liked spam better when it was something that came in a can.
Windows should be defenestrated.
Reply
#14
yes, I did.
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#15
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.
Reply
#16
EDIT: NM.

Thanks Sterling Christensen for the help. It now works! COOL! Smile
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#17
(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.
ravelling Curmudgeon
(geocities sites require copying and pasting URLs.)
I liked spam better when it was something that came in a can.
Windows should be defenestrated.
Reply
#18
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!
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)