Commit 849dfe2d by Luis Penaranda

improved file chooser dialog

1 parent 80e0504b
......@@ -62,6 +62,8 @@ unsigned char *FileRead::read_image(const char *new_image,int *width,int *height
return NULL;
}
const char *FileRead::image_types="All images (*.png *.jpg *.jpeg *.pnm *.pbm *.pgm *.ppm);;PNG images (*.png);;JPG images (*.jpg *.jpeg);;PBM images (*.pnm *.pbm *.pgm *.ppm);;All files (*)";
unsigned char *FileRead::jpgRead(const char *texturePath,
int *outImageWidth,
int *outImageHeight){
......
......@@ -28,6 +28,7 @@ class FileRead{
static enum FileType get_file_type(const char*);
protected:
static unsigned char *read_image(const char*,int*,int*);
static const char *image_types;
private:
static unsigned char *jpgRead(const char*,int*,int*);
static unsigned char *pngRead(const char*,int*,int*);
......
......@@ -279,8 +279,11 @@ void OpenGLCanvas::load_image(const char *new_image){
}
void OpenGLCanvas::change_input_image(){
load_image(QFileDialog::getOpenFileName(this,tr("Choose Panorama File")).toStdString().c_str());
updateGL();
const char *fname=QFileDialog::getOpenFileName(this,tr("Choose Panorama File"),"",FileRead::image_types).toStdString().c_str();
if(strlen(fname)>0){
load_image(fname);
updateGL();
}
}
void OpenGLCanvas::initializeGL(){
......@@ -305,7 +308,7 @@ void OpenGLCanvas::initializeGL(){
// If the input file does not exist or was not specified.
struct stat testbuf;
if(stat(input_image_file,&testbuf)||!strcmp(input_image_file,"")){
load_image(QFileDialog::getOpenFileName(this,tr("Choose Panorama File")).toStdString().c_str());
load_image(QFileDialog::getOpenFileName(this,tr("Choose Panorama File"),"",FileRead::image_types).toStdString().c_str());
}else{
load_image(input_image_file);
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!