![]() |
#3
|
|||
|
|||
Checking the settings of the graphics card was the first thing
I checked. Unless I missed something, it's 32 bits. I also tried a JPEG that I created in Photoshop -- an RGB image that "just happened" to have R == G == B for all pixels --- and it displayed a full range of greys. I looked very closely at the screen, just to see if it were dithering 16 grays to create the illusion of ~256 grays, and I don't believe it was. I'll probably try creating the image as a true grayscale as an experiment later, just to see if the result changes. I didn't do so originally because I wanted the flexibility of being able to write a colored image, even if the image was currently greyscale. In particular, I might want to have a key that adds some colored dots or squares at key points on the mage. (Basically, the plugin enables you to dynamically update the texture from a Python string containing a grayscale or RGBA image in SGI format. Here's the code that creates the image: void InitImageGen(void *imagegen) { VizImageGenObj *self = reinterpret_cast<VizImageGenObj*>(imagegen); strcpy(self->version, "strtexture v1.0"); self->user[0] = 0; self->dataSize = 0; int imageWidth = nearbyPowerOf2(self->x); int imageHeight = nearbyPowerOf2(self->y); if (imageWidth <= 0 || imageHeight <= 0) { imageWidth = 256; imageHeight = 256; } osg::Image *image = new osg::Image; image->setImage(imageWidth, imageHeight, 1, 4, GL_RGBA, GL_UNSIGNED_BYTE, new uchar[imageWidth * imageHeight * 4], osg::Image::USE_NEW_DELETE); clearImage(image); self->image = image; self->texture = new osg::Texture2D(image); CommandImageGen(self); self->status = 1; } And here's the shortest routine I use to write fill the image: void clearImage(osg::Image *image, uchar red = 0, uchar green = 0, uchar blue = 0, uchar alpha = 255) { for (int ii = 0; ii < image->s(); ii++) { for(int jj = 0; jj < image->t(); jj++) { uchar *pixel = image->data(ii, jj); pixel[0] = red; pixel[1] = green; pixel[2] = blue; pixel[3] = alpha; } } image->dirty(); }
__________________
-- Dan Merget |
Thread Tools | |
Display Modes | Rate This Thread |
|
|