Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Color Extraction Developer Insights
#11
Seeing what you're doing now, let me draw your attention to: https://qb64phoenix.com/forum/showthread.php?tid=1360
Reply
#12
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. Wink
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  find color of a pixel PhilOfPerth 8 740 10-09-2025, 05:20 PM
Last Post: SMcNeill
  palette color help pmackay 7 974 07-13-2025, 11:51 PM
Last Post: madscijr
  Trasparent color not being set correctly here... Dav 9 1,520 11-10-2024, 04:11 AM
Last Post: bplus
  Who is the ISE developer/maintainer? desA 3 997 08-02-2024, 03:23 AM
Last Post: grymmjack
  Error displaying 256 color PCX image program? macalwen 8 1,628 07-05-2024, 01:39 PM
Last Post: SMcNeill

Forum Jump:


Users browsing this thread: