Qimage Indexed8

Posted on

I'm trying to create QImage that wrap a existing image buffer that is created by OpenCv I was considering use following constructor to do this. @QImage::QImage ( const uchar. data, int width, int height, int bytesPerLine, Format format )@ so, my code is like @ QImage qimage((const uchar.)iplImage-imageData, iplImage-width, iplImage-height, iplImage-widthStep, QImage::FormatIndexed); // qimage's buffer is now just pointing the 'iplImage-imageData' // without allocating and copying buffer. Qimage.setColorTable(grayScaleColorTable); // color table's item count 256 for grayscale. // now new image buffer is allocated and copied from original here. @ Ok, no memory copy actually was done at the time of calling this ctor. But, here comes my problem.

  1. See More On Stackoverflow
  2. Give More Feedback

QImage::setColorTables is non const member function where QImage allocates new image buffer for copying by its internal detach function. I found there was Qt3 support for this kind of problem where ctor could accept color table as argument in its ctor, but I've not found any such support in Qt4. How can I create gray scale QImage for existing image buffer?

Indexed8

See More On Stackoverflow

Thanks for in advance.

Give More Feedback

Warning: Painting on a QImage with the format QImage::Format_Indexed8 is not supported. Reading and Writing Image Files QImage provides several ways of loading an image file: The file can be loaded when constructing the QImage object, or by using the load() or loadFromData() functions later on.

QImage objects can be passed around by value since the QImage class uses implicit data sharing. QImage objects can also be streamed and compared. Note: If you would like to load QImage objects in a static build of Qt, refer to the Plugin HowTo. Warning: Painting on a QImage with the format QImage.Format_Indexed8 is not supported. If I create a QImage using QImage::Format_Indexed8 and then specify a grayscale color table, I can use the pixelIndex() method to retrieve certain pixel values.