Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Get Color Index (256 color)  (Read 1459 times)

0 Members and 1 Guest are viewing this topic.

gamecreator

  • Newbie
  • *
  • Posts: 17
    • View Profile
Get Color Index (256 color)
« on: December 03, 2017, 02:29:13 am »
I've been looking through the Image Class Reference and it seems like SFML can't do this but I just want to confirm.  I'm drawing a tile map out in a graphics program where each pixel represents a tile.  I was hoping to read the image into SFML and have it tell me which color index each pixel is (from 0 to 255) so I can draw the proper tile based on that.  However, while I can get the RGBA values, I can't find where I could get the pixel color index.  Is this possible with SFML?  If so, how can I do this?  I have no problem with writing a converter or something but just checking here first.  Thanks for any help.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10901
    • View Profile
    • development blog
    • Email
Re: Get Color Index (256 color)
« Reply #1 on: December 03, 2017, 07:50:49 am »
SFML doesn't provide access to the color palette. You could just use the pixel position on the image though.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Get Color Index (256 color)
« Reply #2 on: December 03, 2017, 08:16:19 am »
To be a little clearer, after SFML loads an image, all you get is an array of RGBA values (and a size), so any extra information such as the original palette is definitely lost.
Laurent Gomila - SFML developer

gamecreator

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: Get Color Index (256 color)
« Reply #3 on: December 03, 2017, 10:02:55 am »
Thank you both.

 

anything