View Full Version : How to load image with color index array
12-28-2009, 08:44 PM
I want to display an image which may have an index of color codes, and then each pixel may have one byte to represent the colour (i know there will be only 255 possible colors this way).
So is there a way to load such an image using OpenGL.
12-28-2009, 11:59 PM
If you're able to use shaders, then this should be trivial. Otherwise, no.
12-29-2009, 11:51 AM
If you don't have shaders, you can either:
* use a paletted internal format (EXT_paletted_texture, not supported on modern hardware) or
* have GL depalettize the image on upload. See documentation on GL_COLOR_INDEX, glPixelMap, and glPixelTransfer.
12-29-2009, 10:46 PM
I'm posting this message in 'begginers'as i'm new to openGL so i expect some straight answers:
Basically i've data about RGBA values of each pixel that means each pixel takes 4bytes and if i have 4096x4096 pixels then it comes out to be 64MB. I know that i've no more than 60 color values in the image. so want to make an index of 60 color values. then use this index as one byte value of each pixel.
I really need to reduce the memory requirement.
12-30-2009, 03:58 AM
What is your maximum texture size ? 4096*4096 is quite a lot.
Check it on your hardware with :
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value); //Returns 1 value
Then if your aim is to save texture memory on modern hardware, indeed you will have to roll out you own fragment shader, as the above posters suggested.
This is a bit involved, but we can help.
I suggest reading first this tutorial, so that you have enough background :
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.