c - How to convert an 256 color to the closest matching RGB color? -


i upgrading svga-driven gui software qt-driven one. 1 of problems color conversion. svga uses 256 color model, , qt uses rgb color model(actually supports other models too; using rgb).hence need linear mapping of 256 color equivalent rgb color.

is there formula ?

note:i using c/c++ build language.

you need work out palette being used. should encoded in application. palette array of 256 rgb values. use colour use array index (a single byte). once have palette information, have linear mapping you're after.

there default palette in vga modes. programs set own, either way palette information resides on graphics card. should able query it, can't that. last time wrote code 15 years ago when knew memory addresses write various graphics operations.

another way find out palette: if able modify application write bunch of pixels, draw 16x16 block containing 256 colour values, screenshot , recover palette that.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -