Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / Blending two bitmaps

Author
Message
Robin
21
Years of Service
User Offline
Joined: 22nd Feb 2003
Location: United Kingdom
Posted: 9th Jan 2004 15:49
Hi
Is there a code snippet available which blends two 128x128 bitmaps together? I think theres a way by getting each pixel colour, and working out what the blended colour would look like, but i'm not really sure about this.
thanks
Robin

http://www.thegameszone.tk | robin@thegameszone.tk
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 9th Jan 2004 17:20 Edited at: 9th Jan 2004 17:29
Well the colour would be halfway between the two RGB values.

If R1 > R2
R3 = R2 + (R1 - R2 / 2)

else
R3 = R1 + (R2 - R1 / 2)
Endif

R3 = your new colour for Red.

Do that for Red, Green, and Blue.

You need to check if (R1 - R2 / 2) is greater than 0.
Something like that should work, but it will be slow because you need the point command to get each pixel colour.

Pincho.

Hamish McHaggis
21
Years of Service
User Offline
Joined: 13th Dec 2002
Location: Modgnik Detinu
Posted: 10th Jan 2004 15:53 Edited at: 10th Jan 2004 16:08
Voila... probably could be optimized but it goes pretty fast with 100*100 bitmaps.

Syntax: blendBitmap(firstBitmap,secondBitmap,outputBitmap,blendAmount)

Blend of 0 = All bitmap 1
Blend of 255 = All bitmap 2
Blend of 127 = 50/50

Input bitmaps should be the same size, output bitmap should be the same size or bigger than input bitmaps.

Do you bite your thumb at me sir?

Athelon XP 1600 Plus - Nvidia Geforce MX400 - 256mb RAM

Login to post a reply

Server time is: 2024-05-11 12:36:28
Your offset time is: 2024-05-11 12:36:28