make j2k_to_image return errors
This commit is contained in:
parent
27850206b5
commit
b1342da5c5
|
@ -8,6 +8,7 @@ What's New for OpenJPEG
|
||||||
Jun 21, 2010
|
Jun 21, 2010
|
||||||
* [MM] Move CMake files to CMake folder
|
* [MM] Move CMake files to CMake folder
|
||||||
* [MM] Remove some warnings in code
|
* [MM] Remove some warnings in code
|
||||||
|
* [MM] j2k_to_image properly return error code
|
||||||
|
|
||||||
April 8, 2010
|
April 8, 2010
|
||||||
* [FOD] Fixed problem with Borland C++ Builder (Borland C do not have lrintf). Thanks Marek Mauder for this fix.
|
* [FOD] Fixed problem with Borland C++ Builder (Borland C do not have lrintf). Thanks Marek Mauder for this fix.
|
||||||
|
|
|
@ -508,6 +508,7 @@ void info_callback(const char *msg, void *client_data) {
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
opj_dparameters_t parameters; /* decompression parameters */
|
opj_dparameters_t parameters; /* decompression parameters */
|
||||||
img_fol_t img_fol;
|
img_fol_t img_fol;
|
||||||
opj_image_t *image = NULL;
|
opj_image_t *image = NULL;
|
||||||
|
@ -534,7 +535,7 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
/* parse input and get user encoding parameters */
|
/* parse input and get user encoding parameters */
|
||||||
if(parse_cmdline_decoder(argc, argv, ¶meters,&img_fol, indexfilename) == 1) {
|
if(parse_cmdline_decoder(argc, argv, ¶meters,&img_fol, indexfilename) == 1) {
|
||||||
return 1;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize reading of directory */
|
/* Initialize reading of directory */
|
||||||
|
@ -547,18 +548,18 @@ int main(int argc, char **argv)
|
||||||
dirptr->filename = (char**) malloc(num_images*sizeof(char*));
|
dirptr->filename = (char**) malloc(num_images*sizeof(char*));
|
||||||
|
|
||||||
if(!dirptr->filename_buf){
|
if(!dirptr->filename_buf){
|
||||||
return 0;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
for(i=0;i<num_images;i++){
|
for(i=0;i<num_images;i++){
|
||||||
dirptr->filename[i] = dirptr->filename_buf + i*OPJ_PATH_LEN;
|
dirptr->filename[i] = dirptr->filename_buf + i*OPJ_PATH_LEN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(load_images(dirptr,img_fol.imgdirpath)==1){
|
if(load_images(dirptr,img_fol.imgdirpath)==1){
|
||||||
return 0;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
if (num_images==0){
|
if (num_images==0){
|
||||||
fprintf(stdout,"Folder is empty\n");
|
fprintf(stdout,"Folder is empty\n");
|
||||||
return 0;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
num_images=1;
|
num_images=1;
|
||||||
|
@ -584,7 +585,7 @@ int main(int argc, char **argv)
|
||||||
(!fsrc)
|
(!fsrc)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "ERROR -> failed to open %s for reading\n", parameters.infile);
|
fprintf(stderr, "ERROR -> failed to open %s for reading\n", parameters.infile);
|
||||||
return 1;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
cio = opj_stream_create_default_file_stream(fsrc,true);
|
cio = opj_stream_create_default_file_stream(fsrc,true);
|
||||||
/* decode the code-stream */
|
/* decode the code-stream */
|
||||||
|
@ -650,7 +651,7 @@ int main(int argc, char **argv)
|
||||||
opj_destroy_codec(dinfo);
|
opj_destroy_codec(dinfo);
|
||||||
opj_stream_destroy(cio);
|
opj_stream_destroy(cio);
|
||||||
fclose(fsrc);
|
fclose(fsrc);
|
||||||
return 1;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* close the byte stream */
|
/* close the byte stream */
|
||||||
|
@ -662,6 +663,7 @@ int main(int argc, char **argv)
|
||||||
bSuccess = write_index_file(&cstr_info, indexfilename);
|
bSuccess = write_index_file(&cstr_info, indexfilename);
|
||||||
if (bSuccess) {
|
if (bSuccess) {
|
||||||
fprintf(stderr, "Failed to output index file\n");
|
fprintf(stderr, "Failed to output index file\n");
|
||||||
|
ret = EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -671,54 +673,66 @@ int main(int argc, char **argv)
|
||||||
case PXM_DFMT: /* PNM PGM PPM */
|
case PXM_DFMT: /* PNM PGM PPM */
|
||||||
if (imagetopnm(image, parameters.outfile)) {
|
if (imagetopnm(image, parameters.outfile)) {
|
||||||
fprintf(stdout,"Outfile %s not generated\n",parameters.outfile);
|
fprintf(stdout,"Outfile %s not generated\n",parameters.outfile);
|
||||||
|
ret = EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
|
fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
|
||||||
|
ret = EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PGX_DFMT: /* PGX */
|
case PGX_DFMT: /* PGX */
|
||||||
if(imagetopgx(image, parameters.outfile)){
|
if(imagetopgx(image, parameters.outfile)){
|
||||||
fprintf(stdout,"Outfile %s not generated\n",parameters.outfile);
|
fprintf(stdout,"Outfile %s not generated\n",parameters.outfile);
|
||||||
|
ret = EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
|
fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
|
||||||
|
ret = EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BMP_DFMT: /* BMP */
|
case BMP_DFMT: /* BMP */
|
||||||
if(imagetobmp(image, parameters.outfile)){
|
if(imagetobmp(image, parameters.outfile)){
|
||||||
fprintf(stdout,"Outfile %s not generated\n",parameters.outfile);
|
fprintf(stdout,"Outfile %s not generated\n",parameters.outfile);
|
||||||
|
ret = EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
|
fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
|
||||||
|
ret = EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TIF_DFMT: /* TIFF */
|
case TIF_DFMT: /* TIFF */
|
||||||
if(imagetotif(image, parameters.outfile)){
|
if(imagetotif(image, parameters.outfile)){
|
||||||
fprintf(stdout,"Outfile %s not generated\n",parameters.outfile);
|
fprintf(stdout,"Outfile %s not generated\n",parameters.outfile);
|
||||||
|
ret = EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
|
fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
|
||||||
|
ret = EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RAW_DFMT: /* RAW */
|
case RAW_DFMT: /* RAW */
|
||||||
if(imagetoraw(image, parameters.outfile)){
|
if(imagetoraw(image, parameters.outfile)){
|
||||||
fprintf(stdout,"Error generating raw file. Outfile %s not generated\n",parameters.outfile);
|
fprintf(stdout,"Error generating raw file. Outfile %s not generated\n",parameters.outfile);
|
||||||
|
ret = EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile);
|
fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile);
|
||||||
|
ret = EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TGA_DFMT: /* TGA */
|
case TGA_DFMT: /* TGA */
|
||||||
if(imagetotga(image, parameters.outfile)){
|
if(imagetotga(image, parameters.outfile)){
|
||||||
fprintf(stdout,"Error generating tga file. Outfile %s not generated\n",parameters.outfile);
|
fprintf(stdout,"Error generating tga file. Outfile %s not generated\n",parameters.outfile);
|
||||||
|
ret = EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile);
|
fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile);
|
||||||
|
ret = EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -736,7 +750,7 @@ int main(int argc, char **argv)
|
||||||
opj_image_destroy(image);
|
opj_image_destroy(image);
|
||||||
|
|
||||||
}
|
}
|
||||||
return 0;
|
return ret;
|
||||||
}
|
}
|
||||||
//end main
|
//end main
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue