Hi folks !
I was reading the manual about PNMImage ( Creating New Textures from Scratch — Panda3D Manual ) and I found some minor mistakes :
The third paragraph says:
You can get individual RGB values using the
getRed(x,y), getGreen(x,y), getBlue(x,y)
orgetRedVal(x,y), getGreenVal(x,y), getBlueVal(x,y)
where x and y tell what pixel to look at (lower-left is 0,0 upper right isgetXSize()-1, getYSize()-1
The difference between these functions is that theget*Val
functions return a number between 0 and 1 while theget*
functions return their value as an integer. For example, if your image uses 8-bit color callinggetGreenVal
on a green pixel will return 255 and callinggetGreen
will return 1. You can also get all the RGB information at the same time usinggetXel(x,y)
andgetXelVal(x,y)
which return a 3-component vector with red in the x, green in the y, and blue in the z.
there is a little mix up in the method, for a black Xel : myImage.get* will return 1.0 where myImage.get*Val will return 255.
Also in the fourth exemple of the page :
Both of these set the origin to gray
myImage.setXelVal(0, 0, gray * 255)
myImage.setXel(0, 0, gray)
But for it to work you have to do it the other way :
Both of these set the origin to gray
myImage.setXelVal(0, 0, gray)
myImage.setXel(0, 0, gray *255)
It’s not a big deal, but I guess you would like to kow
Cheers !