[email protected] wrote:
> Hi,
> 
> I am trying to modify HSV values of a Qimage and am finding dithered
> edges in the modified image after manipulating the pixels. 
> Can you provide some pointers on how to fix this issue. My code is given
> below ...
 >
>     public QImage applyImageFilter(final QImage origimg) {
>         // img is the original image and img1 is the resultant img
>         QImage img1 = new QImage(80, 80, QImage.Format.Format_ARGB32);
>         img1.convertToFormat(QImage.Format.Format_ARGB32,
> ImageConversionFlag.AlphaDither_Mask);

This code makes little sense... First you create the pixmap with ARGB32 
format, then convert it to ARGB32 format? This is a redundant operation 
and should be removed.

>         img1.fill(QColor.transparent.value());
>         QPainter p = new QPainter(img1);
>         QSvgRenderer svgrenderer = new QSvgRenderer();
>         p.setRenderHint(QPainter.RenderHint.Antialiasing, true);
> 
>         for (int i = 0; i < 80; i++) {
>             for (int j = 0; j < 80; j++) {
>                 int col = origimg.pixel(i, j);
>                 if (col == 0) {
>                     continue;
>                 }
>                 QColor qcol = new QColor(col);
>                 qcol.setHsvF(0.0, 1.0, 0.5, 1.0);
>                 QPen pen = new QPen(qcol, 1.0, PenStyle.SolidLine,
> PenCapStyle.FlatCap, PenJoinStyle.RoundJoin);
>                 p.setPen(pen);
>                 p.drawPoint(i, j);

Using a painter for this is overkill and in addition to being a lot more 
expensive... why not just:

                   img1.setPixmap(i, j, qcol.argb());

>             }
>         }
>         p.end();
>         svgrenderer.render(p);
>         return img1;
>     } 

The reason you have artifacts along the edges of your image is because 
you are drawing with anti-aliasing. A complete description of the 
coordinates system is covered here:

http://doc.trolltech.com/qtjambi-4.4/html/com/trolltech/qt/coordsys.html

but you probably just want to use QImage::setPixel().

best regards,
Gunnar

_______________________________________________
Qt-jambi-interest mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt-jambi-interest

Reply via email to