Qt - Cannot export QImage to 16bit bmp -


i have created simple application , need export pixmap 16-bit bmp image. have several pixmap items have loop first create qimage , convert format_rgb16:

    for(qlist<image_handler * >::iterator it=imageitems->begin(); it!=imageitems->end(); it++)     {         ...         // image_handler inherits qpixmap         qfile export_image(path+"/img_"+code+".bmp");          qimage export_img = (*it)->toimage().converttoformat(qimage::format_rgb16);         export_img.save(&export_image, "bmp");         ...     } 

where image_handler custom qpixmap. images exported @ path given, correct filename. when @ properties of file (in windows) can see image depth 24-bit. unfortunately need them 16-bit.

what doing wrong here? or bug in qt? how can export 16-bit bmps pixmap?

turns out, qt forcibly converts image, before saving bmp.

qt-src/src/gui/image/qbmphandler.cpp:777:

bool qbmphandler::write(const qimage &img) {     qimage image;     switch (img.format()) {     case qimage::format_argb8565_premultiplied:     case qimage::format_argb8555_premultiplied:     case qimage::format_argb6666_premultiplied:     case qimage::format_argb4444_premultiplied:         image = img.converttoformat(qimage::format_argb32);         break;     case qimage::format_rgb16:     case qimage::format_rgb888:     case qimage::format_rgb666:     case qimage::format_rgb555:     case qimage::format_rgb444:         image = img.converttoformat(qimage::format_rgb32);         break;     default:         image = img;     }     ... 

so, if need save bmp 16bit, you'll have manually, filling header , using qimage::bits() , qimage::bytecount().


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -