Textures, on the fly and in color indexed mode [SOLVED]

Greetings everyone,
I have two questions regarding texture maps:

first, I want to see if it is possible to have a texture map where the image is not loaded from the disk, but presented in an array. I know I can use the operator[] in an PNMImage to get the data as a byte array, but has anyone used it for setting the data?

My next question is to see if it is possible to have the texture map in a color indexed mode, where the pixel is presented as a byte value of 0-255 and then a color palette shows the RGBA value for each corresponding byte value. this means that there are only 255 values but it is very useful to use a Window/Level technique to hide/show details in complex images.

Thank you for your help,

Hi and welcome to Panda3D,

  1. if not loaded from disk, where from then? if you mean embedding graphics in code, that’s possible but pretty pointless.

  2. the indexing should happen outside of panda, in your graphics editor. if you need to modify the images on the fly, i suggest PIL.

Have a nice day

Thank you for your reply. No, I don’t mean embedding in code. My problem stems from the fact that I am trying to show DICOM medical images in Panda 3d (Don’t ask me why, it’s a long story)

Since these images have their own format, I need to create my own file reader which will parse the file and come up with for example as byte array of 131072 bytes representing a 256x256 matrix of 16-bit values.

I then need to give the user the ability to select a range of these values to see, and the user needs this to be available in real time so that they can play with the parameters until they find the correct values.

In OpenGL, I would set this array as the texture map for the corresponding plane and then use a color indexed mode to show it on the screen, so naturally I was looking to see if that is possible here.


Well, for people who might have the same problem that I had, I have pasted the solution in the code snippet forum :
discourse.panda3d.org/viewtopic … 2138#52138

all that was needed was to setup2dtexture and then get the buffer using makerawbuffer.