Objectmix
Tags Register Mark Forums Read

Optimizing alpha blending of two 32bit images : Graphics

This is a discussion on Optimizing alpha blending of two 32bit images within the Graphics forums in Theory and Concepts category; On Apr 9, 12:38 am, Nils <n.pipenbri...@cubic.org> wrote: > Thank you all for the insights on this topic and division. I'm still lost at MMX/SIMD, they seem helpful in processing several operations simultaneously, such as processing the 3 color or even more at the same time. But I didn't know how yet. I'll give it some more time. In the mean time, I'm happy with the performance gain from premultiplication and division optimization. Thanks, Bill Holt...


Object Mix > Theory and Concepts > Graphics > Optimizing alpha blending of two 32bit images

Reply

 

LinkBack Thread Tools
  #11  
Old 04-08-2008, 09:48 PM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default Re: Optimizing alpha blending of two 32bit images

On Apr 9, 12:38 am, Nils <n.pipenbri...@cubic.org> wrote:
>


Thank you all for the insights on this topic and division. I'm still
lost at MMX/SIMD, they seem helpful in processing several operations
simultaneously, such as processing the 3 color or even more at the
same time. But I didn't know how yet. I'll give it some more time. In
the mean time, I'm happy with the performance gain from
premultiplication and division optimization.

Thanks,
Bill Holt

Reply With Quote
  #12  
Old 04-10-2008, 08:56 AM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default Re: Optimizing alpha blending of two 32bit images

Nils a écrit :
> For division by 255 there is the good old Jim Blinn-Trick which encodes
> the first continued fraction and adds some rounding:
>
>
> ui32 iyteblend (ui8 a, ui8 b)
> // returns a*b/255. Exact in all corner-cases but
> // some difference in the inbetweens.
> {
> i32 t = a * b;
> return ((t>>8) + t + 1)>>8;
> }
>
>
> For ARGB32 blending you might want to check out this weblink:
>
> http://www.stereopsis.com/doubleblend.html
>
> Nils


Hi !

// Returns (a * b) / 255. Exact value =)
int blend(byte a, byte b)
{
return ((a * b) * 0x8081) >> 23;
}
Reply With Quote
  #13  
Old 04-10-2008, 11:21 AM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default Re: Optimizing alpha blending of two 32bit images

Agnain wrote:
> Nils a écrit :
>> For division by 255 there is the good old Jim Blinn-Trick which
>> encodes the first continued fraction and adds some rounding:
>>
>>
>> ui32 iyteblend (ui8 a, ui8 b)
>> // returns a*b/255. Exact in all corner-cases but
>> // some difference in the inbetweens.
>> {
>> i32 t = a * b;
>> return ((t>>8) + t + 1)>>8;
>> }
>>
>>
>> For ARGB32 blending you might want to check out this weblink:
>>
>> http://www.stereopsis.com/doubleblend.html
>>
>> Nils

>
> Hi !
>
> // Returns (a * b) / 255. Exact value =)
> int blend(byte a, byte b)
> {
> return ((a * b) * 0x8081) >> 23;
> }



#define MULT_DIV_255(_res, _a, _b) \
(_res) = (_a) * (_b) + 0x80; \
(_res) = ((((_res) >> 8) + (_res)) >> 8);


Exact value, and it can be performed in 16 bits precision (if a and b
are 8 bits numbers)
Reply With Quote
Reply

Thread Tools



All times are GMT -5. The time now is 04:28 AM.