Does anyone know how to convert a 24 bits rgb color value (e.g. RGB: 255, 153, 0) to a msx2 equivalent?

When I am right it is a 24 bits rgb to 9 bits rgb color conversion. I am looking for a formula.

Login or register to post comments

Does anyone know how to convert a 24 bits rgb color value (e.g. RGB: 255, 153, 0) to a msx2 equivalent?

When I am right it is a 24 bits rgb to 9 bits rgb color conversion. I am looking for a formula.

Login or register to post comments

MSX color component = 24bit color component / 32

wouldn't that be a division by 36.43?

That wat 255 would become 7.

No formula - you just drop (discard) the least significant bits that don't fit in the less-accurate end result.

Say for example you have a 24 bit value containing 8 bits that represent red, and you want to convert to an RGB value that has only 3 bits representing red. Then you take the 3 most significant bits (out of 8), and put 'em in that 3-bit space. The remaining 5 (less significant) bits you throw away.

Yes that means losing image quality, but that's the whole point of such a conversion: represent the same pixels using fewer bits. One could try various dithering and/or rounding methods to improve results (or perhaps an integer divide with a divisor other than a power of 2), but ultimately you will be discarding part of the image information.

Red / Green / Blue channels can be treated as independent, applying the same method to each. Or not. Again: whatever works, but one way or the other you'll be discarding those least significant bits.

wouldn't that be a division by 36.43?

That wat 255 would become 7.

No, that would practically leave all the bright colors away as 254 would be already 6 if we are talking about integers. If we start rounding floating points then the brightness problem is not that bad... but anyway... just divide with 32... (This is same as dropping out bits that MSX does not have.)

From 8-bit colour component values to 3-bit values: divide by 255, multiply by 7, and round the result. Other way around: divide by 7, multiply by 255, round the result.

The 7 colour component values: 0, 36, 73, 109, 146, 182, 219, 255

When drawing graphics for screen 5, I try to pick only colours with these component values.

If yes, that means values 0-6 each represent ~36 possible values in the original, while 7 represents only 1 value in the original. Probably NOT what you want...

If no (7 represents more values in the original), then you're back to just dropping bits (divide by a power of 2 like NYYRIKKI said) or rounding up/down. Dithering is a better method to preserve a little extra info from the original values.

From 8-bit colour component values to 3-bit values: divide by 255, multiply by 7, and round the result. Other way around: divide by 7, multiply by 255, round the result.

Why is this better than dropping the lowest 5 bits (/32)? Because in a 3-bit palette value 0 is fully off, 7 is fully on, and on a 8-bit palette value 0 is fully off and 255 is fully on. You can convert these to a scale from 0 to 1, by either dividing by 7 or dividing by 255.

Assuming all values are linearly distanced (disregarding things like gamma), you want to pick the 3-bit colour that is closest to the original 8-bit colour. For e.g. 8-bit value 224 (0.88), this should be 3-bit value 6 (0.85), not 7 (1.00). This is why you should divide, multiply and round, rather than just dropping bits with an integer division, as it minimises the error.

For this reason when you convert a 3-bit colour component to 24-bit, you also don’t want to pad the binary values with five 0’s, but rather nc = c << 5 + c << 2 + c >> 1 (integer logic) or nc = round(c / 7 * 255) (floating point logic).

There's probably a better solution : screen 8 with his 256 colors !

Why degrad the colors to fit in screen 5 or 7 ?

From the RuMSX help files :

Quote:

SCREEN 8

The color-value in screen 8 can be 0-255, the color is defined by the following formula:

color-number = 4 x R + 32 x G + B. The values for Red and Green can be 0-7, the values for Blue can be 0-3 (they correspond to 0, 2, 4 and 7).

This means that the bits are representing colors as following: G G G R R R B B.

For screen modes that use a palette, you can choose colors such that the overall results gets closest to the original.

For example if original has many colors that are very similar, and just a few colors that look very different, you could use a few palette colors for those different ones, and fill the rest of the palette with very similar-looking color values. Then for each RGB value pick the best matching palette entry.

Obviously choosing an optimal palette is a much more complicated job than applying the same simple math to each RGB value.

Become a member

Don't you have an account yet? Become an MSX-friend and register an account!

MSX Music player

Latest forum posts

- Konami's MSX Legacy part 1 almost ready
- SVI 738 RAM upgrade
- Graphically impressive z80 machine
- Floppy drive repair: Sony F1XV MSX2+
- Sprite collisions in the border?
- OPNA for MSX - Anyone working on one to market & interest?
- My 8bits4ever SX-1!
- Snake It
- VGMPlay for MSX
- Second version of Konami's Synthesizer?
- Are people here using the Radio App in SymbOS?
- Laydock 2 sucks!!
- ArkosTracker MSX playroutine, SDCC as-z80 syntax
- MSX Blaster by 8bits4ever, does anyone have any experience with this?

Right now on Ebay

News headlines

- 54th Barcelona MSX users meeting
- New York Kung-Fu 1987 - MSX2/2+ beat em up in development
- Columns enhancement patch
- MSX Fair Nijmegen 2019
- Metal Gear annotated disassembly published
- First batch of TSXDuino hardware available
- Submitted downloads for September 2018
- KimoHachi on sale
- Flashjacks firmware updated to Ver 1.4
- MSXVR got permission to use the MSX logo
- Feedback enhancement patch
- MSX turbo R game "Lost Word"
- OPL4 Shockwave 2 - New product pre-sale 2/2018

Trading & Collecting

- Graphic Tablet NMS 1150
- MSX2+ Panasonic on sale
- Big sale. Batch #1
- MSX PIONEER PALCOM +ER101+ TOSHIBA MSX COMPATIBLE+GAMES
- For sale: MSX turbo-R FS-A1GT
- Philips MSX kleuren monitor VS0080/00
- Sony HB-900 met 1 mb en turbo te koop
- WTB : Playsoniq and/or Yamaha SFG-01/05 (YM2151) OPM cartridges
- Looking for MSX PHILIPS VG-8020 keys
- Pac-man

© 1996-2018 Microcomputer & Related Culture Foundation. MSX is a trademark of MSX Licensing Corporation.
Terms and conditions | Privacy policy | Contact us