Pixmap/ReadPixel Problem

BlitzMax Forums/BlitzMax Beginners Area/Pixmap/ReadPixel Problem

Corporate Dog(Posted 2007) [#1]
I'm trying to write some code which loads a pixmap (from a PNG file), loops through the pixels, and replaces all the pixels of a particular color with a different color.

The problem, unfortunately, is occurring even before I get to the part where I change the pixel color. At every step of my loop, the pixel color being returned by ReadPixel is black (RGB #000000), even though there are pixels with other colors in them (the pixel at 181,21 is actually red, for instance).

Any idea why I'd see this kind of behavior? I've included the relevant code (and the image) below.

Thanks,
Corporate Dog

Graphics 640, 480, 32

Global myPixmap:TPixmap = LoadPixmapPNG("C:\testFireBrand.png")

For y = 0 To 367
 For x = 0 To 363

  p = ReadPixel (myPixmap, x, y)
  If (x = 181 And y = 21) Then Notify p

  ...

  Next
Next






Corporate Dog(Posted 2007) [#2]
Grah. Don't you hate it when you struggle with something for a few days, and then no sooner than you post a help request, the problem resolves itself?

Apparently, my problem was twofold:

A.) I was somehow misinterpreting the number being returned by ReadPixel.

B.) The code I stole to convert to decimal RGB values wasn't using the bitwise And operator.

Regards,
Corporate Dog


Perturbatio(Posted 2007) [#3]
I often find myself talking to a colleague about a programming problem, only to realise the solution just after speaking to them.