how do you open a image in wxWidgets?

Hi everyone, I am trying to make a program that can open images. This doesn't seem to work some how

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
void MyFrame::OnOpenImage(wxCommandEvent& event)
{
	if(assigned==false)
		Canvas=new wxClientDC(this);
	if(FileLoaded==true)
	{
		delete Image;
		delete Memory;
	}
	Memory=new wxMemoryDC;
	wxFileDialog * FileDialog = new wxFileDialog(this);
	if (FileDialog->ShowModal() == wxID_OK)
	{
		wxString FileName = FileDialog->GetPath();
		Image=new wxBitmap;
		Image->LoadFile(FileName,wxBITMAP_TYPE_PNG);
	}
	Canvas->Clear();
	for(;element>-1;element--)
	{
		Pen.pop_back();
		Start.pop_back();
		End.pop_back();
	}
	Memory->SelectObject(*Image);
	Canvas->Blit(50, 0, Image->GetWidth(), Image->GetHeight(), Memory, 0, 0, wxCOPY, true);
	FileLoaded=true;
}


Please help!!!
Last edited on
Did you called wxInitAllImageHandlers() first ?
I put that wxInitAllImageHandlers() in my program, but it still comes up with an error when I run it.
Topic archived. No new replies allowed.