## Blend 2 pictures

If you have a cool piece of software to share, but you are not hosting it officially yet, please dump it in here. If you have code snippets that are useful, please donate!
emarti
Filthy Rich wx Solver
Posts: 210
Joined: Sat May 07, 2005 8:24 pm
Location: Eskisehir, TURKEY
Contact:

### Blend 2 pictures

I wanna share with you.....

Code: Select all

``````// Blend 2 pictures
wxImage i1,i2;

unsigned char r1,r2,r,g1,g2,g,b1,b2,b;
int x,y; // i1 image's width & height
for (int x=0; x<i1.GetWidth();x++)
{
for (int y=0; y<i1.GetHeight(); y++){
// i1 and i2 RGB values
r1 = i1.GetRed(x,y);
r2 = i2.GetRed(x,y);
g1 = i1.GetGreen(x,y);
g2 = i2.GetGreen(x,y);
b1 = i1.GetBlue(x,y);
b2 = i2.GetBlue(x,y);
// New RGB
r = (r1 + r2)/2;
g = (g1 + g2)/2;
b = (b1 + b2)/2;
g = g << 8;
b = b << 16;
// SetRGB
i2.SetRGB(x,y,r,g,b);
}
}
WxStaticBitmap1->SetBitmap(wxBitmap(i2));
``````
Respectly,
emarti
- T U R K E Y ?
- I love this country!

WebSites:
http://mebt.sourceforge.net/
http://wxquran.sourceforge.net/

emarti
Filthy Rich wx Solver
Posts: 210
Joined: Sat May 07, 2005 8:24 pm
Location: Eskisehir, TURKEY
Contact:
Hi, again. A little sample.

http://emarti.50webs.com/Blend2Pic.zip
- T U R K E Y ?
- I love this country!

WebSites:
http://mebt.sourceforge.net/
http://wxquran.sourceforge.net/

priyank_bolia
wxWorld Domination!
Posts: 1339
Joined: Wed Aug 03, 2005 8:10 am
Location: BANGALORE, INDIA
Contact:

### Suggestion

Manipulate the image buffer, rather than calling the functions to access the pixels each time.

emarti
Filthy Rich wx Solver
Posts: 210
Joined: Sat May 07, 2005 8:24 pm
Location: Eskisehir, TURKEY
Contact:
Hi,

Respectly,
emarti
- T U R K E Y ?
- I love this country!

WebSites:
http://mebt.sourceforge.net/
http://wxquran.sourceforge.net/

timg
Earned some good credits
Posts: 148
Joined: Mon Jan 23, 2006 6:52 pm
look at wxImage.GetData(), it returns a pointer to the raw data.