Martin, This code below seems to work well:
... checking if the band is a paletted one ... else if (bandPalette) { // Paletted map int pixelSpace=1*numBytesPerPixel; int lineSpace=destWidth * pixelSpace; unsigned char *rawImageData; rawImageData = new unsigned char[destWidth * destHeight * pixelSpace]; imageData = new unsigned char[destWidth * destHeight * 3/*RGBA*/]; pixelFormat = GL_RGBA; internalFormat = GL_RGBA; bandPalette->RasterIO(GF_Read,windowX,windowY,windowWidth,windowHeight,(void*) (rawImageData),destWidth,destHeight,targetGDALType,pixelSpace,lineSpace); for (int i = 0; i < destWidth * destHeight; i++) { const GDALColorEntry *colorEntry = bandPalette->GetColorTable()->GetColorEntry(rawImageData[i]); GDALPaletteInterp interp = bandPalette->GetColorTable()->GetPaletteInterpretation(); if (!colorEntry) { ... } else { if (interp == GPI_RGB) { imageData[3*i+0] = colorEntry->c3; imageData[3*i+1] = colorEntry->c2; imageData[3*i+2] = colorEntry->c1; // imageData[3*i+3] = colorEntry->c4; } } } delete [] rawImageData; } else { } void * ptr_dest = NULL; void * ptr_src = NULL; if (imageData) { BITMAPINFOHEADER bih; int size = sizeof(BITMAPINFOHEADER) ; memset(&bih, 0, size); bih.biSize = size; bih.biWidth = ((((int) destWidth * 8) + 31) & ~31) >> 3; bih.biHeight = destHeight * -1; bih.biPlanes = 1; bih.biBitCount = 24; bih.biCompression = BI_RGB; pdc = new CDC ; pdc->CreateCompatibleDC(NULL); hbmp = CreateDIBSection( pdc->GetSafeHdc(),(BITMAPINFO*)&bih, DIB_PAL_COLORS,//DIB_RGB_COLORS, &ptr_dest , NULL, 0); unsigned int dibwidth = m_bih.biWidth; GByte* src = (GByte*) imageData; for (int row = 0; row < destHeight; row++) { ptr_dest = dest + row * dibwidth* 3; ptr_src = src + row * destWidth *3; memcpy(ptr_dest, ptr_src, destWidth* 3); } } Your code is similar, though i haven't checked the GetColorEntryAsRGB function yet Best Regards -- View this message in context: http://osgeo-org.1803224.n2.nabble.com/gdal-dev-Problem-w-images-with-one-raster-band-tp7175398p7183703.html Sent from the GDAL - Dev mailing list archive at Nabble.com. _______________________________________________ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev