Skip to content

Instantly share code, notes, and snippets.

@mlabbe
Created September 17, 2014 18:20
Show Gist options
  • Save mlabbe/fecb713316a006735d2f to your computer and use it in GitHub Desktop.
Save mlabbe/fecb713316a006735d2f to your computer and use it in GitHub Desktop.
void ImgPremultiply( void )
{
Assert( surface[0].GetNumChannels() == 4 );
Uint8 *channels = surface[0].GetChannels();
for ( Uint32 i = 0; i < surface[0].GetPixelCount(); ++i )
{
Uint8 *p = &(channels[i*4]);
p[0] = Uint8(p[0] * (p[3] / 255.0f));
p[1] = Uint8(p[1] * (p[3] / 255.0f));
p[2] = Uint8(p[2] * (p[3] / 255.0f));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment