[Qt-interest] Getting number of pixels in a QImage
Rainer Wiesenfarth
Rainer.Wiesenfarth at inpho.de
Tue Apr 7 08:23:22 CEST 2009
From: Keshava Krishna [mailto:keshavkrishna88 at gmail.com]
> @Rainer,
>
> have a look at the code...
>
> QColor *pixelColor;
> int c;
> image=new QImage(imageFileName);
> for(int i=0;i<image->width();i++)
> {
> for(int j=0;j<image->height();j++)
> {
>
> pixelColor = new QColor(image->pixel(i,j));
> pixelColor->setAlphaF(0.3);
> c = pixelColor->rgba();
> image->setPixel(i,j,c);
> }
> }
> [...]
You swapped row and column of the image. So either i should run from 0 to
height() and j from 0 to width(), or the calls should be pixel(j,i) and
setPixel(j,i,c).
See what a code snippet can do to solve your problem? ;-)
Best Regards / Mit freundlichen Grüßen
Rainer Wiesenfarth
--
INPHO GmbH * Smaragdweg 1 * 70174 Stuttgart * Germany
phone: +49 711 2288 10 * fax: +49 711 2288 111 * web: www.inpho.de
place of business: Stuttgart * managing director: Johannes Saile
commercial register: Stuttgart, HRB 9586
Leader in Photogrammetry and Digital Surface Modelling
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3359 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090407/cc1b9980/attachment.bin
More information about the Qt-interest-old
mailing list