Finish fixing up bugs with png i/o
This commit is contained in:
parent
3a44c91ea3
commit
f71e6e7879
|
@ -81,7 +81,7 @@ foreach(filename ${OPENJPEG_DATA_IMAGES_GLOB})
|
||||||
#message( "found:${output_variable} for ${filename_temp}" )
|
#message( "found:${output_variable} for ${filename_temp}" )
|
||||||
endif()
|
endif()
|
||||||
ADD_TEST(dump-${filename_temp} ${EXECUTABLE_OUTPUT_PATH}/j2k_dump -i ${filename})
|
ADD_TEST(dump-${filename_temp} ${EXECUTABLE_OUTPUT_PATH}/j2k_dump -i ${filename})
|
||||||
foreach(codec_type ppm pgx bmp tif raw tga)
|
foreach(codec_type ppm pgx bmp tif raw tga png)
|
||||||
ADD_TEST(j2i-${filename_temp}-${codec_type} ${EXECUTABLE_OUTPUT_PATH}/j2k_to_image -i ${filename} -o ${filename_temp}.${codec_type})
|
ADD_TEST(j2i-${filename_temp}-${codec_type} ${EXECUTABLE_OUTPUT_PATH}/j2k_to_image -i ${filename} -o ${filename_temp}.${codec_type})
|
||||||
ADD_TEST(i2j-${filename_temp}-${codec_type} ${EXECUTABLE_OUTPUT_PATH}/image_to_j2k -i ${filename_temp}.${codec_type} -o ${filename_temp}.${codec_type}${filename_ext})
|
ADD_TEST(i2j-${filename_temp}-${codec_type} ${EXECUTABLE_OUTPUT_PATH}/image_to_j2k -i ${filename_temp}.${codec_type} -o ${filename_temp}.${codec_type}${filename_ext})
|
||||||
#if(UNIX)
|
#if(UNIX)
|
||||||
|
|
|
@ -1713,6 +1713,14 @@ int main(int argc, char **argv) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PNG_DFMT:
|
||||||
|
image = pngtoimage(parameters.infile, ¶meters);
|
||||||
|
if (!image) {
|
||||||
|
fprintf(stderr, "Unable to load png file\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
/* Decide if MCT should be used */
|
/* Decide if MCT should be used */
|
||||||
parameters.tcp_mct = image->numcomps == 3 ? 1 : 0;
|
parameters.tcp_mct = image->numcomps == 3 ? 1 : 0;
|
||||||
|
|
|
@ -31,7 +31,6 @@
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#define __USE_BSD
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
@ -43,6 +42,7 @@
|
||||||
#include "index.h"
|
#include "index.h"
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
|
#include <strings.h>
|
||||||
#define _stricmp strcasecmp
|
#define _stricmp strcasecmp
|
||||||
#define _strnicmp strncasecmp
|
#define _strnicmp strncasecmp
|
||||||
#endif
|
#endif
|
||||||
|
@ -60,7 +60,7 @@
|
||||||
#define TIF_DFMT 14
|
#define TIF_DFMT 14
|
||||||
#define RAW_DFMT 15
|
#define RAW_DFMT 15
|
||||||
#define TGA_DFMT 16
|
#define TGA_DFMT 16
|
||||||
|
#define PNG_DFMT 17
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
|
||||||
typedef struct dircnt{
|
typedef struct dircnt{
|
||||||
|
@ -190,8 +190,8 @@ int load_images(dircnt_t *dirptr, char *imgdirpath){
|
||||||
|
|
||||||
int get_file_format(char *filename) {
|
int get_file_format(char *filename) {
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
static const char *extension[] = {"pgx", "pnm", "pgm", "ppm", "bmp","tif", "raw", "tga", "j2k", "jp2", "jpt", "j2c", "jpc" };
|
static const char *extension[] = {"pgx", "pnm", "pgm", "ppm", "bmp","tif", "raw", "tga", "png", "j2k", "jp2", "jpt", "j2c", "jpc" };
|
||||||
static const int format[] = { PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT, TIF_DFMT, RAW_DFMT, TGA_DFMT, J2K_CFMT, JP2_CFMT, JPT_CFMT, J2K_CFMT, J2K_CFMT };
|
static const int format[] = { PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT, TIF_DFMT, RAW_DFMT, TGA_DFMT, PNG_DFMT, J2K_CFMT, JP2_CFMT, JPT_CFMT, J2K_CFMT, J2K_CFMT };
|
||||||
char * ext = strrchr(filename, '.');
|
char * ext = strrchr(filename, '.');
|
||||||
if (ext == NULL)
|
if (ext == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -288,6 +288,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
|
||||||
case TIF_DFMT:
|
case TIF_DFMT:
|
||||||
case RAW_DFMT:
|
case RAW_DFMT:
|
||||||
case TGA_DFMT:
|
case TGA_DFMT:
|
||||||
|
case PNG_DFMT:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "Unknown output format image %s [only *.pnm, *.pgm, *.ppm, *.pgx, *.bmp, *.tif, *.raw or *.tga]!! \n", outfile);
|
fprintf(stderr, "Unknown output format image %s [only *.pnm, *.pgm, *.ppm, *.pgx, *.bmp, *.tif, *.raw or *.tga]!! \n", outfile);
|
||||||
|
@ -325,6 +326,9 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
|
||||||
case TGA_DFMT:
|
case TGA_DFMT:
|
||||||
img_fol->out_format = "raw";
|
img_fol->out_format = "raw";
|
||||||
break;
|
break;
|
||||||
|
case PNG_DFMT:
|
||||||
|
img_fol->out_format = "png";
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "Unknown output format image %s [only *.pnm, *.pgm, *.ppm, *.pgx, *.bmp, *.tif, *.raw or *.tga]!! \n", outformat);
|
fprintf(stderr, "Unknown output format image %s [only *.pnm, *.pgm, *.ppm, *.pgx, *.bmp, *.tif, *.raw or *.tga]!! \n", outformat);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -735,6 +739,16 @@ int main(int argc, char **argv)
|
||||||
ret = EXIT_SUCCESS;
|
ret = EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PNG_DFMT: /* PNG */
|
||||||
|
if(imagetopng(image, parameters.outfile)){
|
||||||
|
fprintf(stdout,"Error generating png file. Outfile %s not generated\n",parameters.outfile);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* free remaining structures */
|
/* free remaining structures */
|
||||||
|
|
Loading…
Reference in New Issue