Image Viewer in C++ with Source Code
* C++ Tutorial Demo with Source Code :
I will show that how to make image viewer using wxDev C++ IDE
How to make image viewer :-
(Screen Shot)
You need one button , one OpenFileDialog, One WxEdit , WxStaticBitmap
Open Button Code Here:-------
wxString filePath;
int w, h, NewW,NewH;
wxImage img;
int PhotoMaxSize = 250;
if (WxOpenFileDialog1->ShowModal()==wxID_OK){
WxEdit1->SetValue(WxOpenFileDialog1->GetPath());
filePath = WxEdit1->GetValue();
img = wxImage(filePath, wxBITMAP_TYPE_ANY);
w = img.GetWidth();
h = img.GetHeight();
if (w>h){
NewW = PhotoMaxSize;
NewH = PhotoMaxSize * h/w;
}
else{
NewH = PhotoMaxSize;
NewW = PhotoMaxSize * w/h;
}
img = img.Scale(NewW, NewH);
WxStaticBitmap1->SetBitmap(img);
WxStaticBitmap1->Refresh();
}
I will show that how to make image viewer using wxDev C++ IDE
How to make image viewer :-
You need one button , one OpenFileDialog, One WxEdit , WxStaticBitmap
Open Button Code Here:-------
wxString filePath;
int w, h, NewW,NewH;
wxImage img;
int PhotoMaxSize = 250;
if (WxOpenFileDialog1->ShowModal()==wxID_OK){
WxEdit1->SetValue(WxOpenFileDialog1->GetPath());
filePath = WxEdit1->GetValue();
img = wxImage(filePath, wxBITMAP_TYPE_ANY);
w = img.GetWidth();
h = img.GetHeight();
if (w>h){
NewW = PhotoMaxSize;
NewH = PhotoMaxSize * h/w;
}
else{
NewH = PhotoMaxSize;
NewW = PhotoMaxSize * w/h;
}
img = img.Scale(NewW, NewH);
WxStaticBitmap1->SetBitmap(img);
WxStaticBitmap1->Refresh();
}
Comments
Post a Comment