Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-interest Archive, January 2008
Weired QImage ARGB32_Premultiplied??


Message 1 in thread

Is there anybody who is familiar with QImage ?

In documentation of QT4.3 and QT4.2 it says

"In the premultiplied format the red, green, and blue channels are
multiplied by the alpha component divided by 255."

 

But I can never find any premultiplying codes for setPixel(). It seems like
no difference among RGB32, ARGB32, and 

ARGB32_Premultiplied for setPixel().

 

Do I have to premultiply, myself? 

I changed alpha to 0. But the pixel did not disappear.

 

setPixel(x,y, qRgba(r, g, b, 0))

 

setPixel(x,y,qRgba(r,g,b,255));

shows some more clear color. 

But according to the documentation, when the alpha is 0 it should be
disappeard or be changed to black

 

It seems like there is no action about alpha when either setPixe() or
drawImage() is used.

 

Is there any idea?

 

Samuel B. Park  (byeongjun.park@xxxxxxxx) - Research Associate of Sohn
Laboratory.

Case Western Reserve University. School of Medicine. Dept. Rad. Oncology

http://rophys.meds.case.edu

 


Message 2 in thread

Samuel Byeongjun Park wrote:
> Is there anybody who is familiar with QImage ?
> 
> In documentation of QT4.3 and QT4.2 it says
> 
> “In the premultiplied format the red, green, and blue channels are 
> multiplied by the alpha component divided by 255.”
> 
> But I can never find any premultiplying codes for setPixel(). It seems 
> like no difference among RGB32, ARGB32, and
> ARGB32_Premultiplied for setPixel().
> 
> Do I have to premultiply, myself?

I think this information only comes into play when you actually DRAW the 
QImage. Otherwise, it doesn't care what bytes you write into it.

-- 
 [ signature omitted ] 

Message 3 in thread

Thanks for your reply.
Yes. I did draw the QImage myself with setPixel(). I need it.
I have to draw multiple images (pixel by pixel) and to overlay them.
Do you have any other idea?

Anyway it is not working as the documentation yet.


Samuel B. Park.


-----Original Message-----
From: Paul Miller [mailto:paul@xxxxxxxxxx] 
Sent: Sunday, January 06, 2008 2:25 PM
To: qt-interest@xxxxxxxxxxxxx
Cc: qt-interest@xxxxxxxxxxxxx
Subject: Re: Weired QImage ARGB32_Premultiplied??

Samuel Byeongjun Park wrote:
> Is there anybody who is familiar with QImage ?
> 
> In documentation of QT4.3 and QT4.2 it says
> 
> "In the premultiplied format the red, green, and blue channels are 
> multiplied by the alpha component divided by 255."
> 
> But I can never find any premultiplying codes for setPixel(). It seems 
> like no difference among RGB32, ARGB32, and
> ARGB32_Premultiplied for setPixel().
> 
> Do I have to premultiply, myself?

I think this information only comes into play when you actually DRAW the 
QImage. Otherwise, it doesn't care what bytes you write into it.

-- 
 [ signature omitted ] 

Message 4 in thread

Hello Samuel.

I'm not sure what you are expecting here. setPixel is the same for Format_ARGB32 and for Format_ARGB32_Premultiplied.

From the docs: The image is stored using a premultiplied 32-bit ARGB format (0xAARRGGBB), i.e. the red, green, and blue channels are multiplied by the alpha component divided by 255. (If RR, GG, or BB has a higher value than the alpha channel, the results are undefined.) 

What is "not working as the documentation yet" here?

You'll have to do the premultiplying yourself.

The difference between Format_ARGB32 and Format_ARGB32_Premultiplied does not show before you actually DRAW your image. 

How do you overlay them? Are you using QPainter and drawImage?

Cheers,
Peter

> -----Ursprüngliche Nachricht-----
> Von: Samuel Byeongjun Park [mailto:Byeongjun.Park@xxxxxxxx] 
> Gesendet: Montag, 7. Januar 2008 14:48
> An: qt-interest@xxxxxxxxxxxxx
> Betreff: RE: Weired QImage ARGB32_Premultiplied??
> 
> Thanks for your reply.
> Yes. I did draw the QImage myself with setPixel(). I need it.
> I have to draw multiple images (pixel by pixel) and to overlay them.
> Do you have any other idea?
> 
> Anyway it is not working as the documentation yet.
> 
> 
> Samuel B. Park.
> 
> 
> -----Original Message-----
> From: Paul Miller [mailto:paul@xxxxxxxxxx] 
> Sent: Sunday, January 06, 2008 2:25 PM
> To: qt-interest@xxxxxxxxxxxxx
> Cc: qt-interest@xxxxxxxxxxxxx
> Subject: Re: Weired QImage ARGB32_Premultiplied??
> 
> Samuel Byeongjun Park wrote:
> > Is there anybody who is familiar with QImage ?
> > 
> > In documentation of QT4.3 and QT4.2 it says
> > 
> > "In the premultiplied format the red, green, and blue channels are 
> > multiplied by the alpha component divided by 255."
> > 
> > But I can never find any premultiplying codes for 
> setPixel(). It seems 
> > like no difference among RGB32, ARGB32, and
> > ARGB32_Premultiplied for setPixel().
> > 
> > Do I have to premultiply, myself?
> 
> I think this information only comes into play when you 
> actually DRAW the 
> QImage. Otherwise, it doesn't care what bytes you write into it.
> 
> -- 
> Paul Miller | paul@xxxxxxxxxx | www.fxtech.com | Got Tivo?
> 
> --
> 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/
> 
> 
> --
> 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/
> 
> 

