qt-interest@trolltech.com
[Top] [All Lists]

Re: RE : Re: Drawing an image with transparency value

Subject: Re: RE : Re: Drawing an image with transparency value
From: Gunnar Sletta
Date: Mon, 26 Jun 2006 17:13:07 +0200
Mokrani Abdeslam wrote:
Ok,
While waiting for 4.2 version, I use the code below to reset all the alpha channel each time the value of alpha change. Thanks.

    const uchar *dest_data = img.bits();
    int w = img.width(), h = img.height(), bpp = img.bytesPerLine();
    for (int y = 0; y < h; ++y) {
      QRgb *dest = (QRgb *) dest_data;
      for (int x = 0; x < w; ++x) {
          *dest = (alpha << 24) | (*dest & 0x00ffffff);
          ++dest;
      }
      dest_data += bpp;
    }


This won't work if you have an image on the format QImage::Format_ARGB32_Premultiplied, though... Which is recommended as it is significantly faster.

-
Gunnar

--
To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with 
"unsubscribe" in the subject or the body.
List archive and information: http://lists.trolltech.com/qt-interest/

<Prev in Thread] Current Thread [Next in Thread>