Advertisement

BITMAP STUFF

Started by February 09, 2000 03:34 PM
17 comments, last by ThaUnknownProgga 24 years, 6 months ago
Hey, I just noticed something. The weird coloring and skewing/moving or whatever occurs only at places where there is black! So with that information does anyone have any other ideas about what to do?

here''s current code

WriteBuffer array of BYTE
BufferIndex is an int
outpixel of type DWORD
outbyte is an int

for (loop=Height-1;loop>=0;loop--) //Loop bottom up
{
for (loop2=0;loop2 {
outpixel = *((WORD *)(Bitmap_in+loop2*2 + loop * Pitch)); //Load a word

outbyte = ((outpixel)&0x1f)<<3;
WriteBuffer [BufferIndex++] = outbyte;

//Load up the green component and output it

outbyte = ((outpixel>>5)&0x3f)<<2;
WriteBuffer [BufferIndex++] = outbyte;

//Load up the red component and output it
outbyte = ((outpixel>>11)&0x1f)<<3;
WriteBuffer [BufferIndex++] = outbyte;
}
}
Hmmm...still noticing more and more. Something I see is that it''s not as if the error occurs at the black directly, but simply on the first line that there is black. Also, i don''t think it''s true black (0, 0, 0) but just really close. Finally, if i have a dot of red or something in the black, everything after the color bars is tinted green. It seems like what''s happening is that in the color bars, some stuff is skipped. Perhaps the BYTEs I am getting for black are somehow going into the negative numbers...how would i protect against that? PLEASE HELP!! AAAAHHHHHHH
Advertisement
Just some random thoughts...

Is bitmap_in of type BYTE*?

Each row in the bitmap written to file must be padded to be a multiple of 4 bytes, At least if you use BMP file.

Have you tried to write the pixels to a 24 bitars bitmap instead of file and then viewing this bitmap on the screen? I know you stated that you blitted the pixels to screen but was it the pixels intended for the file or the input pixels?

Are you sure the input pixels are in the format RGB565? They could be in RGB555.

Otherwise your code looks right to me. I feel for you.

Edited by - Spellbound on 2/25/00 5:55:55 AM
I might be shooting in the dark here, but since you mentioned the near black pixel thing and the shifting... If you open the file in text (i.e. non-binary) mode, it translates carriage returns and line feeds (bytes with values 10 or 13) into CR/LF pairs, I think. This would add an extra byte to these places, and cause color shifts and skewing...

Edited by - Gefilus on 2/25/00 6:34:54 AM
You should always padd the scanline to DWORD...
Oh my god.....Gefilus...that was the problem!!! THAT WAS THE PROBLEM THE WHOLE TIME! THAT WAS...that was the PROBLEM?! I''ve been spending all this time pouring over my code when THAT is the problem?! AAAAGH! thanks dude, i''m gonna go flip out at some random person then come back and get to work. THANKS EVERYONE! THANK YOU ALL! THANKS!!!! YEEAH!
Advertisement
gah, here I come, all ready to save the day, and its already solved.

bah.

I had the same exact problem before, and it really made me crazy too, heh.

===============================================
I saw a man pursuing the horizon;
Round and round they sped. I was disturbed at this; I accosted the man.
"It is futile," I said, You can never -- "

"You lie," he cried, And ran on.
This is my signature. There are many like it, but this one is mine. My signature is my best friend. It is my life. I must master it as I must master my life. My signature, without me, is useless. Without my signature, I am useless.
the funny thing was, (it wasnt so much funny as it was mind numbing and it made me psychotic. just ask the people in the chat room... heh), I thought it was just an error in my writing code, somehow i wasnt converting it correctly, or something.

Anyway, i could only get the error to occur on large real-life bitmaps, not fake small ones (4x4, so i could easily debug), so I ended up memorising entire lines of bitmaps 100+ x 100+

that was a real waste of 2 weeks of my life.

===============================================
I saw a man pursuing the horizon;
Round and round they sped. I was disturbed at this; I accosted the man.
"It is futile," I said, You can never -- "

"You lie," he cried, And ran on.
This is my signature. There are many like it, but this one is mine. My signature is my best friend. It is my life. I must master it as I must master my life. My signature, without me, is useless. Without my signature, I am useless.
Yes, well I think everyone who is weary of this stuff has gone through his two weeks

This topic is closed to new replies.

Advertisement