Commit 849dfe2d authored by Luis Penaranda's avatar Luis Penaranda

improved file chooser dialog

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