[trunk] Add new behavior for codecs. Now supports little endian RAWL format. It is now possible to encode directly little endian raw file, by simply using the rawl extension. Code has been modified to use strcasecmp instead of strncasecmp to cope with 4 letters files extensions.
Update issue 141
This commit is contained in:
parent
0c5fb4a81b
commit
bdb4d96678
|
@ -2802,8 +2802,7 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
|
||||||
RAW IMAGE FORMAT
|
RAW IMAGE FORMAT
|
||||||
|
|
||||||
<<-- <<-- <<-- <<-- */
|
<<-- <<-- <<-- <<-- */
|
||||||
|
static opj_image_t* rawtoimage_common(const char *filename, opj_cparameters_t *parameters, raw_cparameters_t *raw_cp, opj_bool big_endian) {
|
||||||
opj_image_t* rawtoimage(const char *filename, opj_cparameters_t *parameters, raw_cparameters_t *raw_cp) {
|
|
||||||
int subsampling_dx = parameters->subsampling_dx;
|
int subsampling_dx = parameters->subsampling_dx;
|
||||||
int subsampling_dy = parameters->subsampling_dy;
|
int subsampling_dy = parameters->subsampling_dy;
|
||||||
|
|
||||||
|
@ -2877,17 +2876,26 @@ opj_image_t* rawtoimage(const char *filename, opj_cparameters_t *parameters, raw
|
||||||
unsigned short value;
|
unsigned short value;
|
||||||
for(compno = 0; compno < numcomps; compno++) {
|
for(compno = 0; compno < numcomps; compno++) {
|
||||||
for (i = 0; i < w * h; i++) {
|
for (i = 0; i < w * h; i++) {
|
||||||
unsigned char temp;
|
unsigned char temp1;
|
||||||
if (!fread(&temp, 1, 1, f)) {
|
unsigned char temp2;
|
||||||
|
if (!fread(&temp1, 1, 1, f)) {
|
||||||
fprintf(stderr,"Error reading raw file. End of file probably reached.\n");
|
fprintf(stderr,"Error reading raw file. End of file probably reached.\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
value = temp << 8;
|
if (!fread(&temp2, 1, 1, f)) {
|
||||||
if (!fread(&temp, 1, 1, f)) {
|
|
||||||
fprintf(stderr,"Error reading raw file. End of file probably reached.\n");
|
fprintf(stderr,"Error reading raw file. End of file probably reached.\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
value += temp;
|
if( big_endian )
|
||||||
|
{
|
||||||
|
value = temp1 << 8;
|
||||||
|
value += temp2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
value = temp2 << 8;
|
||||||
|
value += temp1;
|
||||||
|
}
|
||||||
image->comps[compno].data[i] = raw_cp->rawSigned?(short)value:value;
|
image->comps[compno].data[i] = raw_cp->rawSigned?(short)value:value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2905,7 +2913,15 @@ opj_image_t* rawtoimage(const char *filename, opj_cparameters_t *parameters, raw
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
int imagetoraw(opj_image_t * image, const char *outfile)
|
opj_image_t* rawltoimage(const char *filename, opj_cparameters_t *parameters, raw_cparameters_t *raw_cp) {
|
||||||
|
return rawtoimage_common(filename, parameters, raw_cp, OPJ_FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
opj_image_t* rawtoimage(const char *filename, opj_cparameters_t *parameters, raw_cparameters_t *raw_cp) {
|
||||||
|
return rawtoimage_common(filename, parameters, raw_cp, OPJ_TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
int imagetoraw_common(opj_image_t * image, const char *outfile, opj_bool big_endian)
|
||||||
{
|
{
|
||||||
FILE *rawFile = NULL;
|
FILE *rawFile = NULL;
|
||||||
size_t res;
|
size_t res;
|
||||||
|
@ -2982,16 +2998,17 @@ int imagetoraw(opj_image_t * image, const char *outfile)
|
||||||
ptr = image->comps[compno].data;
|
ptr = image->comps[compno].data;
|
||||||
for (line = 0; line < h; line++) {
|
for (line = 0; line < h; line++) {
|
||||||
for(row = 0; row < w; row++) {
|
for(row = 0; row < w; row++) {
|
||||||
unsigned char temp;
|
unsigned char temp1;
|
||||||
|
unsigned char temp2;
|
||||||
curr = (signed short int) (*ptr & mask);
|
curr = (signed short int) (*ptr & mask);
|
||||||
temp = (unsigned char) (curr >> 8);
|
temp1 = (unsigned char) (curr >> 8);
|
||||||
res = fwrite(&temp, 1, 1, rawFile);
|
temp2 = (unsigned char) curr;
|
||||||
|
res = fwrite(&temp1, 1, 1, rawFile);
|
||||||
if( res < 1 ) {
|
if( res < 1 ) {
|
||||||
fprintf(stderr, "failed to write 1 byte for %s\n", outfile);
|
fprintf(stderr, "failed to write 1 byte for %s\n", outfile);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
temp = (unsigned char) curr;
|
res = fwrite(&temp2, 1, 1, rawFile);
|
||||||
res = fwrite(&temp, 1, 1, rawFile);
|
|
||||||
if( res < 1 ) {
|
if( res < 1 ) {
|
||||||
fprintf(stderr, "failed to write 1 byte for %s\n", outfile);
|
fprintf(stderr, "failed to write 1 byte for %s\n", outfile);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -3007,16 +3024,25 @@ int imagetoraw(opj_image_t * image, const char *outfile)
|
||||||
ptr = image->comps[compno].data;
|
ptr = image->comps[compno].data;
|
||||||
for (line = 0; line < h; line++) {
|
for (line = 0; line < h; line++) {
|
||||||
for(row = 0; row < w; row++) {
|
for(row = 0; row < w; row++) {
|
||||||
unsigned char temp;
|
unsigned char temp1;
|
||||||
|
unsigned char temp2;
|
||||||
curr = (unsigned short int) (*ptr & mask);
|
curr = (unsigned short int) (*ptr & mask);
|
||||||
temp = (unsigned char) (curr >> 8);
|
if( big_endian )
|
||||||
res = fwrite(&temp, 1, 1, rawFile);
|
{
|
||||||
|
temp1 = (unsigned char) (curr >> 8);
|
||||||
|
temp2 = (unsigned char) curr;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
temp2 = (unsigned char) (curr >> 8);
|
||||||
|
temp1 = (unsigned char) curr;
|
||||||
|
}
|
||||||
|
res = fwrite(&temp1, 1, 1, rawFile);
|
||||||
if( res < 1 ) {
|
if( res < 1 ) {
|
||||||
fprintf(stderr, "failed to write 1 byte for %s\n", outfile);
|
fprintf(stderr, "failed to write 1 byte for %s\n", outfile);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
temp = (unsigned char) curr;
|
res = fwrite(&temp2, 1, 1, rawFile);
|
||||||
res = fwrite(&temp, 1, 1, rawFile);
|
|
||||||
if( res < 1 ) {
|
if( res < 1 ) {
|
||||||
fprintf(stderr, "failed to write 1 byte for %s\n", outfile);
|
fprintf(stderr, "failed to write 1 byte for %s\n", outfile);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -3041,6 +3067,16 @@ int imagetoraw(opj_image_t * image, const char *outfile)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int imagetoraw(opj_image_t * image, const char *outfile)
|
||||||
|
{
|
||||||
|
return imagetoraw_common(image, outfile, OPJ_TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
int imagetorawl(opj_image_t * image, const char *outfile)
|
||||||
|
{
|
||||||
|
return imagetoraw_common(image, outfile, OPJ_FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HAVE_LIBPNG
|
#ifdef HAVE_LIBPNG
|
||||||
|
|
||||||
#define PNG_MAGIC "\x89PNG\x0d\x0a\x1a\x0a"
|
#define PNG_MAGIC "\x89PNG\x0d\x0a\x1a\x0a"
|
||||||
|
|
|
@ -72,7 +72,9 @@ int imagetopnm(opj_image_t *image, const char *outfile);
|
||||||
|
|
||||||
/* RAW conversion */
|
/* RAW conversion */
|
||||||
int imagetoraw(opj_image_t * image, const char *outfile);
|
int imagetoraw(opj_image_t * image, const char *outfile);
|
||||||
|
int imagetorawl(opj_image_t * image, const char *outfile);
|
||||||
opj_image_t* rawtoimage(const char *filename, opj_cparameters_t *parameters, raw_cparameters_t *raw_cp);
|
opj_image_t* rawtoimage(const char *filename, opj_cparameters_t *parameters, raw_cparameters_t *raw_cp);
|
||||||
|
opj_image_t* rawltoimage(const char *filename, opj_cparameters_t *parameters, raw_cparameters_t *raw_cp);
|
||||||
|
|
||||||
/* PNG conversion*/
|
/* PNG conversion*/
|
||||||
extern int imagetopng(opj_image_t *image, const char *write_idf);
|
extern int imagetopng(opj_image_t *image, const char *write_idf);
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include "windirent.h"
|
#include "windirent.h"
|
||||||
|
@ -44,10 +45,10 @@
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#define strcasecmp _stricmp
|
||||||
|
#define strncasecmp _strnicmp
|
||||||
#else
|
#else
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#define _stricmp strcasecmp
|
|
||||||
#define _strnicmp strncasecmp
|
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
#include "opj_config.h"
|
#include "opj_config.h"
|
||||||
|
@ -137,7 +138,7 @@ void encode_help_display(void) {
|
||||||
fprintf(stdout,"-OutFor \n");
|
fprintf(stdout,"-OutFor \n");
|
||||||
fprintf(stdout," REQUIRED only if -ImgDir is used\n");
|
fprintf(stdout," REQUIRED only if -ImgDir is used\n");
|
||||||
fprintf(stdout," Need to specify only format without filename <BMP> \n");
|
fprintf(stdout," Need to specify only format without filename <BMP> \n");
|
||||||
fprintf(stdout," Currently accepts PBM, PGM, PPM, PNM, PAM, PGX, PNG, BMP, TIF, RAW and TGA formats\n");
|
fprintf(stdout," Currently accepts PBM, PGM, PPM, PNM, PAM, PGX, PNG, BMP, TIF, RAW, RAWL and TGA formats\n");
|
||||||
fprintf(stdout,"\n");
|
fprintf(stdout,"\n");
|
||||||
fprintf(stdout,"-i : source file (-i source.pnm also *pbm, *.pgm, *.ppm, *.pam, *.pgx, *png, *.bmp, *.tif, *.raw, *.tga) \n");
|
fprintf(stdout,"-i : source file (-i source.pnm also *pbm, *.pgm, *.ppm, *.pam, *.pgx, *png, *.bmp, *.tif, *.raw, *.tga) \n");
|
||||||
fprintf(stdout," When using this option -o must be used\n");
|
fprintf(stdout," When using this option -o must be used\n");
|
||||||
|
@ -394,17 +395,17 @@ 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[] = {
|
static const char *extension[] = {
|
||||||
"pgx", "pnm", "pgm", "ppm", "pbm", "pam", "bmp", "tif", "raw", "tga", "png", "j2k", "jp2", "j2c", "jpc"
|
"pgx", "pnm", "pgm", "ppm", "pbm", "pam", "bmp", "tif", "raw", "rawl", "tga", "png", "j2k", "jp2", "j2c", "jpc"
|
||||||
};
|
};
|
||||||
static const int format[] = {
|
static const int format[] = {
|
||||||
PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT, TIF_DFMT, RAW_DFMT, TGA_DFMT, PNG_DFMT, J2K_CFMT, JP2_CFMT, J2K_CFMT, J2K_CFMT
|
PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT, TIF_DFMT, RAW_DFMT, RAWL_DFMT, TGA_DFMT, PNG_DFMT, J2K_CFMT, JP2_CFMT, J2K_CFMT, J2K_CFMT
|
||||||
};
|
};
|
||||||
char * ext = strrchr(filename, '.');
|
char * ext = strrchr(filename, '.');
|
||||||
if (ext == NULL)
|
if (ext == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
ext++;
|
ext++;
|
||||||
for(i = 0; i < sizeof(format)/sizeof(*format); i++) {
|
for(i = 0; i < sizeof(format)/sizeof(*format); i++) {
|
||||||
if(_strnicmp(ext, extension[i], 3) == 0) {
|
if(strcasecmp(ext, extension[i]) == 0) {
|
||||||
return format[i];
|
return format[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -621,6 +622,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
case BMP_DFMT:
|
case BMP_DFMT:
|
||||||
case TIF_DFMT:
|
case TIF_DFMT:
|
||||||
case RAW_DFMT:
|
case RAW_DFMT:
|
||||||
|
case RAWL_DFMT:
|
||||||
case TGA_DFMT:
|
case TGA_DFMT:
|
||||||
case PNG_DFMT:
|
case PNG_DFMT:
|
||||||
break;
|
break;
|
||||||
|
@ -1491,7 +1493,8 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parameters->decod_format == RAW_DFMT && raw_cp->rawWidth == 0) {
|
if ( (parameters->decod_format == RAW_DFMT && raw_cp->rawWidth == 0)
|
||||||
|
|| (parameters->decod_format == RAWL_DFMT && raw_cp->rawWidth == 0)) {
|
||||||
fprintf(stderr,"\nError: invalid raw image parameters\n");
|
fprintf(stderr,"\nError: invalid raw image parameters\n");
|
||||||
fprintf(stderr,"Please use the Format option -F:\n");
|
fprintf(stderr,"Please use the Format option -F:\n");
|
||||||
fprintf(stderr,"-F rawWidth,rawHeight,rawComp,rawBitDepth,s/u (Signed/Unsigned)\n");
|
fprintf(stderr,"-F rawWidth,rawHeight,rawComp,rawBitDepth,s/u (Signed/Unsigned)\n");
|
||||||
|
@ -1600,6 +1603,8 @@ int main(int argc, char **argv) {
|
||||||
dircnt_t *dirptr = NULL;
|
dircnt_t *dirptr = NULL;
|
||||||
|
|
||||||
opj_bool bSuccess;
|
opj_bool bSuccess;
|
||||||
|
opj_bool bUseTiles = OPJ_FALSE; /* OPJ_TRUE */
|
||||||
|
OPJ_UINT32 l_nb_tiles = 4;
|
||||||
|
|
||||||
/* set encoding parameters to default values */
|
/* set encoding parameters to default values */
|
||||||
opj_set_default_encoder_parameters(¶meters);
|
opj_set_default_encoder_parameters(¶meters);
|
||||||
|
@ -1683,6 +1688,7 @@ int main(int argc, char **argv) {
|
||||||
case TIF_DFMT:
|
case TIF_DFMT:
|
||||||
break;
|
break;
|
||||||
case RAW_DFMT:
|
case RAW_DFMT:
|
||||||
|
case RAWL_DFMT:
|
||||||
break;
|
break;
|
||||||
case TGA_DFMT:
|
case TGA_DFMT:
|
||||||
break;
|
break;
|
||||||
|
@ -1739,6 +1745,14 @@ int main(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case RAWL_DFMT:
|
||||||
|
image = rawltoimage(parameters.infile, ¶meters, &raw_cp);
|
||||||
|
if (!image) {
|
||||||
|
fprintf(stderr, "Unable to load raw file\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case TGA_DFMT:
|
case TGA_DFMT:
|
||||||
image = tgatoimage(parameters.infile, ¶meters);
|
image = tgatoimage(parameters.infile, ¶meters);
|
||||||
if (!image) {
|
if (!image) {
|
||||||
|
@ -1800,6 +1814,13 @@ int main(int argc, char **argv) {
|
||||||
opj_set_warning_handler(l_codec, warning_callback,00);
|
opj_set_warning_handler(l_codec, warning_callback,00);
|
||||||
opj_set_error_handler(l_codec, error_callback,00);
|
opj_set_error_handler(l_codec, error_callback,00);
|
||||||
|
|
||||||
|
if( bUseTiles ) {
|
||||||
|
parameters.cp_tx0 = 0;
|
||||||
|
parameters.cp_ty0 = 0;
|
||||||
|
parameters.tile_size_on = OPJ_TRUE;
|
||||||
|
parameters.cp_tdx = 512;
|
||||||
|
parameters.cp_tdy = 512;
|
||||||
|
}
|
||||||
opj_setup_encoder_v2(l_codec, ¶meters, image);
|
opj_setup_encoder_v2(l_codec, ¶meters, image);
|
||||||
|
|
||||||
/* Open the output file*/
|
/* Open the output file*/
|
||||||
|
@ -1821,9 +1842,29 @@ int main(int argc, char **argv) {
|
||||||
if (!bSuccess) {
|
if (!bSuccess) {
|
||||||
fprintf(stderr, "failed to encode image: opj_start_compress\n");
|
fprintf(stderr, "failed to encode image: opj_start_compress\n");
|
||||||
}
|
}
|
||||||
|
if( bUseTiles ) {
|
||||||
|
OPJ_BYTE *l_data;
|
||||||
|
OPJ_UINT32 l_data_size = 512*512*3;
|
||||||
|
l_data = (OPJ_BYTE*) malloc( l_data_size * sizeof(OPJ_BYTE));
|
||||||
|
memset(l_data, 0, l_data_size );
|
||||||
|
assert( l_data );
|
||||||
|
for (i=0;i<l_nb_tiles;++i) {
|
||||||
|
if (! opj_write_tile(l_codec,i,l_data,l_data_size,l_stream)) {
|
||||||
|
fprintf(stderr, "ERROR -> test_tile_encoder: failed to write the tile %d!\n",i);
|
||||||
|
opj_stream_destroy(l_stream);
|
||||||
|
fclose(fout);
|
||||||
|
opj_destroy_codec(l_codec);
|
||||||
|
opj_image_destroy(image);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free(l_data);
|
||||||
|
}
|
||||||
|
else {
|
||||||
bSuccess = bSuccess && opj_encode_v2(l_codec, l_stream);
|
bSuccess = bSuccess && opj_encode_v2(l_codec, l_stream);
|
||||||
if (!bSuccess) {
|
if (!bSuccess) {
|
||||||
fprintf(stderr, "failed to encode image: opj_encode_v2\n");
|
fprintf(stderr, "failed to encode image: opj_encode_v2\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
bSuccess = bSuccess && opj_end_compress(l_codec, l_stream);
|
bSuccess = bSuccess && opj_end_compress(l_codec, l_stream);
|
||||||
if (!bSuccess) {
|
if (!bSuccess) {
|
||||||
|
@ -1833,6 +1874,8 @@ int main(int argc, char **argv) {
|
||||||
if (!bSuccess) {
|
if (!bSuccess) {
|
||||||
opj_stream_destroy(l_stream);
|
opj_stream_destroy(l_stream);
|
||||||
fclose(fout);
|
fclose(fout);
|
||||||
|
opj_destroy_codec(l_codec);
|
||||||
|
opj_image_destroy(image);
|
||||||
fprintf(stderr, "failed to encode image\n");
|
fprintf(stderr, "failed to encode image\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,10 +44,10 @@
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#define strcasecmp _stricmp
|
||||||
|
#define strncasecmp _strnicmp
|
||||||
#else
|
#else
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#define _stricmp strcasecmp
|
|
||||||
#define _strnicmp strncasecmp
|
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
#include "openjpeg.h"
|
#include "openjpeg.h"
|
||||||
|
@ -214,15 +214,15 @@ int load_images(dircnt_t *dirptr, char *imgdirpath){
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
int get_file_format(const char *filename) {
|
int get_file_format(const char *filename) {
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
static const char *extension[] = {"pgx", "pnm", "pgm", "ppm", "bmp","tif", "raw", "tga", "png", "j2k", "jp2", "jpt", "j2c", "jpc" };
|
static const char *extension[] = {"pgx", "pnm", "pgm", "ppm", "bmp","tif", "raw", "rawl", "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, PNG_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, RAWL_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;
|
||||||
ext++;
|
ext++;
|
||||||
if(ext) {
|
if(ext) {
|
||||||
for(i = 0; i < sizeof(format)/sizeof(*format); i++) {
|
for(i = 0; i < sizeof(format)/sizeof(*format); i++) {
|
||||||
if(_strnicmp(ext, extension[i], 3) == 0) {
|
if(strcasecmp(ext, extension[i]) == 0) {
|
||||||
return format[i];
|
return format[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -379,6 +379,8 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
|
||||||
break;
|
break;
|
||||||
case RAW_DFMT:
|
case RAW_DFMT:
|
||||||
break;
|
break;
|
||||||
|
case RAWL_DFMT:
|
||||||
|
break;
|
||||||
case TGA_DFMT:
|
case TGA_DFMT:
|
||||||
break;
|
break;
|
||||||
case PNG_DFMT:
|
case PNG_DFMT:
|
||||||
|
@ -416,6 +418,9 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
|
||||||
case RAW_DFMT:
|
case RAW_DFMT:
|
||||||
img_fol->out_format = "raw";
|
img_fol->out_format = "raw";
|
||||||
break;
|
break;
|
||||||
|
case RAWL_DFMT:
|
||||||
|
img_fol->out_format = "rawl";
|
||||||
|
break;
|
||||||
case TGA_DFMT:
|
case TGA_DFMT:
|
||||||
img_fol->out_format = "raw";
|
img_fol->out_format = "raw";
|
||||||
break;
|
break;
|
||||||
|
@ -909,6 +914,15 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case RAWL_DFMT: /* RAWL */
|
||||||
|
if(imagetorawl(image, parameters.outfile)){
|
||||||
|
fprintf(stdout,"Error generating rawl file. Outfile %s not generated\n",parameters.outfile);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile);
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
|
|
@ -44,5 +44,6 @@
|
||||||
#define RAW_DFMT 15
|
#define RAW_DFMT 15
|
||||||
#define TGA_DFMT 16
|
#define TGA_DFMT 16
|
||||||
#define PNG_DFMT 17
|
#define PNG_DFMT 17
|
||||||
|
#define RAWL_DFMT 18
|
||||||
|
|
||||||
#endif /* _OPJ_FORMAT_DEFS_H_ */
|
#endif /* _OPJ_FORMAT_DEFS_H_ */
|
||||||
|
|
Loading…
Reference in New Issue