Need some help with colorspaces

Dmitry Kazakov dimula73 at gmail.com
Mon Aug 3 22:27:52 CEST 2009


Hi, all!
I have a strange problem with colorspaces, could someone help me?

The problem is:
I'm writing KisImagePyramid class, that is used by
KisPrescaledProjection. This class caches KisImage's projection in a
usual KisPaintDevice, BUT created for monitor's color space.
I create this color space as follows:
m_monitorColorSpace = KoColorSpaceRegistry::instance()->rgb8(m_monitorProfile);

where @monitorProfile is a profile given by KisPrescaledProjection

Then i create a paint device:
KisPaintDeviceSP pd = new KisPaintDevice(m_monitorColorSpace);

and try to copy entire image on it:
    KisPainter gc(pd);
    gc.bitBlt(rc.topLeft(), originalProjection, rc);
    gc.end();

    QImage temp = pd->convertToQImage(m_monitorProfile,
				      0, 0,
				      m_originalImage->width(),
				      m_originalImage->height());
    temp.save("/home/dima/UNSCALED_FULL.png");

where m_originalImage and originalProjection are KisImageSP and it's
projection respectively.

As a result i get an image with artefacts along right side of it:
http://img18.imageshack.us/img18/4338/unscaledfull.png

Original image is here:
http://img514.imageshack.us/img514/1849/simples.png

In the beginning i thought this is some overflow in
KisPainter::bitBlt, BUT when i changed destination paint device
colorspace to source colorspace, everything started to work perfectly!
KisPaintDeviceSP pd = new KisPaintDevice(originalProjection->colorSpace());
I got a copy of original image in "/home/dima/UNSCALED_FULL.png"

I can't understand why?! What do i do wrong?


PS:
the code together:

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// This code doesn't work
m_monitorColorSpace = KoColorSpaceRegistry::instance()->rgb8(m_monitorProfile);

KisPaintDeviceSP pd = new KisPaintDevice(m_monitorColorSpace);

KisPainter gc(pd);
gc.bitBlt(rc.topLeft(), originalProjection, rc);
gc.end();

QImage temp = pd->convertToQImage(m_monitorProfile,
  				      0, 0,
				      m_originalImage->width(),
				      m_originalImage->height());
temp.save("/home/dima/UNSCALED_FULL.png");

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// This code works
m_monitorColorSpace = KoColorSpaceRegistry::instance()->rgb8(m_monitorProfile);

KisPaintDeviceSP pd = new KisPaintDevice(originalProjection->colorSpace());
// the change is here
----------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

KisPainter gc(pd);
gc.bitBlt(rc.topLeft(), originalProjection, rc);
gc.end();

QImage temp = pd->convertToQImage(m_monitorProfile,
  				      0, 0,
				      m_originalImage->width(),
				      m_originalImage->height());
temp.save("/home/dima/UNSCALED_FULL.png");


-- 
Dmitry Kazakov


More information about the kimageshop mailing list