Best way to convert 24bit to 16bit

Started by
15 comments, last by VisualLR 24 years, 4 months ago
Put up a copy of the original image somewhere i can d/l it please (and dont make it a jpg).

Josh

Advertisement
Splat,

Sorry, to ask this again, but you say, in you example, the 24-bit color red component
is 187 and the 16-bit color red component is 23 for the first pixel. So the error
value is 3? Why isn't it 23-187 = -164? Don't you want the negative decimal difference
between the two?

I understand how this error number is divided up and distributed to its neighbors,
but I don't completely understand how it is calculated, and what happens at the very end
of the first row and the start of the second row.

Last time I checked, the FAQs here didn't cover 24-bit to 16-bit or RGB color.
Just B/W and 8-bit.

Vader

Ok, I uploaded the 24bit BMP, you can get it HERE

This is just a test BMP I made so I could see if it did it with every BMP I feed it, and it does... Ive checked the code over and over and still no clue...

later!

------------------
Luis Sempe
visuallr@netscape.net
http://www.geocities.com/SiliconValley/6276

omg why didnt i notice this like along time ago... why are you guys adding color components you have to OR them

#define RGB16BIT(r,g,b) ((b >> 3) | ((g >> 2) << 5) | ((r >> 3) << 11))

Josh

same thing if you know the bits don't overlap, which they don't in this case.
Hi,

I was wondering what the best way to convert a 24bit value to 16bits would be, currently Im using this:

#define RGB16BIT(r,g,b)
((b%32) + ((g%32) << 5) + ((r%32) << 10))

but I usually get an odd pixel somewhere in the bitmap, so I was wondering if there was a better way to do this.

Thanks!

------------------
Luis Sempe
visuallr@netscape.net
http://www.geocities.com/SiliconValley/6276

What's the index of the pixel that bugs you?

Could be something as simple as a loop that never makes a full round.

Since you are not using dithering, there is no way you can get color bleeding for just one pixel, so you are right to look for the bug elsewhere.

/Niels

<b>/NJ</b>

This topic is closed to new replies.

Advertisement