01-28-2024, 08:45 PM
Seeing what you're doing now, let me draw your attention to: https://qb64phoenix.com/forum/showthread.php?tid=1360
Color Extraction Developer Insights
|
01-28-2024, 08:45 PM
Seeing what you're doing now, let me draw your attention to: https://qb64phoenix.com/forum/showthread.php?tid=1360
01-28-2024, 09:05 PM
To break down how I did this:
temp = _NewImage(_Width(image), _Height(image), 256) _Dest temp: For i = 0 To 255: _PaletteColor i, _RGB32(i): Next: _Dest d The above creates a 256 color screen for us, and sets to to be 256 color grayscale. r = _MemGet(m(0), o(0) + 1, _Unsigned _Byte): g = _MemGet(m(0), o(0) + 2, _Unsigned _Byte): b = _MemGet(m(0), o(0) + 3, _Unsigned _Byte) Then I read the RGB values. (Alpha shouldn't be needed here, as 256 color images don't carry an alpha channel usually, so I'm assuming they're all full alpha.) _MemPut m(1), o(1), _RGB(r, g, b, temp) As _UNSIGNED _BYTE And then I use the native _RGB command to match the closest color in my grayscale palette to the 32-bit color value, and I put that value to the new grayscale image. And using this trick, I can set up my 256-color screen to use *any* palette that I want to match with as closely as possible. (In fact, I could use this method to dither from 32-bit images to 256-color images, if I wanted to.) With just a tweak of the palette, I can create Red-Scale, Blue-Scale, Green-Scale images, as you see easily in the demo if you follow the link. |
« Next Oldest | Next Newest »
|