#6 √ resolved
John Croisant

Surface#get_at doesn't work with 8 bit PNGs

Reported by John Croisant | June 18th, 2008 @ 01:20 AM | in 2.4 (Event)

Originally reported by: Aureliano Calvo - aurelianito

-----

The get_at method in the surface method is not working correctly on 8bits png.

For instance, using the attached file,

image = Rubygame::Surface.load_image("eye_8bits.png")
image.get_at(0,0)

returns [0, 0, 0, 0] # black

instead of [255, 0, 0, 255] # red

Comments and changes to this ticket

  • Trickster

    Trickster June 18th, 2008 @ 08:06 PM

    Actually this is supposed to happen

    that image loads as an 8bit surface and any operation that takes a color on an 8 bit surface takes in a integer representing the palette entry.

    surf = Rubygame::Surface.load('eye_8bits.png')

    p surf.depth #=> 8

    p surf.get_at(0, 0) #=> [0, 0, 0, 0] aka first entry in the surface's palette

    p surf.palette[0..2] #=> should be [255, 0, 0]

    Just trying to help ;)

  • John Croisant

    John Croisant August 16th, 2008 @ 05:00 PM

    • → Milestone changed from “Surface & Rect” to “2.4 (Event)”
    • → Tag changed from “” to “@bug color surface”
    • → State changed from “new” to “resolved”

    @Trickster: Actually, this is not supposed to happen, because the defined behavior of Surface#get_at says that it returns the RGB values of the pixel. It doesn't say "... unless it's an 8-bit Surface". ;-)

    The problem was a stupid if-statement that I wrote that shouldn't have been there.

    Anyway: this issue is fixed in the master branch and will be rolled out with Rubygame 2.4.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Flexible library for making games with the Ruby language.

rubygame.sourceforge.net

Shared Ticket Bins

People watching this ticket

Attachments

You can update this ticket by sending an email to from your email client. (help)