Author Topic: RGB565 to 24 bit  (Read 1394 times)

0 Members and 1 Guest are viewing this topic.

Offline @rtTopic starter

  • Super Contributor
  • ***
  • Posts: 1071
RGB565 to 24 bit
« on: February 05, 2019, 10:59:22 am »
Hi Guys :)
I have some source RGB565 images converted to display on 24 bit platforms which look ok:
https://imgur.com/a/WlmNaVu

But it occurs to me I’m not quite correct. For Red & Blue channels the maximum value is 31, and for Green, 63.
None of these values are evenly divisible by 255, so I’ve just multiplied R&B by 8, and green by 4.
The maximum values for this scheme (as in the photo linked above) would then be 248 for Red & Blue, and 252 for Green.

Without floating point math (which would be easy), how are you supposed to do this conversion?
Images looks ok, but I suspect I’m leaving something out because a plain white image would be slightly green, etc.
Cheers.
 

Offline oPossum

  • Super Contributor
  • ***
  • Posts: 1447
  • Country: us
  • Very dangerous - may attack at any time
Re: RGB565 to 24 bit
« Reply #1 on: February 05, 2019, 11:27:05 am »
Use fixed point.

RB: n * 2114 >> 8
G:  n * 1040 >> 8
 

Offline @rtTopic starter

  • Super Contributor
  • ***
  • Posts: 1071
Re: RGB565 to 24 bit
« Reply #2 on: February 05, 2019, 12:49:14 pm »
Very nice, thanks :)
 

Offline DJohn

  • Regular Contributor
  • *
  • Posts: 103
  • Country: gb
Re: RGB565 to 24 bit
« Reply #3 on: February 05, 2019, 02:57:58 pm »
You don't even need to multiply.  Just repeat the bits that you've got until the target is full.  So 5 bit abcde becomes 8 bit abcdeabc.  In software that takes enough masking and shifting that (on a processor with a fast multiply) it might not be worth it.  In hardware it's trivial.
 

Offline @rtTopic starter

  • Super Contributor
  • ***
  • Posts: 1071
Re: RGB565 to 24 bit
« Reply #4 on: February 05, 2019, 03:51:18 pm »
I have a timer set up already, and could time the routine, but it’s a Windows supercomputer, and doesn’t matter for static images.

I can’t tell the difference at all, even side by side, but the peace of mind is priceless.
https://imgur.com/a/TdeWi4p
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf