Merging more bitmap and save to single file

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
sivaranjani
Knows some wx things
Knows some wx things
Posts: 46
Joined: Wed Mar 14, 2018 10:43 am

Merging more bitmap and save to single file

Post by sivaranjani »

Hi,
I have to capture multiple images from the particular range values i.e(from calculated rect size).And finally all images has to be merged to single file and merged bitmap has to be saved.

Code: Select all

	for(int i= 0; i< Views.size();i++)
	{
		wxBitmap screenshot(parentSize.GetWidth(), parentSize.GetHeight(), -1);
		screenshot.GetSubBitmap(wxRect(0, 0, cansize.GetWidth(), cansize.GetHeight()));
		memDC.SelectObject(screenshot);
		screenshot.SaveFile("screenshot.jpg",wxBITMAP_TYPE_JPEG);
		tempimg = screenshot.ConvertToImage();
	}
	wxFileDialog saveFileDialog(this, wxT("Save Image"), _U(""), _U(""), _U("Bitmap (*.bmp)|*.bmp|JPEG (*.jpg)|*.jpg|PNG (*.png)|*.png|TIFF (*.tif)|*.tif|"), wxFD_SAVE);
				
				if (saveFileDialog.ShowModal() == wxID_CANCEL)
					return;

				wxString filename = saveFileDialog.GetPath();
				tempimg.SaveFile(filename.t_str(), wxBITMAP_TYPE_PNG);
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: Merging more bitmap and save to single file

Post by PB »

And your question is?

I think there is at least one issue in your code: You do not capture and work with the result of GetSubBitmap()?

Generally, you need to compute the size of the resulting image, create wxBitmap of this size and then paste the individual screenshots into it, probably via selecting the big bitmap into wxDC and then DrawBitmap()ing the screenshots into it. Should not be difficult, assuming the composed bitmap is not unreasonably large...
sivaranjani
Knows some wx things
Knows some wx things
Posts: 46
Joined: Wed Mar 14, 2018 10:43 am

Re: Merging more bitmap and save to single file

Post by sivaranjani »

Hi,
In the attached bitmap.png file there is two panels in which active panel is highlighted by blue colour.while capturing and storing image i should not display colour.so i tried to use GetSubBitmap() function to get particular panel and merge.

Thanks,
Attachments
bitmap.png
bitmap.png (2.2 KiB) Viewed 710 times
Post Reply