Please nominate your Qt Champions for 2021! https://forum.qt.io/topic/132134/looking-for-the-2021-qt-champions
[Solved] BMP palettes
Is there an opportunity to make an 8-bit BMP color palette with QT?(inbuilt function or method)
With QImage that uses format Format_Indexed8 you can set the size of palette with "setColorCount":http://qt-project.org/doc/qt-5/qimage.html#setColorCount and then each palette element with "setColor":http://qt-project.org/doc/qt-5/qimage.html#setColor. You can then save the image in one of supported formats (including BMP) with "save":http://qt-project.org/doc/qt-5/qimage.html#save
Thank you for your answer. But my question was not unambiguous. I want to write an 8-bit bmp header and i don't want to set all the 256 value one by one.
I am looking for an easier and faster solution.
Qt generalizes image manipulation and doesn't provide access to specific parts of structures in specific file formats.They are just end points in the import/export.
If you want direct access to theses bits and pieces you'll have to do it yourself or use another library. Fortunately BMP format is one of the simpler ones so it shouldn't be much trouble.
.NET has a structure: RGBTRIPLE
But how can i do this in QT?
quote author="Spike89" date="1402213812" and i don't want to set all the 256 value one by one. I am looking for an easier and faster solution.[/quote]
But your example .net code does just that - sets colors one by one.
Maybe we should rewind. What do you actually want to do with that? It looks like just a grayscale palette.
The RGBTRIPLE seems to be a 24bit struct with 8 bits per channel. Qt uses 32bit color QColor class (8 bit for red, green, blue and alpha).
What format do you need it in? Do you want to use it with Qt classes (like QImage, QPixmap) or with something else? Or maybe you just want a grayscale image?