PDA

View Full Version : QPainter, QImage and transparency color with *.jpg file



moijhd
25th July 2013, 11:04
Hi,

I render a widget (it actually is a QwtPlot rendered through a QwtPlotRenderer but I don't think this is the issue here) to a PDF file using a QPrinter.

I now want to write a JPG file. I replace the QPrinter by a QImage (Format_ARGB32_Premultiplied).

In my *.jpg file the transparency is black and I want it to be white (like it is in the PDF file).

Thanks.

PS0 : it works fine with PNG (of course)
PS1 : I know that JPG does not support transparency, I want to change the color of the transparency it uses instead.

wysota
25th July 2013, 11:06
I want to change the color of the transparency it uses instead.

JPG doesn't store any information on transparency thus you need to change the original image to display those areas as white instead of black. Other than that you can try using QImage::createHeuristicMask() or QImage::createMaskFromColor() but this might not work as you expect it.