The above video goes away if you are a member and logged in, so log in now!

 Would you like to get all the newest Gaming News fromQJ.NET in your email each day? Want to learn more about the team who brings you the QJ news?

## Optimizing?

This is a discussion on Optimizing? within the Developer's Dungeon forums, part of the PSP Development Forum category; any one know a better way of doing this it is a alpha blend function where color is the color ...

 Tweet
1. ## Optimizing?

any one know a better way of doing this
it is a alpha blend function where color is the color you are drawing on the destinationData (background color)

Code:
```         rcolorc = (   color & 0xff );
gcolorc = (( color >> 8 ) & 0xff );
bcolorc = (( color >> 16 ) & 0xff );
acolorc = (( color >> 24) & 0xff);
rcolord = ( *destinationData & 0xff );
gcolord = (( *destinationData >> 8 ) & 0xff );
bcolord = (( *destinationData >> 16 ) & 0xff );
acolord = (( *destinationData >> 24) & 0xff);

rcolorc = ((acolorc*rcolorc)>>8) + (((255-acolorc) * rcolord)>>8);
if(rcolorc>255) rcolorc=255;
gcolorc = ((acolorc*gcolorc)>>8) + (((255-acolorc) * gcolord)>>8);
if(gcolorc>255) gcolorc=255;
bcolorc = ((acolorc*bcolorc)>>8) + (((255-acolorc) * bcolord)>>8);
if(bcolorc>255) bcolorc=255;
if(acolord+acolorc<255){
acolorc = acolord+acolorc;
}else{
acolorc = 255;
}
*destinationData = MAKE_ARGB( (int) acolorc, (int) rcolorc, (int) gcolorc, (int) bcolorc );```

2. I'm assuming you want full quality alpha'ing, right? Otherwise you could look and see if there are any optimisations which lower accuracy slightly, but there's little to work with, a few multiplies here and there, no massively slow operations.
I don't think the function itself is particularly slow, but it would be how you're calling it that may have room for improvements.

Say you're calling this function on a 10x10 square of pixels on a texture, you could optimise this by using 10-pixel strips, and incrementing the pointer, rather than calling get and set operations each time. Try and make your functions use as little memory-shifting code as possible, and try to treat things as groups rather than individual pixels. Also, don't use divides, they're pretty slow in general (I can't see any in your current code, but just be careful).

3. yeah that was my first step changed all the /255 to >>8
thanks for the tips

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

All times are GMT -8. The time now is 10:23 AM.

Use of this Web site constitutes acceptance of the TERMS & CONDITIONS and PRIVACY POLICY