Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Converting 24-Bit images to Paletted Images (2-colors to 256-colors)
#3
Tongue 
(11-22-2025, 07:27 AM)SMcNeill Wrote: You need to catch up with QB64PE's capabilities.  Here's  all it takes  to  toggle from 32-bit to  256 colors:


Code: (Select All)
Screen _NewImage(800, 600, 32)
nature = _LoadImage("nature.jpg", 32)
nature256 = _LoadImage("nature.jpg", 256)
nature256a = _LoadImage("nature.jpg", 257)

Do
    Cls , 0
    k = _KeyHit
    Select Case k
        Case 27: System 'escape to end
        Case 19712, 18432: Color32 = Color32 + 1 'right/up
        Case 19200, 20480: Color32 = Color32 - 1 'left/down
    End Select
    If Color32 < 0 Then Color32 = 2
    If Color32 > 2 Then Color32 = 0
    Select Case Color32
        Case 0: _PutImage , nature: Print "32-bit"
        Case 1: _PutImage , nature256: Print "256-color QB64 set  palette"
        Case 2: _PutImage , nature256a: Print "256-color adaptive palette"
    End Select
    _Limit 30
    _Display
Loop

Save image below as "nature.jpg".

    Steve, this is a great capability in the language libraries.
    It's very convenient for games and also for prototyping
    more advanced Image processing !

    There are still reasons to roll your own code here.

    I get much better 8 bit images by allowing ImageMagick to do the palette mapping and dithering and then setting 
    The 8 bit image palette with _palettecolor.  for the Image Handle.

    The QB64 set color palette actually kinda sucks  Smile
Reply


Messages In This Thread
RE: Converting 24-Bit images to Paletted Images (2-colors to 256-colors) - by ahenry3068 - 11-22-2025, 09:17 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Bright Circle Colors SierraKen 4 639 08-23-2025, 03:33 PM
Last Post: DANILIN
  A little bit of spark fun today TerryRitchie 2 853 05-18-2024, 12:59 AM
Last Post: bobalooie
  _ROL & _ROR A quickie bit of crypto OldMoses 0 537 09-05-2022, 09:36 PM
Last Post: OldMoses
  Load Image 256 Petr 1 765 05-22-2022, 06:19 PM
Last Post: Dav
Video QB64 Win32 Video Player (64 bit) SpriggsySpriggs 6 1,565 04-24-2022, 05:33 PM
Last Post: Dav

Forum Jump:


Users browsing this thread: 1 Guest(s)