--
 [ signature omitted ] 

Message 5 in thread

hi,

in the near past I had to do some work on image processing, and I may 
wrongly think that you need to mix the 2 pixel of 2 different images.
if I'm not wrong then you need to apply some 'algo' there to find out 
the final value of the pixel value(it can be for single image or any 
other number)
and then you use "setPixel()" to set that value into a 'empty imge' that 
in the end will represent the mix of images if I get it correctly.
the pixel value is calculated for each channel separately. this is very 
dependent on what you do.



Peter Prade wrote:
> Hello Samuel.
>
> I'm not sure what you are expecting here. setPixel is the same for Format_ARGB32 and for Format_ARGB32_Premultiplied.
>
> >From the docs: The image is stored using a premultiplied 32-bit ARGB format (0xAARRGGBB), i.e. the red, green, and blue channels are multiplied by the alpha component divided by 255. (If RR, GG, or BB has a higher value than the alpha channel, the results are undefined.) 
>
> What is "not working as the documentation yet" here?
>
> You'll have to do the premultiplying yourself.
>
> The difference between Format_ARGB32 and Format_ARGB32_Premultiplied does not show before you actually DRAW your image. 
>
> How do you overlay them? Are you using QPainter and drawImage?
>
> Cheers,
> Peter
>
>   
>> -----Ursprüngliche Nachricht-----
>> Von: Samuel Byeongjun Park [mailto:Byeongjun.Park@xxxxxxxx] 
>> Gesendet: Montag, 7. Januar 2008 14:48
>> An: qt-interest@xxxxxxxxxxxxx
>> Betreff: RE: Weired QImage ARGB32_Premultiplied??
>>
>> Thanks for your reply.
>> Yes. I did draw the QImage myself with setPixel(). I need it.
>> I have to draw multiple images (pixel by pixel) and to overlay them.
>> Do you have any other idea?
>>
>> Anyway it is not working as the documentation yet.
>>
>>
>> Samuel B. Park.
>>
>>
>> -----Original Message-----
>> From: Paul Miller [mailto:paul@xxxxxxxxxx] 
>> Sent: Sunday, January 06, 2008 2:25 PM
>> To: qt-interest@xxxxxxxxxxxxx
>> Cc: qt-interest@xxxxxxxxxxxxx
>> Subject: Re: Weired QImage ARGB32_Premultiplied??
>>
>> Samuel Byeongjun Park wrote:
>>     
>>> Is there anybody who is familiar with QImage ?
>>>
>>> In documentation of QT4.3 and QT4.2 it says
>>>
>>> "In the premultiplied format the red, green, and blue channels are 
>>> multiplied by the alpha component divided by 255."
>>>
>>> But I can never find any premultiplying codes for 
>>>       
>> setPixel(). It seems 
>>     
>>> like no difference among RGB32, ARGB32, and
>>> ARGB32_Premultiplied for setPixel().
>>>
>>> Do I have to premultiply, myself?
>>>       
>> I think this information only comes into play when you 
>> actually DRAW the 
>> QImage. Otherwise, it doesn't care what bytes you write into it.
>>
>> -- 
>> Paul Miller | paul@xxxxxxxxxx | www.fxtech.com | Got Tivo?
>>
>> --
>> 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/
>>
>>
>> --
>> 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/
>>
>>
>>     
>
> --
> 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/
>
>
>   

--
 [ signature omitted ] 

Message 6 in thread

> Hello Samuel.
> 
> I'm not sure what you are expecting here. setPixel is the same for 
> Format_ARGB32 and for Format_ARGB32_Premultiplied.
> 
> From the docs: The image is stored using a premultiplied 32-bit 
> ARGB format (0xAARRGGBB), i.e. the red, green, and blue channels 
> are multiplied by the alpha component divided by 255. (If RR, GG, 
> or BB has a higher value than the alpha channel, the results are 
> undefined.) 
> 
> What is "not working as the documentation yet" here?
> 
> You'll have to do the premultiplying yourself.

Ok.. I got it.. thank you.. It means I have to premultiply myself..

> 
> The difference between Format_ARGB32 and 
> Format_ARGB32_Premultiplied does not show before you actually DRAW 
> your image. 
> 
> How do you overlay them? Are you using QPainter and drawImage?

I used QPainter of another QImage and used drawImage
with QPainter::CompositionMode_SourceOver.

I will try again with my premultiplying code.

> Cheers,
> Peter

Thanks Peter.


Samuel Park

--
 [ signature omitted ]