<br><br><div class="gmail_quote">On Sun, Apr 24, 2011 at 1:53 AM, JL VT <span dir="ltr"><<a href="mailto:pentalis@gmail.com">pentalis@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div>After reading a post in the Krita forums asking for Impasto, I took a look at the Phong Bumpmap filter with the intent to fix it.</div><div><br></div><div>The filter generates a QImage called "bumpmap", this contains the result of the process() method.</div>
<div><br></div><div>Currently, the filter simply uses this QImage:</div><div><font face="'courier new', monospace"> device->convertFromQImage(bumpmap, "", applyRect.topLeft().x(), applyRect.topLeft().y());</font></div>
<div><br></div><div>This will only work if "device" is an RGB 8 color space (or maybe in other cases I'm not aware of).</div><div><br></div><div>I've been _trying_ to fix this behavior by storing the information contained in the QImage in an intermediary RGB 8 KisPaintDevice, and then turning this to the colorspace of the target KisPaintDevice...</div>
<div><br></div><div>...but my attempts have not succeeded, this is an example of what I did to replace the former line of code:</div><div><font face="'courier new', monospace"> KisPaintDeviceSP quickHack = new KisPaintDevice(KoColorSpaceRegistry::instance()->rgb8());</font></div>
<div><span style="font-family: 'courier new',monospace;"> quickHack->convertFromQImage(bumpmap, "");</span></div><div><font face="'courier new', monospace"> KisPainter painter(device);</font></div>
<div><font face="'courier new', monospace"> painter.bitBlt(applyRect.topLeft(), quickHack, applyRect);</font></div><div><font face="arial, helvetica, sans-serif"><br>
</font></div><div><font face="arial, helvetica, sans-serif">In theory, this should work. I _thought_ that </font><font face="'courier new', monospace">painter.bitBlt</font><font face="arial, helvetica, sans-serif"> would convert the </font><font face="'courier new', monospace">RGB 8</font><font face="arial, helvetica, sans-serif"> information into whatever colorspace </font><font face="'courier new', monospace">device</font><font face="arial, helvetica, sans-serif"> is using. But... this didn't work.</font></div>
<div><font face="arial, helvetica, sans-serif">With this new code, I only get the expected output from the filter if my image uses an RGB 8 colorspace. With RGB 16 I get garbage, and with other colorspaces I get a crash (I think the crash is a bug from the UI that I need to fix, so I'm just testing with RGB 16 for now). So everything is like before, no improvement.</font></div>
<div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">Any idea of what I'm doing wrong?.</font></div><div><font face="arial, helvetica, sans-serif">I need a way to turn an RGB 8 bitmap into any other colorspace, I'm sure Krita already handles that, but I don't know how to turn that RGB 8 data into the other colorspaces.</font></div>
<div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">I am stuck here, so h</font><span style="font-family: arial,helvetica,sans-serif;">elp is greatly appreciated.</span></div>
</blockquote></div><br>I didn't understand exactly what you need, but i guess the following is what you are doing:<br><br>KisPaintDeviceSP device = <font face="'courier new', monospace">new KisPaintDevice(KoColorSpaceRegistry::instance()->rgb8());<br>
</font><span style="font-family: 'courier new',monospace;">device->convertFromQImage(bumpmap, "");</span><br><font face="courier new,monospace">device->convertTo(yourDesiredColorSpace);</font><br clear="all">
<br>Btw, the code you wrote above should work as well, but less efficiently. If it doesn't, it would be good to make a testcase in KisPainterTest.<br><br>-- <br>Dmitry Kazakov<br>