[Qt-interest] Getting number of pixels in a QImage

Keshava Krishna keshavkrishna88 at gmail.com
Mon Apr 6 17:17:51 CEST 2009


@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);
          }
}

here is  part of text gets printed on shell('m using ubuntu 8.10)

QImage::pixel: coordinate (88,70) out of range
QImage::setPixel: coordinate (88,70) out of range
QImage::pixel: coordinate (88,71) out of range
QImage::setPixel: coordinate (88,71) out of range
QImage::pixel: coordinate (88,72) out of range
QImage::setPixel: coordinate (88,72) out of range
QImage::pixel: coordinate (88,73) out of range
QImage::setPixel: coordinate (88,73) out of range
QImage::pixel: coordinate (88,74) out of range
QImage::setPixel: coordinate (88,74) out of range
QImage::pixel: coordinate (88,75) out of range
QImage::setPixel: coordinate (88,75) out of range
QImage::pixel: coordinate (88,76) out of range
QImage::setPixel: coordinate (88,76) out of range
QImage::pixel: coordinate (88,77) out of range
QImage::setPixel: coordinate (88,77) out of range
QImage::pixel: coordinate (88,78) out of range
QImage::setPixel: coordinate (88,78) out of range
QImage::pixel: coordinate (88,79) out of range
QImage::setPixel: coordinate (88,79) out of range
QImage::pixel: coordinate (88,80) out of range
QImage::setPixel: coordinate (88,80) out of range
QImage::pixel: coordinate (88,81) out of range
QImage::setPixel: coordinate (88,81) out of range
QImage::pixel: coordinate (88,82) out of range

this made me feel  that image->height() and image->width() is not giving the
proper values..
so , i mailed to the community...
sorry for not giving the code before...

Regards,
Keshava.




On Mon, Apr 6, 2009 at 12:43 PM, Rainer Wiesenfarth <
Rainer.Wiesenfarth at inpho.de> wrote:

>
> From: qt-interest-bounces at trolltech.com
> > i have a QImage, i want to get the no of pixels that are
> > present horizontally and vertically i e x and y....
> > QImage::width() and QImage::height() are not giving the
> > proper results...
> > can anyone suggest me a way  out??
>
> width() and heigth() should return the correct values, if they don't, there
> is something wrong with the code.
>
> As most of us are not clairvoyant, some details and a code snippet may lead
> to more useful answers than mine.
>
> 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
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090406/b0e5a37a/attachment.html 


More information about the Qt-interest-old mailing list