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!
Post Reply
emarti
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 210
Joined: Sat May 07, 2005 8:24 pm
Location: Eskisehir, TURKEY
Contact:

Blend 2 pictures

Post by emarti » Mon Mar 20, 2006 1:53 am

I wanna share with you.....

Code: Select all

// Blend 2 pictures
wxImage::AddHandler( new wxBMPHandler);
wxImage i1,i2;
i1.LoadFile(_T("1.bmp"), wxBITMAP_TYPE_BMP);
i2.LoadFile(_T("2.bmp"), wxBITMAP_TYPE_BMP);
		
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
Filthy Rich wx Solver
Posts: 210
Joined: Sat May 07, 2005 8:24 pm
Location: Eskisehir, TURKEY
Contact:

Post by emarti » Tue Mar 21, 2006 11:58 pm

Hi, again. A little sample.
Image

Download sample (with source)
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!
wxWorld Domination!
Posts: 1339
Joined: Wed Aug 03, 2005 8:10 am
Location: BANGALORE, INDIA
Contact:

Suggestion

Post by priyank_bolia » Wed Mar 22, 2006 11:03 am

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

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

Post by emarti » Wed Mar 22, 2006 10:30 pm

Hi,
How to manipulate the image buffer? I am poor about this concept probably.

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
Earned some good credits
Posts: 148
Joined: Mon Jan 23, 2006 6:52 pm

Post by timg » Thu Mar 23, 2006 12:47 am

look at wxImage.GetData(), it returns a pointer to the raw data.

Post Reply