- memset(&cmptparm[0], 0, numcomps * sizeof(opj_image_cmptparm_t));
-
- for(i = 0; i < numcomps; i++)
- {
- cmptparm[i].prec = prec;
- cmptparm[i].bpp = prec;
- cmptparm[i].sgnd = 0;
- cmptparm[i].dx = subsampling_dx;
- cmptparm[i].dy = subsampling_dy;
- cmptparm[i].w = w;
- cmptparm[i].h = h;
- }
- image = opj_image_create(numcomps, &cmptparm[0], color_space);
-
- if(!image) { fclose(fp); return NULL; }
-
-/* set image offset and reference grid */
- image->x0 = parameters->image_offset_x0;
- image->y0 = parameters->image_offset_y0;
- image->x1 = parameters->image_offset_x0 + (w - 1) * subsampling_dx + 1;
- image->y1 = parameters->image_offset_y0 + (h - 1) * subsampling_dy + 1;
-
- if((format == 2) || (format == 3)) /* ascii pixmap */
- {
- unsigned int index;
-
- for (i = 0; i < w * h; i++)
- {
- for(compno = 0; compno < numcomps; compno++)
- {
- index = 0;
- if (fscanf(fp, "%u", &index) != 1)
- fprintf(stderr, "\nWARNING: fscanf return a number of element different from the expected.\n");
-
- image->comps[compno].data[i] = (index * 255)/header_info.maxval;
- }
- }
- }
- else
- if((format == 5)
- || (format == 6)
- ||((format == 7)
- && ( header_info.gray || header_info.graya
- || header_info.rgb || header_info.rgba)))/* binary pixmap */
- {
- unsigned char c0, c1, one;
-
- one = (prec < 9);
-
- for (i = 0; i < w * h; i++)
- {
- for(compno = 0; compno < numcomps; compno++)
- {
- if ( !fread(&c0, 1, 1, fp) )
- fprintf(stderr, "\nError: fread return a number of element different from the expected.\n");
- if(one)
- {
- image->comps[compno].data[i] = c0;
- }
- else
- {
- if ( !fread(&c1, 1, 1, fp) )
- fprintf(stderr, "\nError: fread return a number of element different from the expected.\n");
-/* netpbm: */
- image->comps[compno].data[i] = ((c0<<8) | c1);
- }
- }
- }
- }
- else
- if(format == 1) /* ascii bitmap */
- {
- for (i = 0; i < w * h; i++)
- {
- unsigned int index;
-
- if ( fscanf(fp, "%u", &index) != 1)
- fprintf(stderr, "\nWARNING: fscanf return a number of element different from the expected.\n");
-
- image->comps[0].data[i] = (index?0:255);
- }
- }
- else
- if(format == 4)
- {
- int x, y, bit;
- unsigned char uc;
-
- i = 0;
- for(y = 0; y < h; ++y)
- {
- bit = -1; uc = 0;
-
- for(x = 0; x < w; ++x)
- {
- if(bit == -1)
- {
- bit = 7;
- uc = (unsigned char)getc(fp);
- }
- image->comps[0].data[i] = (((uc>>bit) & 1)?0:255);
- --bit; ++i;
- }
- }
- }
- else
- if((format == 7 && header_info.bw)) /*MONO*/
- {
- unsigned char uc;
-
- for(i = 0; i < w * h; ++i)
- {
- if ( !fread(&uc, 1, 1, fp) )
- fprintf(stderr, "\nError: fread return a number of element different from the expected.\n");
- image->comps[0].data[i] = (uc & 1)?0:255;
- }
- }
- fclose(fp);
-
- return image;
-}/* pnmtoimage() */
-
-int imagetopnm(opj_image_t * image, const char *outfile)
-{
- int *red, *green, *blue, *alpha;
- int wr, hr, max;
- int i, compno, ncomp;
- int adjustR, adjustG, adjustB, adjustA;
- int fails, two, want_gray, has_alpha, triple;
- int prec, v;
- FILE *fdest = NULL;
- const char *tmp = outfile;
- char *destname;
- alpha = NULL;
- if((prec = image->comps[0].prec) > 16)
- {
- fprintf(stderr,"%s:%d:imagetopnm\n\tprecision %d is larger than 16"
- "\n\t: refused.\n",__FILE__,__LINE__,prec);
- return 1;
- }
- two = has_alpha = 0; fails = 1;
- ncomp = image->numcomps;
-
- while (*tmp) ++tmp; tmp -= 2;
- want_gray = (*tmp == 'g' || *tmp == 'G');
- ncomp = image->numcomps;
-
- if(want_gray) ncomp = 1;
-
- if (ncomp == 2 /* GRAYA */
- || (ncomp > 2 /* RGB, RGBA */
- && image->comps[0].dx == image->comps[1].dx
- && image->comps[1].dx == image->comps[2].dx
- && image->comps[0].dy == image->comps[1].dy
- && image->comps[1].dy == image->comps[2].dy
- && image->comps[0].prec == image->comps[1].prec
- && image->comps[1].prec == image->comps[2].prec
- ))
- {
- fdest = fopen(outfile, "wb");
-
- if (!fdest)
- {
- fprintf(stderr, "ERROR -> failed to open %s for writing\n", outfile);
- return fails;
- }
- two = (prec > 8);
- triple = (ncomp > 2);
- wr = image->comps[0].w; hr = image->comps[0].h;
- max = (1<<prec) - 1; has_alpha = (ncomp == 4 || ncomp == 2);
-
- red = image->comps[0].data;
-
- if(triple)
- {
- green = image->comps[1].data;
- blue = image->comps[2].data;
- }
- else green = blue = NULL;
-
- if(has_alpha)
- {
- const char *tt = (triple?"RGB_ALPHA":"GRAYSCALE_ALPHA");
-
- fprintf(fdest, "P7\n# OpenJPEG-%s\nWIDTH %d\nHEIGHT %d\nDEPTH %d\n"
- "MAXVAL %d\nTUPLTYPE %s\nENDHDR\n", opj_version(),
- wr, hr, ncomp, max, tt);
- alpha = image->comps[ncomp - 1].data;
- adjustA = (image->comps[ncomp - 1].sgnd ?
- 1 << (image->comps[ncomp - 1].prec - 1) : 0);
- }
- else
- {
- fprintf(fdest, "P6\n# OpenJPEG-%s\n%d %d\n%d\n",
- opj_version(), wr, hr, max);
- adjustA = 0;
- }
- adjustR = (image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0);
-
- if(triple)
- {
- adjustG = (image->comps[1].sgnd ? 1 << (image->comps[1].prec - 1) : 0);
- adjustB = (image->comps[2].sgnd ? 1 << (image->comps[2].prec - 1) : 0);
- }
- else adjustG = adjustB = 0;
-
- for(i = 0; i < wr * hr; ++i)
- {
- if(two)
- {
- v = *red + adjustR; ++red;
-/* netpbm: */
- fprintf(fdest, "%c%c",(unsigned char)(v>>8), (unsigned char)v);
-
- if(triple)
- {
- v = *green + adjustG; ++green;
-/* netpbm: */
- fprintf(fdest, "%c%c",(unsigned char)(v>>8), (unsigned char)v);
-
- v = *blue + adjustB; ++blue;
-/* netpbm: */
- fprintf(fdest, "%c%c",(unsigned char)(v>>8), (unsigned char)v);
-
- }/* if(triple) */
-
- if(has_alpha)
- {
- v = *alpha + adjustA; ++alpha;
-/* netpbm: */
- fprintf(fdest, "%c%c",(unsigned char)(v>>8), (unsigned char)v);
- }
- continue;
-
- } /* if(two) */
-
-/* prec <= 8: */
-
- fprintf(fdest, "%c", (unsigned char)*red++);
- if(triple)
- fprintf(fdest, "%c%c",(unsigned char)*green++, (unsigned char)*blue++);
-
- if(has_alpha)
- fprintf(fdest, "%c", (unsigned char)*alpha++);
-
- } /* for(i */
-
- fclose(fdest); return 0;
- }
-
-/* YUV or MONO: */
-
- if (image->numcomps > ncomp)
- {
- fprintf(stderr,"WARNING -> [PGM file] Only the first component\n");
- fprintf(stderr," is written to the file\n");
- }
- destname = (char*)malloc(strlen(outfile) + 8);
-
- for (compno = 0; compno < ncomp; compno++)
- {
- if (ncomp > 1)
- sprintf(destname, "%d.%s", compno, outfile);
- else
- sprintf(destname, "%s", outfile);
-
- fdest = fopen(destname, "wb");
- if (!fdest)
- {
- fprintf(stderr, "ERROR -> failed to open %s for writing\n", destname);
- free(destname);
- return 1;
- }
- wr = image->comps[compno].w; hr = image->comps[compno].h;
- prec = image->comps[compno].prec;
- max = (1<<prec) - 1;
-
- fprintf(fdest, "P5\n#OpenJPEG-%s\n%d %d\n%d\n",
- opj_version(), wr, hr, max);
-
- red = image->comps[compno].data;
- adjustR =
- (image->comps[compno].sgnd ? 1 << (image->comps[compno].prec - 1) : 0);
-
- if(prec > 8)
- {
- for (i = 0; i < wr * hr; i++)
- {
- v = *red + adjustR; ++red;
-/* netpbm: */
- fprintf(fdest, "%c%c",(unsigned char)(v>>8), (unsigned char)v);
-
- if(has_alpha)
- {
- v = *alpha++;
-/* netpbm: */
- fprintf(fdest, "%c%c",(unsigned char)(v>>8), (unsigned char)v);
- }
- }/* for(i */
- }
- else /* prec <= 8 */
- {
- for(i = 0; i < wr * hr; ++i)
- {
- fprintf(fdest, "%c", (unsigned char)(*red + adjustR)); ++red;
- }
- }
- fclose(fdest);
- } /* for (compno */
- free(destname);
-
- return 0;
-}/* imagetopnm() */
-
-#ifdef HAVE_LIBTIFF
-/* -->> -->> -->> -->>
-
- TIFF IMAGE FORMAT
-
- <<-- <<-- <<-- <<-- */
-
-int imagetotif(opj_image_t * image, const char *outfile)
-{
- int width, height, imgsize;
- int bps,index,adjust, sgnd;
- int ushift, dshift, has_alpha, force16;
- TIFF *tif;
- tdata_t buf;
- tstrip_t strip;
- tsize_t strip_size;
-
- ushift = dshift = force16 = has_alpha = 0;
- bps = image->comps[0].prec;
-
- if(bps > 8 && bps < 16)
- {
- ushift = 16 - bps; dshift = bps - ushift;
- bps = 16; force16 = 1;
- }
-
- if(bps != 8 && bps != 16)
- {
- fprintf(stderr,"imagetotif: Bits=%d, Only 8 and 16 bits implemented\n",
- bps);
- fprintf(stderr,"\tAborting\n");
- return 1;
- }
- tif = TIFFOpen(outfile, "wb");
-
- if (!tif)
- {
- fprintf(stderr, "imagetotif:failed to open %s for writing\n", outfile);
- return 1;
- }
- sgnd = image->comps[0].sgnd;
- adjust = sgnd ? 1 << (image->comps[0].prec - 1) : 0;
-
- if(image->numcomps >= 3
- && image->comps[0].dx == image->comps[1].dx
- && image->comps[1].dx == image->comps[2].dx
- && image->comps[0].dy == image->comps[1].dy
- && image->comps[1].dy == image->comps[2].dy
- && image->comps[0].prec == image->comps[1].prec
- && image->comps[1].prec == image->comps[2].prec)
- {
- has_alpha = (image->numcomps == 4);
-
- width = image->comps[0].w;
- height = image->comps[0].h;
- imgsize = width * height ;
-
- TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width);
- TIFFSetField(tif, TIFFTAG_IMAGELENGTH, height);
- TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 3 + has_alpha);
- TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bps);
- TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
- TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
- TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
- TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, 1);
- strip_size = TIFFStripSize(tif);
- buf = _TIFFmalloc(strip_size);
- index=0;
-
- for(strip = 0; strip < TIFFNumberOfStrips(tif); strip++)
- {
- unsigned char *dat8;
- tsize_t i, ssize, last_i = 0;
- int step, restx;
- ssize = TIFFStripSize(tif);
- dat8 = (unsigned char*)buf;
-
- if(bps == 8)
- {
- step = 3 + has_alpha;
- restx = step - 1;
-
- for(i=0; i < ssize - restx; i += step)
- {
- int r, g, b, a = 0;
-
- if(index < imgsize)
- {
- r = image->comps[0].data[index];
- g = image->comps[1].data[index];
- b = image->comps[2].data[index];
- if(has_alpha) a = image->comps[3].data[index];
-
- if(sgnd)
- {
- r += adjust;
- g += adjust;
- b += adjust;
- if(has_alpha) a += adjust;
- }
- dat8[i+0] = r ;
- dat8[i+1] = g ;
- dat8[i+2] = b ;
- if(has_alpha) dat8[i+3] = a;
-
- index++;
- last_i = i + step;
- }
- else
- break;
- }/*for(i = 0;)*/
-
- if(last_i < ssize)
- {
- for(i = last_i; i < ssize; i += step)
- {
- int r, g, b, a = 0;
-
- if(index < imgsize)
- {
- r = image->comps[0].data[index];
- g = image->comps[1].data[index];
- b = image->comps[2].data[index];
- if(has_alpha) a = image->comps[3].data[index];
-
- if(sgnd)
- {
- r += adjust;
- g += adjust;
- b += adjust;
- if(has_alpha) a += adjust;
- }
- dat8[i+0] = r ;
- if(i+1 < ssize) dat8[i+1] = g ; else break;
- if(i+2 < ssize) dat8[i+2] = b ; else break;
- if(has_alpha)
- {
- if(i+3 < ssize) dat8[i+3] = a ; else break;
- }
- index++;
- }
- else
- break;
- }/*for(i)*/
- }/*if(last_i < ssize)*/
-
- } /*if(bps == 8)*/
- else
- if(bps == 16)
- {
- step = 6 + has_alpha + has_alpha;
- restx = step - 1;
-
- for(i = 0; i < ssize - restx ; i += step)
- {
- int r, g, b, a = 0;
-
- if(index < imgsize)
- {
- r = image->comps[0].data[index];
- g = image->comps[1].data[index];
- b = image->comps[2].data[index];
- if(has_alpha) a = image->comps[3].data[index];
-
- if(sgnd)
- {
- r += adjust;
- g += adjust;
- b += adjust;
- if(has_alpha) a += adjust;
- }
- if(force16)
- {
- r = (r<<ushift) + (r>>dshift);
- g = (g<<ushift) + (g>>dshift);
- b = (b<<ushift) + (b>>dshift);
- if(has_alpha) a = (a<<ushift) + (a>>dshift);
- }
- dat8[i+0] = r;/*LSB*/
- dat8[i+1] = (r >> 8);/*MSB*/
- dat8[i+2] = g;
- dat8[i+3] = (g >> 8);
- dat8[i+4] = b;
- dat8[i+5] = (b >> 8);
- if(has_alpha)
- {
- dat8[i+6] = a;
- dat8[i+7] = (a >> 8);
- }
- index++;
- last_i = i + step;
- }
- else
- break;
- }/*for(i = 0;)*/
-
- if(last_i < ssize)
- {
- for(i = last_i ; i < ssize ; i += step)
- {
- int r, g, b, a = 0;
-
- if(index < imgsize)
- {
- r = image->comps[0].data[index];
- g = image->comps[1].data[index];
- b = image->comps[2].data[index];
- if(has_alpha) a = image->comps[3].data[index];
-
- if(sgnd)
- {
- r += adjust;
- g += adjust;
- b += adjust;
- if(has_alpha) a += adjust;
- }
- if(force16)
- {
- r = (r<<ushift) + (r>>dshift);
- g = (g<<ushift) + (g>>dshift);
- b = (b<<ushift) + (b>>dshift);
- if(has_alpha) a = (a<<ushift) + (a>>dshift);
- }
- dat8[i+0] = r;/*LSB*/
- if(i+1 < ssize) dat8[i+1] = (r >> 8);else break;/*MSB*/
- if(i+2 < ssize) dat8[i+2] = g; else break;
- if(i+3 < ssize) dat8[i+3] = (g >> 8);else break;
- if(i+4 < ssize) dat8[i+4] = b; else break;
- if(i+5 < ssize) dat8[i+5] = (b >> 8);else break;
-
- if(has_alpha)
- {
- if(i+6 < ssize) dat8[i+6] = a; else break;
- if(i+7 < ssize) dat8[i+7] = (a >> 8); else break;
- }
- index++;
- }
- else
- break;
- }/*for(i)*/
- }/*if(last_i < ssize)*/
-
- }/*if(bps == 16)*/
- (void)TIFFWriteEncodedStrip(tif, strip, (void*)buf, strip_size);
- }/*for(strip = 0; )*/
-
- _TIFFfree((void*)buf);
- TIFFClose(tif);
-
- return 0;
- }/*RGB(A)*/
-
- if(image->numcomps == 1 /* GRAY */
- || ( image->numcomps == 2 /* GRAY_ALPHA */
- && image->comps[0].dx == image->comps[1].dx
- && image->comps[0].dy == image->comps[1].dy
- && image->comps[0].prec == image->comps[1].prec))
- {
- int step;
-
- has_alpha = (image->numcomps == 2);
-
- width = image->comps[0].w;
- height = image->comps[0].h;
- imgsize = width * height;
-
-/* Set tags */
- TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width);
- TIFFSetField(tif, TIFFTAG_IMAGELENGTH, height);
- TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1 + has_alpha);
- TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bps);
- TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
- TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
- TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
- TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, 1);
-
-/* Get a buffer for the data */
- strip_size = TIFFStripSize(tif);
- buf = _TIFFmalloc(strip_size);
- index = 0;
-
- for(strip = 0; strip < TIFFNumberOfStrips(tif); strip++)
- {
- unsigned char *dat8;
- tsize_t i, ssize = TIFFStripSize(tif);
- dat8 = (unsigned char*)buf;
-
- if(bps == 8)
- {
- step = 1 + has_alpha;
-
- for(i=0; i < ssize; i += step)
- {
- if(index < imgsize)
- {
- int r, a = 0;
-
- r = image->comps[0].data[index];
- if(has_alpha) a = image->comps[1].data[index];
-
- if(sgnd)
- {
- r += adjust;
- if(has_alpha) a += adjust;
- }
- dat8[i+0] = r;
- if(has_alpha) dat8[i+1] = a;
- index++;
- }
- else
- break;
- }/*for(i )*/
- }/*if(bps == 8*/
- else
- if(bps == 16)
- {
- step = 2 + has_alpha + has_alpha;
-
- for(i=0; i < ssize; i += step)
- {
- if(index < imgsize)
- {
- int r, a = 0;
-
- r = image->comps[0].data[index];
- if(has_alpha) a = image->comps[1].data[index];
-
- if(sgnd)
- {
- r += adjust;
- if(has_alpha) a += adjust;
- }
- if(force16)
- {
- r = (r<<ushift) + (r>>dshift);
- if(has_alpha) a = (a<<ushift) + (a>>dshift);
- }
- dat8[i+0] = r;/*LSB*/
- dat8[i+1] = r >> 8;/*MSB*/
- if(has_alpha)
- {
- dat8[i+2] = a;
- dat8[i+3] = a >> 8;
- }
- index++;
- }/*if(index < imgsize)*/
- else
- break;
- }/*for(i )*/
- }
- (void)TIFFWriteEncodedStrip(tif, strip, (void*)buf, strip_size);
- }/*for(strip*/
-
- _TIFFfree(buf);
- TIFFClose(tif);
-
- return 0;
- }
-
- TIFFClose(tif);
-
- fprintf(stderr,"imagetotif: Bad color format.\n"
- "\tOnly RGB(A) and GRAY(A) has been implemented\n");
- fprintf(stderr,"\tFOUND: numcomps(%d)\n\tAborting\n",
- image->numcomps);
-
- return 1;
-}/* imagetotif() */
-
-/*
- * libtiff/tif_getimage.c : 1,2,4,8,16 bitspersample accepted
- * CINEMA : 12 bit precision
-*/
-opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
-{
- int subsampling_dx = parameters->subsampling_dx;
- int subsampling_dy = parameters->subsampling_dy;
- TIFF *tif;
- tdata_t buf;
- tstrip_t strip;
- tsize_t strip_size;
- int j, numcomps, w, h,index;
- OPJ_COLOR_SPACE color_space;
- opj_image_cmptparm_t cmptparm[4]; /* RGBA */
- opj_image_t *image = NULL;
- int imgsize = 0;
- int has_alpha = 0;
- unsigned short tiBps, tiPhoto, tiSf, tiSpp, tiPC;
- unsigned int tiWidth, tiHeight;
-
- tif = TIFFOpen(filename, "r");
-
- if(!tif)
- {
- fprintf(stderr, "tiftoimage:Failed to open %s for reading\n", filename);
- return 0;
- }
- tiBps = tiPhoto = tiSf = tiSpp = tiPC = 0;
- tiWidth = tiHeight = 0;
-
- TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &tiWidth);
- TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &tiHeight);
- TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &tiBps);
- TIFFGetField(tif, TIFFTAG_SAMPLEFORMAT, &tiSf);
- TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &tiSpp);
- TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &tiPhoto);
- TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &tiPC);
- w= tiWidth;
- h= tiHeight;
-
- if(tiBps != 8 && tiBps != 16 && tiBps != 12) tiBps = 0;
- if(tiPhoto != 1 && tiPhoto != 2) tiPhoto = 0;
-
- if( !tiBps || !tiPhoto)
- {
- if( !tiBps)
- fprintf(stderr,"imagetotif: Bits=%d, Only 8 and 16 bits"
- " implemented\n",tiBps);
- else
- if( !tiPhoto)
- fprintf(stderr,"tiftoimage: Bad color format %d.\n\tOnly RGB(A)"
- " and GRAY(A) has been implemented\n",(int) tiPhoto);
-
- fprintf(stderr,"\tAborting\n");
- TIFFClose(tif);
-
- return NULL;
- }
-
- {/* From: tiff-4.0.x/libtiff/tif_getimage.c : */
- uint16* sampleinfo;
- uint16 extrasamples;
-
- TIFFGetFieldDefaulted(tif, TIFFTAG_EXTRASAMPLES,
- &extrasamples, &sampleinfo);
-
- if(extrasamples >= 1)
- {
- switch(sampleinfo[0])
- {
- case EXTRASAMPLE_UNSPECIFIED:
-/* Workaround for some images without correct info about alpha channel
-*/
- if(tiSpp > 3)
- has_alpha = 1;
- break;
-
- case EXTRASAMPLE_ASSOCALPHA: /* data pre-multiplied */
- case EXTRASAMPLE_UNASSALPHA: /* data not pre-multiplied */
- has_alpha = 1;
- break;
- }
- }
- else /* extrasamples == 0 */
- if(tiSpp == 4 || tiSpp == 2) has_alpha = 1;
- }
-
-/* initialize image components
-*/
- memset(&cmptparm[0], 0, 4 * sizeof(opj_image_cmptparm_t));
-
- if(tiPhoto == PHOTOMETRIC_RGB) /* RGB(A) */
- {
- numcomps = 3 + has_alpha;
- color_space = OPJ_CLRSPC_SRGB;
-
-/*#define USETILEMODE*/
- for(j = 0; j < numcomps; j++)
- {
- if(parameters->cp_cinema)
- {
- cmptparm[j].prec = 12;
- cmptparm[j].bpp = 12;
- }
- else
- {
- cmptparm[j].prec = tiBps;
- cmptparm[j].bpp = tiBps;
- }
- cmptparm[j].dx = subsampling_dx;
- cmptparm[j].dy = subsampling_dy;
- cmptparm[j].w = w;
- cmptparm[j].h = h;
-#ifdef USETILEMODE
- cmptparm[j].x0 = 0;
- cmptparm[j].y0 = 0;
-#endif
- }
-
-#ifdef USETILEMODE
- image = opj_image_tile_create(numcomps,&cmptparm[0],color_space);
-#else
- image = opj_image_create(numcomps, &cmptparm[0], color_space);
-#endif