Printing a QImage has color distortion
-
Hi
Only something like this
http://stackoverflow.com/questions/27949569/convert-a-qimage-to-grayscale
https://www.programmingalgorithms.com/algorithm/rgb-to-cmyk?lang=C%2B%2B
QColor also has CMYK support. -
Hello again,
I did figure that QColor supported CMYK, but I am unsure as to how I should put it all together back in the image. Once I get a QColor object from the QColor::toCMYK() call, the only way I can replace the pixel inside the QImage is through QColor::rgba, which returns actual RGBA values. However, I now remember that I had not opened the file explicitly in RGBA format at the time. I will attempt this again and see what I can come up with.
I'll keep you updated.
Thanks,
BasiC
-
Hi back,
I tried something like this :
studentPicture.convertToFormat(QImage::Format_RGBA8888); for(int j = 0; j < studentPicture.height(); j++) { for(int i = 0; i < studentPicture.width(); i++) { int c = 0, m = 0, y = 0, k = 0; QColor oldColor = studentPicture.pixel(i, j); oldColor = oldColor.toCmyk(); oldColor.getCmyk(&c, &m, &y, &k); QColor newColor(c, m , y, k); studentPicture.setPixel(i, j, newColor.rgba()); } }
However, the result doesn't look promising at all... Do you have any more pointer for me ?
Thanks,
BasiC
-
Hi wb
Does look like I would expect.
But you still have massive color
I wonder if .setPixel(i, j, newColor.rgba() << will that convert back to RGB? );http://doc.qt.io/qt-5/qimage.html#setPixelColor-1
It seems to accept a QColor directly so maybe it can get rid of the .rgb() ?Sadly I have not tested this with Cmyk - only greyscale and other manipulations so
im not sure why its not working.Also, i would install ImageMagick and make a Cmyk version and print it. just be sure it will work and
you have a Cmyk version to compare with.
Since Scribus can print nicely I assume 99.9% its due to Qt sending image as RGB. -
Good morning,
Removing .rgba() doesn't compile. I need to head to work, but I'll try printing with a CMYK converted image too as soon as I can.
Thanks,
BasiC
-
Hi,
I tried printing the CMYK output and it still looked bad, but I'm guessing Qt might be converting it to rgb when it loads it ?
Thanks
-
@BasiC
Yes, i would assume it does.
Im not sure how to bypass that.After removing rgb() did you use
http://doc.qt.io/qt-5/qimage.html#setPixelColor-1
Note its not setPixel, but set PixelColor and it accpet a "pure" color? -
@mrjj
You caught me off guard with the added Color in method name. I'll try it out as soon as I get a minute. -
Tried the code. I only exported to PDF for testing purposes and I believe it wouldn't print properly...
By the way, this looks a little like when I was using .rgba().
-
@BasiC
Well its pretty hard to look at CMYK images on RGB monitor and know if they be all right :)
PDF might convert to RGB as in adobe its default . Dont know if Qt export is.
You could ask Adobe Reader to save as cmyk to be sure. ( if you have it)Maybe its not possible to do in Qt directly as setPixelColor does accept Color CMYK version
so it should have worked. Also the images you load are JPGS ? (png not good for cmyk i read)I think it still get convert to RGB or something. that all other pixel manipulation works.
Maybe its needed to construct raw buffer and handle all loading and saving by own code.Also if you did install imagemagick
try
convert image-rgb.jpg -colorspace CMYK image-cmyk.jpg
and print from windows -
Thanks for the reply. I'm in a little rush currently. Hopefully I can test your pointers out pretty soon.