How do you save images in wxWidgets?

Hi everyone, I am currently working on a paint program and I am having trouble getting it to save images. Any images that it saves ends up blank. Can someone please help me. Here's the code for my save image function:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
void MyFrame::OnSaveImage(wxCommandEvent& event)
{
	Memory->SelectObject(*Image);
	Image->SetSize(this->GetSize());
	for(int i=0;i<=element;i++)
	{
		Memory->SetPen(Pen.at(i));
		Memory->DrawLine(Start.at(i),End.at(i));
	}
	wxFileDialog *FileDialog = new wxFileDialog(this,wxFileSelectorPromptStr,wxEmptyString,wxEmptyString,
	wxT("Bitmap Files (*.bmp)|*.bmp"),wxFD_SAVE);
	if (FileDialog->ShowModal() == wxID_OK)
	{
		wxString PlaceName = FileDialog->GetPath();
		Image->SaveFile(PlaceName, wxBITMAP_TYPE_BMP);
	}
	else
		return;
}


Please help!!!
What type is Image? Neither wxImage nor wxBitmap has according to the current documentation a function named SetSize()

wxImage has a function Size which returns a copy of the image with the new size (what probably happens in your case). Use Resize in order to change the size of an image in place.

See

http://docs.wxwidgets.org/stable/wx_wximage.html#wximage
http://docs.wxwidgets.org/stable/wx_wximage.html#wximageresize
http://docs.wxwidgets.org/stable/wx_wximage.html#wximagesize
Image is a wxBitmap, I have worked out the problem but I have no idea about how to solve it. i think the problem is that when I draw on Memory, it does not apply the changes to Image. Please help!!!
Use the latest version of wxwidget. I don't know what SetSize() does.

how is Image created?

http://docs.wxwidgets.org/stable/wx_wxbitmap.html#wxbitmapcreate

I'd expect that Image is a local varibale within OnSaveImage(). I'd expect that for Memory too which is a wxMemoryDC?

Topic archived. No new replies allowed.