Add flviewer and cmyk, cielab and esycc
This commit is contained in:
parent
75a33de3bc
commit
3007184c91
|
@ -253,6 +253,20 @@ mark_as_advanced(BUILD_VIEWER)
|
|||
mark_as_advanced(BUILD_JAVA)
|
||||
mark_as_advanced(BUILD_JP3D)
|
||||
|
||||
option(BUILD_FLVIEWER "Build the flviewer executable (C++)" OFF)
|
||||
option(BUILD_FLVIEWER_WITH_SHARED_LIBS "Build the flviewer with shared libraries" OFF)
|
||||
option(BUILD_FLVIEWER_WITH_JPWL_LIB "Build the flviewer with JPWL library" OFF)
|
||||
option(FLTK_SKIP_OPENGL "Build flviewer without OPENGL support" ON)
|
||||
option(BUILD_WITH_GERMAN "Build flviewer with GERMAN language" OFF)
|
||||
if(FLTK_SKIP_OPENGL)
|
||||
SET(FLTK_GL_LIBRARY "")
|
||||
endif()
|
||||
mark_as_advanced(BUILD_FLVIEWER)
|
||||
mark_as_advanced(BUILD_FLVIEWER_WITH_SHARED_LIBS)
|
||||
mark_as_advanced(BUILD_FLVIEWER_WITH_JPWL_LIB)
|
||||
mark_as_advanced(FLTK_SKIP_OPENGL)
|
||||
mark_as_advanced(BUILD_WITH_GERMAN)
|
||||
|
||||
if(BUILD_CODEC OR BUILD_MJ2)
|
||||
# OFF: It will only build 3rd party libs if they are not found on the system
|
||||
# ON: 3rd party libs will ALWAYS be build, and used
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
**If you want to use 'flviewer' for LINUX, APPLE, MS-WINDOWS:**
|
||||
|
||||
01. Download the FLTK library from
|
||||
|
||||
http://www.fltk.org
|
||||
|
||||
e.g. fltk-1.3.x-r10813.tar.bz2
|
||||
and expand it.
|
||||
|
||||
02. For versions < r10813 MANUALLY uncomment in
|
||||
|
||||
FL/Enumerations.H
|
||||
|
||||
the line
|
||||
|
||||
//#define FL_ABI_VERSION 10304
|
||||
|
||||
If you do not
|
||||
|
||||
#define FL_ABI_VERSION 10304
|
||||
|
||||
the horizontal BAR is not activated.
|
||||
|
||||
03. For versions >= r10813, you can do:
|
||||
|
||||
either: configure --abi-version=10304
|
||||
or : cmake -DFL_ABI_VERSION:string="10304"
|
||||
|
||||
04. MS-WINDOWS may need in-source configuration/compilation.
|
||||
MS-WINDOWS out-source configuration/compilation may need
|
||||
'-DOPTION_BUILD_EXAMPLES:bool=off'.
|
||||
|
||||
04. Compile and install the FLTK library.
|
||||
|
||||
06. For FLVIEWER, CMAKE arguments for the OPENJPEG library may be:
|
||||
|
||||
-DBUILD_SHARED_LIBS:bool=on
|
||||
-DBUILD_FLVIEWER:bool=on
|
||||
-DBUILD_FLVIEWER_WITH_SHARED_LIBS:bool=on
|
||||
-DFLTK_SKIP_OPENGL:bool=on
|
||||
-DBUILD_WITH_GERMAN:bool=off
|
||||
|
||||
07. Compile the OPENJPEG library.
|
||||
|
||||
08. Call 'bin/flviewer --version'.
|
||||
|
||||
09. Call 'bin/flviewer' to test the application.
|
||||
|
||||
10. Some files with a large number of SOP markers, e.g.
|
||||
|
||||
'openjpeg-data/input/conformance/p0_07.j2k'
|
||||
|
||||
with 256 tiles, may need some time. On my computer about 2 minutes.
|
||||
The SOP markers are therefore ON only on demand (read_jpeg2000.cxx).
|
||||
|
||||
11. The FLVIEWER menu has some buttons, inputs and outputs:
|
||||
|
||||
Tracks, Frames, Threads : for MJ2
|
||||
Stop, Go on, Restart, Close, <-Step, Step-> : for MJ2, JPX, JPM
|
||||
Tile, Reduction and Area : for JP2/J2K, JPM, JPX
|
||||
Section and Browse : for all file types
|
||||
Layer and Component : for resp. files
|
||||
|
||||
To use 'Section':
|
||||
Push the left mouse button and draw a rectangle
|
||||
Press 'Section'
|
||||
To remove the rectangle, click into the main window
|
||||
|
||||
In the section window use the right mouse button to select an action.
|
||||
|
||||
Only one section window can be open.
|
||||
|
||||
Use the right mouse button to close the section window.
|
||||
|
||||
If you handle an animation of type MJ2 you must first press
|
||||
the 'Stop' button to stop the movie before you can get a section.
|
||||
|
||||
12. Install the OPENJPEG library together with FLVIEWER.
|
||||
|
||||
13. JPM and JPX files can be found on:
|
||||
|
||||
http://home.arcor.de
|
||||
|
||||
or (possibly) on
|
||||
|
||||
https://share.openanalytics.eu/data/public/76cb6a.php
|
||||
https://share.openanalytics.eu/data/public/1e7708.php
|
||||
|
|
@ -16,6 +16,10 @@ endif()
|
|||
if(BUILD_JP3D)
|
||||
add_subdirectory(jp3d)
|
||||
endif()
|
||||
|
||||
if(BUILD_VIEWER)
|
||||
# wx apps:
|
||||
add_subdirectory(wx)
|
||||
add_subdirectory(wx)
|
||||
endif()
|
||||
if(BUILD_FLVIEWER)
|
||||
add_subdirectory(fltk)
|
||||
endif()
|
||||
|
|
|
@ -94,6 +94,14 @@ static void sycc444_to_rgb(opj_image_t *img)
|
|||
unsigned int maxw, maxh, max, i;
|
||||
int offset, upb;
|
||||
|
||||
d0 = r = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
d1 = g = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
d2 = b = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
|
||||
if(d0 == NULL || d1 == NULL || d2 == NULL)
|
||||
{
|
||||
goto fails;
|
||||
}
|
||||
upb = (int)img->comps[0].prec;
|
||||
offset = 1<<(upb - 1); upb = (1<<upb)-1;
|
||||
|
||||
|
@ -104,10 +112,6 @@ static void sycc444_to_rgb(opj_image_t *img)
|
|||
cb = img->comps[1].data;
|
||||
cr = img->comps[2].data;
|
||||
|
||||
d0 = r = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
d1 = g = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
d2 = b = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
|
||||
for(i = 0U; i < max; ++i)
|
||||
{
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||
|
@ -116,6 +120,12 @@ static void sycc444_to_rgb(opj_image_t *img)
|
|||
free(img->comps[0].data); img->comps[0].data = d0;
|
||||
free(img->comps[1].data); img->comps[1].data = d1;
|
||||
free(img->comps[2].data); img->comps[2].data = d2;
|
||||
return;
|
||||
|
||||
fails:
|
||||
if(d0) free(d0);
|
||||
if(d1) free(d1);
|
||||
fprintf(stderr,"color.c:%d:\n\tmemory out\n",__LINE__);
|
||||
|
||||
}/* sycc444_to_rgb() */
|
||||
|
||||
|
@ -127,6 +137,14 @@ static void sycc422_to_rgb(opj_image_t *img)
|
|||
int offset, upb;
|
||||
unsigned int i, j;
|
||||
|
||||
d0 = r = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
d1 = g = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
d2 = b = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
|
||||
if(d0 == NULL || d1 == NULL || d2 == NULL)
|
||||
{
|
||||
goto fails;
|
||||
}
|
||||
upb = (int)img->comps[0].prec;
|
||||
offset = 1<<(upb - 1); upb = (1<<upb)-1;
|
||||
|
||||
|
@ -137,10 +155,6 @@ static void sycc422_to_rgb(opj_image_t *img)
|
|||
cb = img->comps[1].data;
|
||||
cr = img->comps[2].data;
|
||||
|
||||
d0 = r = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
d1 = g = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
d2 = b = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
|
||||
for(i=0U; i < maxh; ++i)
|
||||
{
|
||||
for(j=0U; j < (maxw & ~(unsigned int)1U); j += 2U)
|
||||
|
@ -170,7 +184,13 @@ static void sycc422_to_rgb(opj_image_t *img)
|
|||
img->comps[2].dx = img->comps[0].dx;
|
||||
img->comps[1].dy = img->comps[0].dy;
|
||||
img->comps[2].dy = img->comps[0].dy;
|
||||
return;
|
||||
|
||||
fails:
|
||||
if(d0) free(d0);
|
||||
if(d1) free(d1);
|
||||
fprintf(stderr,"color.c:%d:\n\tmemory out\n",__LINE__);
|
||||
return;
|
||||
}/* sycc422_to_rgb() */
|
||||
|
||||
static void sycc420_to_rgb(opj_image_t *img)
|
||||
|
@ -181,6 +201,14 @@ static void sycc420_to_rgb(opj_image_t *img)
|
|||
int offset, upb;
|
||||
unsigned int i, j;
|
||||
|
||||
d0 = r = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
d1 = g = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
d2 = b = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
|
||||
if(d0 == NULL || d1 == NULL || d2 == NULL)
|
||||
{
|
||||
goto fails;
|
||||
}
|
||||
upb = (int)img->comps[0].prec;
|
||||
offset = 1<<(upb - 1); upb = (1<<upb)-1;
|
||||
|
||||
|
@ -191,10 +219,6 @@ static void sycc420_to_rgb(opj_image_t *img)
|
|||
cb = img->comps[1].data;
|
||||
cr = img->comps[2].data;
|
||||
|
||||
d0 = r = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
d1 = g = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
d2 = b = (int*)malloc(sizeof(int) * (size_t)max);
|
||||
|
||||
for(i=0U; i < (maxh & ~(unsigned int)1U); i += 2U)
|
||||
{
|
||||
ny = y + maxw;
|
||||
|
@ -255,7 +279,13 @@ static void sycc420_to_rgb(opj_image_t *img)
|
|||
img->comps[2].dx = img->comps[0].dx;
|
||||
img->comps[1].dy = img->comps[0].dy;
|
||||
img->comps[2].dy = img->comps[0].dy;
|
||||
return;
|
||||
|
||||
fails:
|
||||
if(d0) free(d0);
|
||||
if(d1) free(d1);
|
||||
fprintf(stderr,"color.c:%d:\n\tmemory out\n",__LINE__);
|
||||
return;
|
||||
}/* sycc420_to_rgb() */
|
||||
|
||||
void color_sycc_to_rgb(opj_image_t *img)
|
||||
|
@ -329,7 +359,7 @@ void color_apply_icc_profile(opj_image_t *image)
|
|||
cmsColorSpaceSignature in_space, out_space;
|
||||
cmsUInt32Number intent, in_type, out_type, nr_samples;
|
||||
int *r, *g, *b;
|
||||
int prec, i, max, max_w, max_h;
|
||||
int prec, i, max, max_w, max_h, ok = 0;
|
||||
OPJ_COLOR_SPACE oldspace;
|
||||
|
||||
in_prof =
|
||||
|
@ -392,6 +422,9 @@ __FILE__,__LINE__,out_space,
|
|||
(out_space>>24) & 0xff,(out_space>>16) & 0xff,
|
||||
(out_space>>8) & 0xff, out_space & 0xff);
|
||||
#endif
|
||||
image->color_space = oldspace;
|
||||
cmsCloseProfile(in_prof);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -419,6 +452,14 @@ in_type,out_type
|
|||
(void)in_space;
|
||||
#endif /* DEBUG_PROFILE */
|
||||
|
||||
if(out_prof == NULL)
|
||||
{
|
||||
image->color_space = oldspace;
|
||||
cmsCloseProfile(in_prof);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
transform = cmsCreateTransform(in_prof, in_type,
|
||||
out_prof, out_type, intent, 0);
|
||||
|
||||
|
@ -452,6 +493,10 @@ fprintf(stderr,"%s:%d:color_apply_icc_profile\n\tcmsCreateTransform failed. "
|
|||
in = inbuf = (unsigned char*)malloc(nr_samples);
|
||||
out = outbuf = (unsigned char*)malloc(nr_samples);
|
||||
|
||||
if(inbuf == NULL || outbuf == NULL)
|
||||
{
|
||||
goto fails0;
|
||||
}
|
||||
r = image->comps[0].data;
|
||||
g = image->comps[1].data;
|
||||
b = image->comps[2].data;
|
||||
|
@ -475,7 +520,16 @@ fprintf(stderr,"%s:%d:color_apply_icc_profile\n\tcmsCreateTransform failed. "
|
|||
*g++ = (int)*out++;
|
||||
*b++ = (int)*out++;
|
||||
}
|
||||
free(inbuf); free(outbuf);
|
||||
ok = 1;
|
||||
|
||||
fails0:
|
||||
if(inbuf != NULL) free(inbuf);
|
||||
if(outbuf != NULL) free(outbuf);
|
||||
|
||||
if(ok == 0)
|
||||
{
|
||||
fprintf(stderr,"color.c:%d:\n\tmemory out\n",__LINE__);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -485,6 +539,10 @@ else
|
|||
in = inbuf = (unsigned short*)malloc(nr_samples);
|
||||
out = outbuf = (unsigned short*)malloc(nr_samples);
|
||||
|
||||
if(inbuf == NULL || outbuf == NULL)
|
||||
{
|
||||
goto fails1;
|
||||
}
|
||||
r = image->comps[0].data;
|
||||
g = image->comps[1].data;
|
||||
b = image->comps[2].data;
|
||||
|
@ -508,19 +566,44 @@ else
|
|||
*g++ = (int)*out++;
|
||||
*b++ = (int)*out++;
|
||||
}
|
||||
free(inbuf); free(outbuf);
|
||||
ok = 1;
|
||||
|
||||
fails1:
|
||||
if(inbuf) free(inbuf);
|
||||
if(outbuf) free(outbuf);
|
||||
|
||||
if(ok == 0)
|
||||
{
|
||||
fprintf(stderr,"color.c:%d:\n\tmemory out\n",__LINE__);
|
||||
}
|
||||
}
|
||||
}
|
||||
else /* GRAY, GRAYA */
|
||||
{
|
||||
opj_image_comp_t*comps = NULL;
|
||||
unsigned char *in, *inbuf, *out, *outbuf;
|
||||
int *d1, *d2;
|
||||
max = max_w * max_h;
|
||||
nr_samples = (cmsUInt32Number)max * 3 * sizeof(unsigned char);
|
||||
in = inbuf = (unsigned char*)malloc(nr_samples);
|
||||
out = outbuf = (unsigned char*)malloc(nr_samples);
|
||||
|
||||
image->comps = (opj_image_comp_t*)
|
||||
realloc(image->comps, (image->numcomps+2)*sizeof(opj_image_comp_t));
|
||||
d1 = (int*)calloc((size_t)max, sizeof(int));
|
||||
d2 = (int*)calloc((size_t)max, sizeof(int));
|
||||
|
||||
if(inbuf == NULL || outbuf == NULL | d1 == NULL || d2 == NULL)
|
||||
{
|
||||
goto fails2;
|
||||
}
|
||||
comps = image->comps;
|
||||
comps = (opj_image_comp_t*)
|
||||
realloc(comps, (image->numcomps+2)*sizeof(opj_image_comp_t));
|
||||
|
||||
if(comps == NULL)
|
||||
{
|
||||
goto fails2;
|
||||
}
|
||||
image->comps = comps;
|
||||
|
||||
if(image->numcomps == 2)
|
||||
image->comps[3] = image->comps[1];
|
||||
|
@ -528,8 +611,8 @@ else
|
|||
image->comps[1] = image->comps[0];
|
||||
image->comps[2] = image->comps[0];
|
||||
|
||||
image->comps[1].data = (int*)calloc((size_t)max, sizeof(int));
|
||||
image->comps[2].data = (int*)calloc((size_t)max, sizeof(int));
|
||||
image->comps[1].data = d1;
|
||||
image->comps[2].data = d2;
|
||||
|
||||
image->numcomps += 2;
|
||||
|
||||
|
@ -549,7 +632,19 @@ else
|
|||
{
|
||||
*r++ = (int)*out++; *g++ = (int)*out++; *b++ = (int)*out++;
|
||||
}
|
||||
free(inbuf); free(outbuf);
|
||||
ok = 1;
|
||||
|
||||
fails2:
|
||||
if(inbuf) free(inbuf);
|
||||
if(outbuf) free(outbuf);
|
||||
|
||||
if(ok == 0)
|
||||
{
|
||||
if(d1 != NULL) free(d1);
|
||||
if(d2 != NULL) free(d2);
|
||||
if(comps != NULL) free(comps);
|
||||
fprintf(stderr,"color.c:%d:\n\tmemory out\n",__LINE__);
|
||||
}
|
||||
|
||||
}/* if(image->numcomps */
|
||||
|
||||
|
@ -561,5 +656,282 @@ else
|
|||
#endif
|
||||
}/* color_apply_icc_profile() */
|
||||
|
||||
#endif /* OPJ_HAVE_LIBLCMS2 || OPJ_HAVE_LIBLCMS1 */
|
||||
void color_cielab_to_rgb(opj_image_t *image)
|
||||
{
|
||||
int *row;
|
||||
cmsHTRANSFORM transform;
|
||||
int *dst0, *dst1, *dst2;
|
||||
cmsHPROFILE in, out;
|
||||
int enumcs, numcomps, ok;
|
||||
|
||||
image->color_space = OPJ_CLRSPC_SRGB;
|
||||
|
||||
numcomps = image->numcomps;
|
||||
|
||||
if(numcomps != 3)
|
||||
{
|
||||
fprintf(stderr,"%s:%d:\n\tnumcomps %d not handled. Quitting.\n",
|
||||
__FILE__,__LINE__,numcomps);
|
||||
return;
|
||||
}
|
||||
|
||||
row = (int*)image->icc_profile_buf;
|
||||
enumcs = row[0];
|
||||
ok = 0;
|
||||
{
|
||||
int *L, *a, *b, *red, *green, *blue;
|
||||
int *src0, *src1, *src2;
|
||||
double rl, ol, ra, oa, rb, ob, prec0, prec1, prec2;
|
||||
double minL, maxL, mina, maxa, minb, maxb;
|
||||
unsigned int default_type;
|
||||
unsigned int i, max, ok = 0;
|
||||
cmsUInt16Number RGB[3];
|
||||
cmsCIELab Lab;
|
||||
|
||||
in = cmsCreateLab4Profile(NULL);
|
||||
out = cmsCreate_sRGBProfile();
|
||||
|
||||
transform =
|
||||
cmsCreateTransform(in, TYPE_Lab_DBL, out, TYPE_RGB_16,
|
||||
INTENT_PERCEPTUAL, 0);
|
||||
|
||||
#ifdef HAVE_LIBLCMS2
|
||||
cmsCloseProfile(in);
|
||||
cmsCloseProfile(out);
|
||||
#endif
|
||||
if(transform == NULL)
|
||||
{
|
||||
#ifdef HAVE_LIBLCMS1
|
||||
cmsCloseProfile(in);
|
||||
cmsCloseProfile(out);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
red = dst0 = (int*)malloc(max * sizeof(int));
|
||||
green = dst1 = (int*)malloc(max * sizeof(int));
|
||||
blue = dst2 = (int*)malloc(max * sizeof(int));
|
||||
|
||||
if(dst0 == NULL || dst1 == NULL || dst2 == NULL)
|
||||
{
|
||||
goto fails;
|
||||
}
|
||||
prec0 = (double)image->comps[0].prec;
|
||||
prec1 = (double)image->comps[1].prec;
|
||||
prec2 = (double)image->comps[2].prec;
|
||||
|
||||
default_type = row[1];
|
||||
|
||||
if(default_type == 0x44454600)// DEF : default
|
||||
{
|
||||
rl = 100; ra = 170; rb = 200;
|
||||
ol = 0;
|
||||
oa = pow(2, prec1 - 1);
|
||||
ob = pow(2, prec2 - 2) + pow(2, prec2 - 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
rl = (double)row[2]; ra = (double)row[4]; rb = (double)row[6];
|
||||
ol = (double)row[3]; oa = (double)row[5]; ob = (double)row[7];
|
||||
}
|
||||
L = src0 = image->comps[0].data;
|
||||
a = src1 = image->comps[1].data;
|
||||
b = src2 = image->comps[2].data;
|
||||
|
||||
max = image->comps[0].w * image->comps[0].h;
|
||||
|
||||
minL = -(rl * ol)/(pow(2, prec0)-1);
|
||||
maxL = minL + rl;
|
||||
|
||||
mina = -(ra * oa)/(pow(2, prec1)-1);
|
||||
maxa = mina + ra;
|
||||
|
||||
minb = -(rb * ob)/(pow(2, prec2)-1);
|
||||
maxb = minb + rb;
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
{
|
||||
Lab.L = minL + (double)(*L) * (maxL - minL)/(pow(2, prec0)-1); ++L;
|
||||
Lab.a = mina + (double)(*a) * (maxa - mina)/(pow(2, prec1)-1); ++a;
|
||||
Lab.b = minb + (double)(*b) * (maxb - minb)/(pow(2, prec2)-1); ++b;
|
||||
|
||||
cmsDoTransform(transform, &Lab, RGB, 1);
|
||||
|
||||
*red++ = RGB[0];
|
||||
*green++ = RGB[1];
|
||||
*blue++ = RGB[2];
|
||||
}
|
||||
ok = 1;
|
||||
|
||||
free(src0); image->comps[0].data = dst0;
|
||||
free(src1); image->comps[1].data = dst1;
|
||||
free(src2); image->comps[2].data = dst2;
|
||||
|
||||
image->color_space = OPJ_CLRSPC_SRGB;
|
||||
image->comps[0].prec = 16;
|
||||
image->comps[1].prec = 16;
|
||||
image->comps[2].prec = 16;
|
||||
}
|
||||
|
||||
fails:
|
||||
cmsDeleteTransform(transform);
|
||||
#ifdef HAVE_LIBLCMS1
|
||||
cmsCloseProfile(in);
|
||||
cmsCloseProfile(out);
|
||||
#endif
|
||||
if(ok) return;
|
||||
|
||||
if(dst0 != NULL) free(dst0);
|
||||
if(dst1 != NULL) free(dst1);
|
||||
fprintf(stderr,"color.c:%d:\n\tmemory out\n", __LINE__);
|
||||
|
||||
}// color_cielab_to_rgb()
|
||||
|
||||
#endif // HAVE_LIBLCMS2 || HAVE_LIBLCMS1
|
||||
|
||||
void color_cmyk_to_rgb(opj_image_t *image)
|
||||
{
|
||||
int *R, *G, *B, *dst0, *dst1, *dst2;
|
||||
int *sc, *sm, *sy, *sk, *src0, *src1, *src2, *src3;
|
||||
float C, M, Y, K;
|
||||
unsigned int w, h, max, prec, len, i;
|
||||
|
||||
w = image->comps[0].w;
|
||||
h = image->comps[0].h;
|
||||
prec = image->comps[0].prec;
|
||||
|
||||
if(prec != 8) return;
|
||||
if(image->numcomps != 4) return;
|
||||
|
||||
max = w * h;
|
||||
len = max * sizeof(int);
|
||||
|
||||
R = dst0 = (int*)malloc(len);
|
||||
G = dst1 = (int*)malloc(len);
|
||||
B = dst2 = (int*)malloc(len);
|
||||
|
||||
if(dst0 == NULL || dst1 == NULL || dst2 == NULL)
|
||||
{
|
||||
goto fails;
|
||||
}
|
||||
sc = src0 = image->comps[0].data;
|
||||
sm = src1 = image->comps[1].data;
|
||||
sy = src2 = image->comps[2].data;
|
||||
sk = src3 = image->comps[3].data;
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
{
|
||||
/* CMYK and CMY values from 0 to 1 */
|
||||
|
||||
C = (float)(*sc++)/(float)255.;
|
||||
M = (float)(*sm++)/(float)255;
|
||||
Y = (float)(*sy++)/(float)255;
|
||||
K = (float)(*sk++)/(float)255;
|
||||
|
||||
/* CMYK -> CMY */
|
||||
|
||||
C = ( C * ( (float)1. - K ) + K );
|
||||
M = ( M * ( (float)1. - K ) + K );
|
||||
Y = ( Y * ( (float)1. - K ) + K );
|
||||
|
||||
/* CMY -> RGB : RGB results from 0 to 255 */
|
||||
|
||||
*R++ = (int)(unsigned char)(( (float)1. - C ) * (float)255.);
|
||||
*G++ = (int)(unsigned char)(( (float)1. - M ) * (float)255.);
|
||||
*B++ = (int)(unsigned char)(( (float)1. - Y ) * (float)255.);
|
||||
}
|
||||
|
||||
free(src0); image->comps[0].data = dst0;
|
||||
free(src1); image->comps[1].data = dst1;
|
||||
free(src2); image->comps[2].data = dst2;
|
||||
free(src3); image->comps[3].data = NULL;
|
||||
|
||||
image->numcomps = 3;
|
||||
image->color_space = OPJ_CLRSPC_SRGB;
|
||||
return;
|
||||
|
||||
fails:
|
||||
if(dst0 != NULL) free(dst0);
|
||||
if(dst1 != NULL) free(dst1);
|
||||
fprintf(stderr,"color.c:%d)\n\tmemory out\n",__LINE__);
|
||||
|
||||
}// color_cmyk_to_rgb()
|
||||
|
||||
//
|
||||
// This code has been adopted from sjpx_openjpeg.c of ghostscript
|
||||
//
|
||||
void color_esycc_to_rgb(opj_image_t *image)
|
||||
{
|
||||
int *s0, *s1, *s2, *src0, *src1, *src2;
|
||||
int *r, *g, *b, *dst0, *dst1, *dst2;
|
||||
int y, cb, cr, sign1, sign2, val;
|
||||
unsigned int w, h, max, i;
|
||||
int flip_value = (1 << (image->comps[0].prec-1));
|
||||
int max_value = (~(-1 << image->comps[0].prec));
|
||||
|
||||
if(image->numcomps != 3) return;
|
||||
|
||||
r = dst0 = (int*)malloc(max * sizeof(int));
|
||||
g = dst1 = (int*)malloc(max * sizeof(int));
|
||||
b = dst2 = (int*)malloc(max * sizeof(int));
|
||||
|
||||
if(dst0 == NULL || dst1 == NULL || dst2 == NULL)
|
||||
{
|
||||
goto fails;
|
||||
}
|
||||
w = image->comps[0].w;
|
||||
h = image->comps[0].h;
|
||||
|
||||
s0 = src0 = image->comps[0].data;
|
||||
s1 = src1 = image->comps[1].data;
|
||||
s2 = src2 = image->comps[2].data;
|
||||
|
||||
sign1 = image->comps[1].sgnd;
|
||||
sign2 = image->comps[2].sgnd;
|
||||
|
||||
max = w * h;
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
{
|
||||
|
||||
y = *s0++; cb = *s1++; cr = *s2++;
|
||||
|
||||
if( !sign1) cb -= flip_value;
|
||||
if( !sign2) cr -= flip_value;
|
||||
|
||||
val = (int)
|
||||
((float)y - (float)0.0000368 * (float)cb
|
||||
+ (float)1.40199 * (float)cr + (float)0.5);
|
||||
|
||||
if(val > max_value) val = max_value; else if(val < 0) val = 0;
|
||||
*r++ = val;
|
||||
|
||||
val = (int)
|
||||
((float)1.0003 * (float)y - (float)0.344125 * (float)cb
|
||||
- (float)0.7141128 * (float)cr + (float)0.5);
|
||||
|
||||
if(val > max_value) val = max_value; else if(val < 0) val = 0;
|
||||
*g++ = val;
|
||||
|
||||
val = (int)
|
||||
((float)0.999823 * (float)y + (float)1.77204 * (float)cb
|
||||
- (float)0.000008 *(float)cr + (float)0.5);
|
||||
|
||||
if(val > max_value) val = max_value; else if(val < 0) val = 0;
|
||||
*b++ = val;
|
||||
}
|
||||
|
||||
free(src0); image->comps[0].data = dst0;
|
||||
free(src1); image->comps[1].data = dst1;
|
||||
free(src2); image->comps[2].data = dst2;
|
||||
|
||||
image->numcomps = 3;
|
||||
image->color_space = OPJ_CLRSPC_SRGB;
|
||||
return;
|
||||
|
||||
fails:
|
||||
image->color_space = OPJ_CLRSPC_SRGB;
|
||||
if(dst0 != NULL) free(dst0);
|
||||
if(dst1 != NULL) free(dst1);
|
||||
fprintf(stderr,"color.c:%d)\n\tmemory out\n",__LINE__);
|
||||
|
||||
}// color_esycc_to_rgb()
|
||||
|
|
|
@ -40,5 +40,8 @@
|
|||
|
||||
extern void color_sycc_to_rgb(opj_image_t *img);
|
||||
extern void color_apply_icc_profile(opj_image_t *image);
|
||||
extern void color_cielab_to_rgb(opj_image_t *image);
|
||||
|
||||
extern void color_cmyk_to_rgb(opj_image_t *image);
|
||||
extern void color_esycc_to_rgb(opj_image_t *image);
|
||||
#endif /* _OPJ_COLOR_H_ */
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
if(BUILD_FLVIEWER)
|
||||
add_subdirectory(flviewer)
|
||||
endif()
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
# - Find NPTH library
|
||||
#
|
||||
# NPTH_INCLUDE_DIR
|
||||
# NPTH_LIBRARIES
|
||||
# NPTH_FOUND
|
||||
#
|
||||
# also defined, but not for general use are
|
||||
# NPTH_LIBRARY
|
||||
|
||||
FIND_PATH(NPTH_INCLUDE_DIR npth.h
|
||||
PATHS /usr/include /usr/local/include /opt/include /opt/local/include)
|
||||
|
||||
SET(NPTH_NAMES ${NPTH_NAMES} npth libnpth libnpth_static)
|
||||
|
||||
FIND_LIBRARY(NPTH_LIBRARY NAMES ${NPTH_NAMES} )
|
||||
|
||||
MARK_AS_ADVANCED(NPTH_INCLUDE_DIR NPTH_LIBRARY)
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set NPTH_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(NPTH DEFAULT_MSG NPTH_LIBRARY NPTH_INCLUDE_DIR)
|
||||
|
||||
IF(NPTH_FOUND)
|
||||
SET(NPTH_INCLUDE_DIRS ${NPTH_INCLUDE_DIR})
|
||||
SET(NPTH_LIBRARIES ${NPTH_LIBRARY} )
|
||||
ENDIF(NPTH_FOUND)
|
|
@ -0,0 +1,124 @@
|
|||
#
|
||||
INCLUDE(${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake)
|
||||
CHECK_FUNCTION_EXISTS(_fseeki64 HAVE_FSEEKI64)
|
||||
CHECK_FUNCTION_EXISTS(fseeko HAVE_FSEEKO)
|
||||
#
|
||||
INCLUDE(${CMAKE_ROOT}/Modules/CheckTypeSize.cmake)
|
||||
#
|
||||
CHECK_TYPE_SIZE("ptrdiff_t" PTRDIFF_HAS_SIZE)
|
||||
IF(PTRDIFF_HAS_SIZE)
|
||||
SET(PTRDIFF_S "#define PTRDIFF_T ptrdiff_t")
|
||||
IF(UNIX)
|
||||
SET(PTRDIFF_FORMAT_S "#define PTRDIFF_FORMAT \"%ld\"")
|
||||
ELSE()
|
||||
IF(PTRDIFF_HAS_SIZE EQUAL 8)
|
||||
SET(PTRDIFF_FORMAT_S "#define PTRDIFF_FORMAT \"%I64d\"")
|
||||
ELSE()
|
||||
SET(PTRDIFF_FORMAT_S "#define PTRDIFF_FORMAT \"%ld\"")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ELSE()
|
||||
SET(PTRDIFF_S "/* #undef PTRDIFF_T */")
|
||||
SET(PTRDIFF_FORMAT_S "/* #undef PTRDIFF_FORMAT */")
|
||||
ENDIF()
|
||||
#
|
||||
CHECK_TYPE_SIZE("size_t" SIZE_T_HAS_SIZE)
|
||||
IF(SIZE_T_HAS_SIZE)
|
||||
SET(SIZE_T_S "size_t")
|
||||
ENDIF()
|
||||
#
|
||||
IF(UNIX)
|
||||
CHECK_TYPE_SIZE("int64_t" INT64_HAS_SIZE)
|
||||
IF(INT64_HAS_SIZE EQUAL 8)
|
||||
SET(INT64_S "int64_t")
|
||||
SET(INT64_FORMAT_S "\"%ld\"")
|
||||
ENDIF()
|
||||
CHECK_TYPE_SIZE("uint64_t" UINT64_HAS_SIZE)
|
||||
IF(UINT64_HAS_SIZE EQUAL 8)
|
||||
SET(UINT64_S "uint64_t")
|
||||
SET(UINT64_FORMAT_S "\"%lu\"")
|
||||
ENDIF()
|
||||
ELSE()
|
||||
CHECK_TYPE_SIZE("signed __int64" INT64_HAS_SIZE)
|
||||
IF(INT64_HAS_SIZE EQUAL 8)
|
||||
SET(INT64_S "signed __int64")
|
||||
SET(INT64_FORMAT_S "\"%I64d\"")
|
||||
ENDIF()
|
||||
CHECK_TYPE_SIZE("unsigned __int64" UINT64_HAS_SIZE)
|
||||
IF(UINT64_HAS_SIZE EQUAL 8)
|
||||
SET(UINT64_S "unsigned __int64")
|
||||
SET(UINT64_FORMAT_S "\"%I64u\"")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
#
|
||||
IF(INT64_HAS_SIZE LESS 8)
|
||||
CHECK_TYPE_SIZE("signed long" INT64_HAS_SIZE)
|
||||
IF(INT64_HAS_SIZE EQUAL 8)
|
||||
SET(INT64_S "signed long")
|
||||
SET(INT64_FORMAT_S "\"%ld\"")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
#
|
||||
IF(UINT64_HAS_SIZE LESS 8)
|
||||
CHECK_TYPE_SIZE("unsigned long" UINT64_HAS_SIZE)
|
||||
IF(UINT64_HAS_SIZE EQUAL 8)
|
||||
SET(UINT64_S "unsigned long")
|
||||
SET(UINT64_FORMAT_S "\"%lu\"")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
#
|
||||
IF(INT64_HAS_SIZE LESS 8)
|
||||
IF(UNIX)
|
||||
CHECK_TYPE_SIZE("signed long long" LONG_LONG_HAS_SIZE)
|
||||
IF(LONG_LONG_HAS_SIZE EQUAL 8)
|
||||
SET(INT64_S "signed long long")
|
||||
SET(INT64_FORMAT_S "\"%lld\"")
|
||||
SET(INT64_HAS_SIZE 8)
|
||||
ENDIF()
|
||||
ELSE()
|
||||
CHECK_TYPE_SIZE("signed long long" LONG_LONG_HAS_SIZE)
|
||||
IF(LONG_LONG_HAS_SIZE EQUAL 8)
|
||||
SET(INT64_S "signed long long")
|
||||
SET(INT64_FORMAT_S "\"%I64d\"")
|
||||
SET(INT64_HAS_SIZE 8)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
#
|
||||
IF(UINT64_HAS_SIZE LESS 8)
|
||||
IF(UNIX)
|
||||
CHECK_TYPE_SIZE("unsigned long long" ULONG_LONG_HAS_SIZE)
|
||||
IF(ULONG_LONG_HAS_SIZE EQUAL 8)
|
||||
SET(UINT64_S "unsigned long long")
|
||||
SET(UINT64_FORMAT_S "\"%llu\"")
|
||||
SET(UINT64_HAS_SIZE 8)
|
||||
ENDIF()
|
||||
ELSE()
|
||||
CHECK_TYPE_SIZE("unsigned long long" ULONG_LONG_HAS_SIZE)
|
||||
IF(ULONG_LONG_HAS_SIZE EQUAL 8)
|
||||
SET(UINT64_S "unsigned long long")
|
||||
SET(UINT64_FORMAT_S "\"%I64u\"")
|
||||
SET(UINT64_HAS_SIZE 8)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
#
|
||||
IF(INT64_HAS_SIZE LESS 8)
|
||||
CHECK_TYPE_SIZE("signed long" INT64_HAS_SIZE)
|
||||
IF(INT64_HAS_SIZE)
|
||||
SET(INT64_S "signed long")
|
||||
SET(INT64_FORMAT_S "\"%ld\"")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
#
|
||||
IF(UINT64_HAS_SIZE LESS 8)
|
||||
CHECK_TYPE_SIZE("unsigned long" UINT64_HAS_SIZE)
|
||||
IF(UINT64_HAS_SIZE)
|
||||
SET(UINT64_S "unsigned long")
|
||||
SET(UINT64_FORMAT_S "\"%lu\"")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
#
|
||||
#MESSAGE(STATUS "INT64_HAS_SIZE => ${INT64_HAS_SIZE}")
|
||||
#MESSAGE(STATUS "UINT64_HAS_SIZE => ${UINT64_HAS_SIZE}")
|
||||
#
|
|
@ -0,0 +1,3 @@
|
|||
SET(FLVIEWER_VERSION_MAJOR 0)
|
||||
SET(FLVIEWER_VERSION_MINOR 2)
|
||||
SET(FLVIEWER_VERSION_PATCH 5)
|
|
@ -0,0 +1,172 @@
|
|||
#
|
||||
PROJECT(flviewer)
|
||||
SET(exe flviewer)
|
||||
#
|
||||
#
|
||||
IF(CMAKE_COMPILER_IS_GNUCC)
|
||||
SET(CMAKE_CXX_FLAGS "-Wall -Wunused-but-set-variable -Wunused-variable ${CMAKE_CXX_FLAGS}")
|
||||
ENDIF()
|
||||
#
|
||||
INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/CMake/vers.cmake)
|
||||
|
||||
SET(FLVIEWER_VERSION
|
||||
"${FLVIEWER_VERSION_MAJOR}.${FLVIEWER_VERSION_MINOR}.${FLVIEWER_VERSION_PATCH}")
|
||||
SET(FLVIEWER_PACKAGE_STRING "flviewer-${FLVIEWER_VERSION}")
|
||||
#
|
||||
SET(FLVIEWER_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
#
|
||||
SET(CMAKE_MODULE_PATH
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMake
|
||||
${CMAKE_MODULE_PATH}
|
||||
)
|
||||
#------- fltk-1.3.x
|
||||
FIND_PACKAGE(FLTK REQUIRED)
|
||||
FIND_PACKAGE(JPEG)
|
||||
#
|
||||
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
|
||||
#-------------------------------------------------
|
||||
INCLUDE_DIRECTORIES(
|
||||
${FLTK_INCLUDE_DIR}
|
||||
${JPEG_INCLUDE_DIR}
|
||||
${PNG_INCLUDE_DIRNAME}
|
||||
${ZLIB_INCLUDE_DIRNAME}
|
||||
${LCMS_INCLUDE_DIRNAME}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${OPENJPEG_BINARY_DIR}/src/lib/openjp2 #opj_config.h
|
||||
${OPENJPEG_BINARY_DIR}/src/bin/common # opj_apps_config.h
|
||||
${OPENJPEG_SOURCE_DIR}/src/lib/openjp2
|
||||
${OPENJPEG_BINARY_DIR}/src/bin/fltk/flviewer
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
if(BUILD_THIRDPARTY)
|
||||
include_directories(
|
||||
${OPENJPEG_SOURCE_DIR}/thirdparty/include
|
||||
${OPENJPEG_SOURCE_DIR}/thirdparty/liblcms2/include
|
||||
${OPENJPEG_SOURCE_DIR}/thirdparty/libpng
|
||||
${OPENJPEG_SOURCE_DIR}/thirdparty/libtiff
|
||||
${OPENJPEG_BINARY_DIR}/thirdparty/libtiff
|
||||
)
|
||||
endif()
|
||||
#
|
||||
IF(UNIX)
|
||||
FIND_PACKAGE(Threads)
|
||||
ELSE()
|
||||
IF(WIN32)
|
||||
FIND_PACKAGE(NPTH)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
#
|
||||
SET(HAVE_THREADS)
|
||||
SET(HAVE_WINPORT)
|
||||
INCLUDE(${CMAKE_ROOT}/Modules/CheckPrototypeDefinition.cmake)
|
||||
#
|
||||
IF(WIN32)
|
||||
IF(NPTH_FOUND)
|
||||
SET(HAVE_THREADS 1)
|
||||
ELSE()
|
||||
SET(HAVE_THREADS 1)
|
||||
SET(HAVE_WINPORT 1)
|
||||
ENDIF()
|
||||
ELSE() #UNIX
|
||||
IF(CMAKE_HAVE_THREADS_LIBRARY)
|
||||
SET(HAVE_THREADS 1)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
#-------------------
|
||||
IF(UNIX)
|
||||
FIND_PROGRAM(FLTK_CONFIG_SCRIPT fltk-config PATHS ${FLTK_BIN_DIR})
|
||||
#
|
||||
IF(BUILD_FLVIEWER_WITH_SHARED_LIBS)
|
||||
EXEC_PROGRAM(${FLTK_CONFIG_SCRIPT} ARGS --use-images --ldflags
|
||||
OUTPUT_VARIABLE FLIBS)
|
||||
SET(LIBS ${FLIBS} ${JPEG_LIBRARIES})
|
||||
ELSE()
|
||||
EXEC_PROGRAM(${FLTK_CONFIG_SCRIPT} ARGS --use-images --ldstaticflags
|
||||
OUTPUT_VARIABLE FLIBS)
|
||||
SET(LIBS ${FLIBS} ${JPEG_LIBRARIES})
|
||||
ENDIF()
|
||||
ELSE()
|
||||
SET(LIBS ${FLTK_BASE_LIBRARY} ${FLTK_FORMS_LIBRARY} ${FLTK_GL_LIBRARY} ${FLTK_IMAGES_LIBRARY} )
|
||||
# IF(NOT FLTK_SKIP_OPENGL)
|
||||
# SET(LIBS ${LIBS} ${FLTK_GL_LIBRARY})
|
||||
# ENDIF()
|
||||
IF(BUILD_FLVIEWER_WITH_SHARED_LIBS)
|
||||
SET(LIBS ${LIBS} ${JPEG_LIBRARIES})
|
||||
ELSE()
|
||||
#If fltk has been compiled statically:
|
||||
#please enter the full paths of zlib.lib, fltkjpeg.lib, fltkpng.lib
|
||||
#SET(LIBS ${LIBS} C:/Public/Users/lib/zlib.lib C:/Public/Users/lib/fltkjpeg.lib C:/Public/Users/lib/fltkpng.lib
|
||||
#SET(LIBS ${LIBS} C:/WINDOWS/system32/user/lib/zlib.lib C:/WINDOWS/system32/user/lib/fltkjpeg.lib C:/WINDOWS/system32/user/lib/fltkpng.lib )
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
#-------------------
|
||||
SET(SRCS flviewer.cxx ps_image.cxx print_gui.cxx rgb_color.cxx)
|
||||
SET(SRCS ${SRCS} color.cxx read_jpeg2000.cxx read_mj2.cxx read_jpx.cxx read_jpm.cxx)
|
||||
#
|
||||
IF(OPJ_HAVE_LIBPNG)
|
||||
SET(SRCS ${SRCS} PNG.cxx)
|
||||
SET(LIBS ${LIBS} ${PNG_LIBNAME} ${Z_LIBNAME})
|
||||
ENDIF()
|
||||
#
|
||||
SET(SRCS ${SRCS} OPENJPEG.cxx PGX.cxx OPENMJ2.cxx JP2.cxx)
|
||||
#
|
||||
#IF(BUILD_JPWL AND BUILD_FLVIEWER_WITH_JPWL_LIB)
|
||||
# INCLUDE_DIRECTORIES(${OPENJPEGJPWL_INCLUDE_DIR})
|
||||
# SET(LIBS ${LIBS} ${OPENJPEGJPWL_LIBRARY_NAME})
|
||||
#ELSE()
|
||||
INCLUDE_DIRECTORIES(${OPENJPEG_INCLUDE_DIR})
|
||||
SET(LIBS ${LIBS} ${OPENJPEG_LIBRARY_NAME})
|
||||
#ENDIF()
|
||||
#
|
||||
IF(OPJ_HAVE_LIBLCMS2 OR OPJ_HAVE_LIBLCMS1)
|
||||
SET(LIBS ${LIBS} ${LCMS_LIBNAME})
|
||||
ENDIF()
|
||||
#
|
||||
IF(BUILD_WITH_GERMAN)
|
||||
SET(WITH_GERMAN 1)
|
||||
ELSE()
|
||||
SET(WITH_ENGLISH 1)
|
||||
ENDIF()
|
||||
#
|
||||
INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/CMake/defs.cmake)
|
||||
#
|
||||
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake
|
||||
${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
||||
#
|
||||
IF(UNIX)
|
||||
IF("${FLTK_MATH_LIBRARY}" STREQUAL "FLTK_MATH_LIBRARY-NOTFOUND")
|
||||
MESSAGE("FLTK_MATH_LIBRARY NOT FOUND")
|
||||
ELSE()
|
||||
SET(LIBS ${LIBS} ${FLTK_MATH_LIBRARY})
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
#
|
||||
IF(WIN32)
|
||||
IF(BUILD_FLVIEWER_WITH_SHARED_LIBS)
|
||||
ADD_DEFINITIONS(-DOPJ_EXPORTS)
|
||||
ELSE()
|
||||
ADD_DEFINITIONS(-DOPJ_STATIC)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
#
|
||||
ADD_EXECUTABLE(${exe} ${SRCS})
|
||||
#
|
||||
TARGET_LINK_LIBRARIES(${exe} ${LIBS})
|
||||
#
|
||||
IF(UNIX)
|
||||
TARGET_LINK_LIBRARIES(${exe} m)
|
||||
ENDIF()
|
||||
#
|
||||
IF(MSVC)
|
||||
SET_TARGET_PROPERTIES(${exe} PROPERTIES LINK_FLAGS_RELEASE
|
||||
"/NODEFAULTLIB:libcmt.lib
|
||||
/NODEFAULTLIB:libcmtd.lib
|
||||
/NODEFAULTLIB:msvcrtd.lib
|
||||
/SUBSYSTEM:CONSOLE" )
|
||||
ENDIF()
|
||||
#
|
||||
INSTALL(TARGETS ${exe}
|
||||
RUNTIME
|
||||
DESTINATION bin
|
||||
)
|
||||
#
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,15 @@
|
|||
#ifndef _JP2_HH_
|
||||
#define _JP2_HH_
|
||||
|
||||
#define JP2_FILE 1
|
||||
#define MJ2_FILE 0
|
||||
|
||||
extern void JP2_save_file(Canvas *canvas, const char *write_idf);
|
||||
extern unsigned char *JP2_decode(const char *read_idf, unsigned char *src,
|
||||
uint64_t fsize, int is_still, int decod_format,
|
||||
unsigned int *out_width, unsigned int *out_height,
|
||||
int *out_type, int *out_selected);
|
||||
extern void JP2_file_from_rgb(const unsigned char *buf, unsigned int width,
|
||||
unsigned int height, unsigned int numcomps, const char *write_idf);
|
||||
|
||||
#endif // _JP2_HH_
|
|
@ -0,0 +1,74 @@
|
|||
#include <config.h>
|
||||
/*
|
||||
* author(s) and license
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#include <io.h>
|
||||
#else /* not _WIN32 */
|
||||
#define __STDC_FORMAT_MACROS
|
||||
#include <stdint.h>
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#include <FL/fl_ask.H>
|
||||
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
extern "C" {
|
||||
#include "openjpeg.h"
|
||||
#include "color.hh"
|
||||
}
|
||||
#else
|
||||
#include "openjpeg.h"
|
||||
#include "color.hh"
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#include "flviewer.hh"
|
||||
#include "viewerdefs.hh"
|
||||
#include "tree.hh"
|
||||
#include "lang/opj_lang.h_utf8"
|
||||
|
||||
#include "JP2.hh"
|
||||
#include "OPENJPEG.hh"
|
||||
|
||||
static unsigned char *openjpeg_buf;
|
||||
|
||||
static void OPENJPEG_postlude(void)
|
||||
{
|
||||
if(openjpeg_buf) { free(openjpeg_buf); openjpeg_buf = NULL; }
|
||||
}
|
||||
|
||||
void OPENJPEG_load(Canvas *canvas, const char *read_idf,
|
||||
unsigned char *src, uint64_t fsize, int decod_format)
|
||||
{
|
||||
unsigned char *dst;
|
||||
int selected_component = 0;
|
||||
unsigned int width, height;
|
||||
int type;
|
||||
|
||||
dst =
|
||||
JP2_decode(read_idf, src, fsize, IS_STILL, decod_format,
|
||||
&width, &height, &type, &selected_component);
|
||||
|
||||
FLViewer_clear_wait();
|
||||
FLViewer_url(read_idf, width, height);
|
||||
|
||||
if( !dst) return;
|
||||
|
||||
canvas->read_idf = read_idf;
|
||||
|
||||
FLViewer_use_buffer(dst, width, height, type);
|
||||
|
||||
FLViewer_tiles_activate(1);
|
||||
|
||||
FLViewer_area_activate(1);
|
||||
|
||||
openjpeg_buf = dst;
|
||||
|
||||
canvas->cleanup = &OPENJPEG_postlude;
|
||||
|
||||
}/* OPENJPEG_load() */
|
|
@ -0,0 +1,8 @@
|
|||
#ifndef _FLVIEWER_OPENJPEG_HH_
|
||||
#define _FLVIEWER_OPENJPEG_HH_
|
||||
|
||||
extern void OPENJPEG_load(Canvas *canvas, const char *read_idf,
|
||||
unsigned char *src, uint64_t fsize, int decod_format);
|
||||
|
||||
|
||||
#endif /* _FLVIEWER_OPENJPEG_HH_ */
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,8 @@
|
|||
#ifndef _FLVIEWER_OPENMJ2_HH_
|
||||
#define _FLVIEWER_OPENMJ2_HH_
|
||||
|
||||
extern void OPENMJ2_load(Canvas *canvas, const char *read_idf,
|
||||
uint64_t fsize);
|
||||
extern void OPENMJ2_free_tracks();
|
||||
|
||||
#endif /* _FLVIEWER_OPENMJ2_HH_ */
|
|
@ -0,0 +1,195 @@
|
|||
#include <config.h>
|
||||
/*
|
||||
* author(s) and license
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "flviewer.hh"
|
||||
#include "PGX.hh"
|
||||
|
||||
#define PGX_MIN_LEN 12
|
||||
|
||||
static unsigned char *pgx_buf;
|
||||
|
||||
static void PGX_postlude(void)
|
||||
{
|
||||
if(pgx_buf) { free(pgx_buf); pgx_buf = NULL; }
|
||||
}
|
||||
|
||||
/* ML == big_endian; LM == little_endian
|
||||
*/
|
||||
static unsigned short readushort(unsigned char *s, int bigendian)
|
||||
{
|
||||
unsigned short c0, c1;
|
||||
|
||||
c0 = *s; c1 = s[1];
|
||||
|
||||
if(bigendian)
|
||||
return (unsigned short)((c0<<8) + c1);
|
||||
|
||||
return (unsigned short)((c1<<8) + c0);
|
||||
}
|
||||
|
||||
static unsigned int readuint(unsigned char *s, int bigendian)
|
||||
{
|
||||
unsigned int c0, c1, c2, c3;
|
||||
|
||||
c0 = *s; c1 = s[1]; c2 = s[2]; c3 = s[3];
|
||||
|
||||
if(bigendian)
|
||||
return (c0 << 24) + (c1 << 16) + (c2 << 8) + c3;
|
||||
|
||||
return (c3 << 24) + (c2 << 16) + (c1 << 8) + c0;
|
||||
}
|
||||
|
||||
void PGX_load(Canvas *canvas, FILE *reader, const char *read_idf,
|
||||
size_t fsize)
|
||||
{
|
||||
unsigned char *src, *s, *dst_buf, *d;
|
||||
int width, height, prec, sgnd, adjustS, adjustG ;
|
||||
int i, max, bigendian;
|
||||
int ushift, dshift;
|
||||
char endian1, endian2;
|
||||
char signbuf[80], white[80];
|
||||
|
||||
if(fsize <= PGX_MIN_LEN)
|
||||
{
|
||||
fprintf(stderr,"%s:%d: PGX_load\n\t%s\n\tis too short: len is %lu\n",
|
||||
__FILE__,__LINE__,read_idf,(unsigned long)fsize);
|
||||
FLViewer_close_reader();
|
||||
return;
|
||||
}
|
||||
src = (unsigned char*) calloc(1, fsize + 8);
|
||||
|
||||
if(src == NULL)
|
||||
{
|
||||
fprintf(stderr,"PGX.cxx:%d:\n\tmemory out\n",__LINE__);
|
||||
exit(1);
|
||||
}
|
||||
(void)fread(src, 1, fsize, reader);
|
||||
FLViewer_close_reader();
|
||||
|
||||
width = height = 0;
|
||||
/*--------------------------------------*/
|
||||
i = sscanf((char*)src, "PG%[ \t]%c%c%[ \t%+-]%d%[ \t]%d%[ \t]%d",
|
||||
white, &endian1, &endian2, signbuf, &prec, white,
|
||||
&width, white, &height);
|
||||
|
||||
if(i != 9)
|
||||
{
|
||||
fprintf(stderr, "%s:%d:PGX_load\n\t %s\n\tis not a valid PGX file.\n\t"
|
||||
"%d elements read, 9 expected.\n",__FILE__,__LINE__,read_idf, i);
|
||||
goto fails;
|
||||
}
|
||||
if(prec <= 0 || prec > 32)
|
||||
{
|
||||
fprintf(stderr, "%s:%d:PGX_load\n\tprec %d is invalid\n",
|
||||
__FILE__,__LINE__,prec);
|
||||
goto fails;
|
||||
}
|
||||
s = (unsigned char*)strchr((char*)src, '\n');
|
||||
assert(s);
|
||||
++s;
|
||||
|
||||
i = 0; sgnd = 0;
|
||||
|
||||
while(signbuf[i])
|
||||
{
|
||||
if(signbuf[i] == '-') sgnd = 1;
|
||||
i++;
|
||||
}
|
||||
|
||||
if(endian1 == 'M' && endian2 == 'L')
|
||||
bigendian = 1;
|
||||
else
|
||||
if(endian1 == 'L' && endian2 == 'M')
|
||||
bigendian = 0;
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "%s:%d:PGX_load\n\tneither 'ML' nor 'LM' found "
|
||||
"in header.\n",__FILE__,__LINE__);
|
||||
goto fails;
|
||||
}
|
||||
if(prec > 8) adjustG = prec - 8; else adjustG = 0;
|
||||
|
||||
if(sgnd) adjustS = (1<<(prec - 1)); else adjustS = 0;
|
||||
|
||||
if(prec < 8)
|
||||
{
|
||||
ushift = 8 - prec; dshift = prec - ushift;
|
||||
}
|
||||
else
|
||||
{
|
||||
ushift = dshift = 0;
|
||||
}
|
||||
max = width * height;
|
||||
d = dst_buf = (unsigned char*)calloc(1, max * 3);
|
||||
|
||||
if(dst_buf == NULL)
|
||||
{
|
||||
fprintf(stderr,"PGX.cxx:%d:\n\tmemory out\n",__LINE__);
|
||||
exit(1);
|
||||
}
|
||||
for(i = 0; i < max; i++)
|
||||
{
|
||||
int g;
|
||||
|
||||
g = 0;
|
||||
|
||||
if(prec < 8)
|
||||
{
|
||||
g = s[0] + adjustS; ++s;
|
||||
|
||||
g = (g<<ushift) + (g>>dshift);
|
||||
|
||||
*d++ = (unsigned char)g; *d++ = (unsigned char)g; *d++ = (unsigned char)g;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(prec == 8)
|
||||
{
|
||||
if(sgnd) g = (char)s[0]; else g = s[0]; ++s;
|
||||
}
|
||||
else
|
||||
if(prec <= 16)
|
||||
{
|
||||
if(sgnd)
|
||||
g = (short) readushort(s, bigendian);
|
||||
else
|
||||
g = readushort(s, bigendian);
|
||||
|
||||
s += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(sgnd)
|
||||
g = (int) readuint(s, bigendian);
|
||||
else
|
||||
g = readuint(s, bigendian);
|
||||
|
||||
s += 4;
|
||||
}
|
||||
g += adjustS;
|
||||
if(adjustG)
|
||||
g = ((g >> adjustG)+((g >> (adjustG - 1))%2));
|
||||
if(g > 255) g = 255; else if(g < 0) g = 0;
|
||||
|
||||
*d++ = (unsigned char)g;
|
||||
*d++ = (unsigned char)g;
|
||||
*d++ = (unsigned char)g;
|
||||
}//for(i
|
||||
|
||||
FLViewer_url(read_idf, width, height);
|
||||
|
||||
FLViewer_use_buffer(dst_buf, width, height, 3);
|
||||
|
||||
pgx_buf = dst_buf;
|
||||
canvas->cleanup = &PGX_postlude;
|
||||
|
||||
fails:
|
||||
free(src);
|
||||
|
||||
}/* PGX_load() */
|
|
@ -0,0 +1,7 @@
|
|||
#ifndef _FLVIEWER_PGX_HH_
|
||||
#define _FLVIEWER_PGX_HH_
|
||||
|
||||
extern void PGX_load(Canvas *canvas, FILE *reader, const char *read_idf,
|
||||
size_t fsize);
|
||||
|
||||
#endif /* _FLVIEWER_PGX_HH_ */
|
|
@ -0,0 +1,364 @@
|
|||
#include <config.h>
|
||||
#include "opj_apps_config.h"
|
||||
|
||||
#ifdef OPJ_HAVE_LIBPNG
|
||||
/*
|
||||
* author(s) and license
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
extern "C" {
|
||||
#include <png.h>
|
||||
#include <zlib.h>
|
||||
}
|
||||
#else
|
||||
#include <png.h>
|
||||
#include <zlib.h>
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#include "opj_stdint.h"
|
||||
|
||||
#include <FL/fl_ask.H>
|
||||
|
||||
#include "flviewer.hh"
|
||||
#include "PNG.hh"
|
||||
#include "lang/png_lang.h_utf8"
|
||||
|
||||
/* #define USE_PNG_IMAGE */
|
||||
|
||||
static unsigned char *png_buf;
|
||||
|
||||
static void PNG_postlude(void)
|
||||
{
|
||||
if(png_buf) { free(png_buf); png_buf = NULL; }
|
||||
}
|
||||
|
||||
void PNG_load(Canvas *canvas, FILE *reader, const char *read_idf,
|
||||
int64_t fsize)
|
||||
{
|
||||
#ifndef USE_PNG_IMAGE // uses reader
|
||||
png_bytep row;
|
||||
png_structp png;
|
||||
png_infop info;
|
||||
unsigned char *buf;
|
||||
double gamma, display_exponent;
|
||||
int unit, pass, nr_passes, depth;
|
||||
png_uint_32 resx, resy;
|
||||
png_uint_32 width, height;
|
||||
unsigned int i, src_w;
|
||||
int color_type, has_alpha;
|
||||
int bit_depth, interlace_type,compression_type, filter_type;
|
||||
|
||||
/* libpng-VERSION/example.c:
|
||||
* PC : screen_gamma = 2.2;
|
||||
* Mac: screen_gamma = 1.7 or 1.0;
|
||||
*/
|
||||
display_exponent = 2.2;
|
||||
|
||||
if((png = png_create_read_struct(PNG_LIBPNG_VER_STRING,
|
||||
NULL, NULL, NULL)) == NULL)
|
||||
goto fin;
|
||||
if((info = png_create_info_struct(png)) == NULL)
|
||||
goto fin;
|
||||
|
||||
if(setjmp(png_jmpbuf(png)))
|
||||
goto fin;
|
||||
|
||||
FLViewer_wait();
|
||||
|
||||
png_init_io(png, reader);
|
||||
png_read_info(png, info);
|
||||
|
||||
png_get_IHDR(png, info, &width, &height,
|
||||
&bit_depth, &color_type, &interlace_type,
|
||||
&compression_type, &filter_type);
|
||||
|
||||
if(color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
png_set_expand(png);
|
||||
else
|
||||
if(color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8)
|
||||
png_set_expand(png);
|
||||
|
||||
if(png_get_valid(png, info, PNG_INFO_tRNS))
|
||||
png_set_expand(png);
|
||||
|
||||
if(bit_depth == 16)
|
||||
png_set_strip_16(png);
|
||||
|
||||
/* GRAY => RGB; GRAY_ALPHA => RGBA
|
||||
*/
|
||||
if(color_type == PNG_COLOR_TYPE_GRAY
|
||||
|| color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
||||
{
|
||||
png_set_gray_to_rgb(png);
|
||||
color_type =
|
||||
(color_type == PNG_COLOR_TYPE_GRAY? PNG_COLOR_TYPE_RGB:
|
||||
PNG_COLOR_TYPE_RGB_ALPHA);
|
||||
}
|
||||
|
||||
if( !png_get_gAMA(png, info, &gamma))
|
||||
gamma = 0.45455;
|
||||
|
||||
png_set_gamma(png, display_exponent, gamma);
|
||||
|
||||
nr_passes = png_set_interlace_handling(png);
|
||||
|
||||
png_read_update_info(png, info);
|
||||
|
||||
png_get_pHYs(png, info, &resx, &resy, &unit);
|
||||
|
||||
color_type = png_get_color_type(png, info);
|
||||
|
||||
has_alpha = (color_type == PNG_COLOR_TYPE_RGB_ALPHA);
|
||||
|
||||
if(has_alpha)
|
||||
depth = 4;
|
||||
else
|
||||
depth = 3;
|
||||
|
||||
src_w = width * (3 + has_alpha);
|
||||
buf = (unsigned char*)malloc(src_w * height);
|
||||
|
||||
if(buf == NULL)
|
||||
{
|
||||
fprintf(stderr,"PNG.cxx:%d:\n\tmemory out\n",__LINE__);
|
||||
exit(1);
|
||||
}
|
||||
for(pass = 0; pass < nr_passes; pass++)
|
||||
{
|
||||
row = buf;
|
||||
|
||||
for(i = 0; i < height; i++)
|
||||
{
|
||||
/* libpng.3:
|
||||
* If you want the "sparkle" effect, just call png_read_rows() as
|
||||
* normal, with the third parameter NULL.
|
||||
*/
|
||||
png_read_rows(png, &row, NULL, 1);
|
||||
|
||||
row += src_w;
|
||||
}
|
||||
}
|
||||
FLViewer_url(read_idf, width, height);
|
||||
|
||||
FLViewer_use_buffer(buf, width, height, depth);
|
||||
|
||||
png_buf = buf;
|
||||
canvas->cleanup = &PNG_postlude;
|
||||
|
||||
fin:
|
||||
if(png)
|
||||
png_destroy_read_struct(&png, &info, NULL);
|
||||
FLViewer_close_reader();
|
||||
|
||||
#else // USE_PNG_IMAGE uses read_idf
|
||||
unsigned char *buf;
|
||||
png_image image;
|
||||
int depth = 3;
|
||||
|
||||
buf = NULL;
|
||||
memset(&image, 0, (sizeof image));
|
||||
image.version = PNG_IMAGE_VERSION;
|
||||
|
||||
FLViewer_close_reader();
|
||||
|
||||
FLViewer_wait();
|
||||
|
||||
if(png_image_begin_read_from_file(&image, read_idf))
|
||||
{
|
||||
png_bytep buffer;
|
||||
|
||||
depth = PNG_IMAGE_SAMPLE_CHANNELS(image.format);
|
||||
|
||||
if(depth == 3 || depth == 1)
|
||||
{
|
||||
image.format = PNG_FORMAT_RGB; depth = 3;
|
||||
}
|
||||
else
|
||||
if(depth == 4 || depth == 2)
|
||||
{
|
||||
image.format = PNG_FORMAT_RGBA; depth = 4;
|
||||
}
|
||||
buffer = (png_bytep)malloc(PNG_IMAGE_SIZE(image));
|
||||
|
||||
if(buffer != NULL
|
||||
&& png_image_finish_read(&image, NULL/*background*/,
|
||||
buffer,
|
||||
0/*row_stride*/, NULL/*colormap*/))
|
||||
{
|
||||
buf = buffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(buffer == NULL)
|
||||
png_image_free(&image);
|
||||
else
|
||||
free(buffer);
|
||||
}
|
||||
}
|
||||
if(buf == NULL) return;
|
||||
|
||||
FLViewer_url(read_idf, image.width, image.height);
|
||||
|
||||
FLViewer_use_buffer(buf, image.width, image.height, depth);
|
||||
|
||||
png_buf = buf;
|
||||
canvas->cleanup = &PNG_postlude;
|
||||
|
||||
#endif /* USE_PNG_IMAGE */
|
||||
}/* PNG_load() */
|
||||
|
||||
static int to_png(unsigned char *buf, int width, int height, int nr_comp,
|
||||
FILE *writer)
|
||||
{
|
||||
png_structp png;
|
||||
png_infop info;
|
||||
unsigned char *s;
|
||||
int color_type, step;
|
||||
int y, ok;
|
||||
png_color_8 sig_bit;
|
||||
|
||||
ok = 0;
|
||||
info = NULL;
|
||||
/* Create and initialize the png_struct with the desired error handler
|
||||
* functions. If you want to use the default stderr and longjump method,
|
||||
* you can supply NULL for the last three parameters. We also check that
|
||||
* the library version is compatible with the one used at compile time,
|
||||
* in case we are using dynamically linked libraries. REQUIRED.
|
||||
*/
|
||||
png = png_create_write_struct(PNG_LIBPNG_VER_STRING,
|
||||
NULL, NULL, NULL);
|
||||
|
||||
if(png == NULL) goto fin;
|
||||
|
||||
/* Allocate/initialize the image information data. REQUIRED
|
||||
*/
|
||||
info = png_create_info_struct(png);
|
||||
|
||||
if(info == NULL) goto fin;
|
||||
|
||||
/* Set error handling. REQUIRED if you are not supplying your own
|
||||
* error handling functions in the png_create_write_struct() call.
|
||||
*/
|
||||
if(setjmp(png_jmpbuf(png))) goto fin;
|
||||
|
||||
/* I/O initialization functions is REQUIRED
|
||||
*/
|
||||
png_init_io(png, writer);
|
||||
|
||||
/* Set the image information here. Width and height are up to 2^31,
|
||||
* bit_depth is one of 1, 2, 4, 8, or 16, but valid values also depend on
|
||||
* the color_type selected. color_type is one of PNG_COLOR_TYPE_GRAY,
|
||||
* PNG_COLOR_TYPE_GRAY_ALPHA, PNG_COLOR_TYPE_PALETTE, PNG_COLOR_TYPE_RGB,
|
||||
* or PNG_COLOR_TYPE_RGB_ALPHA. interlace is either PNG_INTERLACE_NONE or
|
||||
* PNG_INTERLACE_ADAM7, and the compression_type and filter_type MUST
|
||||
* currently be PNG_COMPRESSION_TYPE_BASE and PNG_FILTER_TYPE_BASE.
|
||||
* REQUIRED
|
||||
*
|
||||
* ERRORS:
|
||||
*
|
||||
* color_type == PNG_COLOR_TYPE_PALETTE && bit_depth > 8
|
||||
* color_type == PNG_COLOR_TYPE_RGB && bit_depth < 8
|
||||
* color_type == PNG_COLOR_TYPE_GRAY_ALPHA && bit_depth < 8
|
||||
* color_type == PNG_COLOR_TYPE_RGB_ALPHA) && bit_depth < 8
|
||||
*
|
||||
*/
|
||||
png_set_compression_level(png, Z_BEST_COMPRESSION);
|
||||
|
||||
if(nr_comp == 4)
|
||||
{
|
||||
step = 4 * width;
|
||||
sig_bit.alpha = 8;
|
||||
sig_bit.red = sig_bit.green = sig_bit.blue = 8;
|
||||
color_type = PNG_COLOR_TYPE_RGB_ALPHA;
|
||||
}
|
||||
else
|
||||
if(nr_comp == 3)
|
||||
{
|
||||
step = 3 * width;
|
||||
sig_bit.alpha = 0;
|
||||
sig_bit.red = sig_bit.green = sig_bit.blue = 8;
|
||||
color_type = PNG_COLOR_TYPE_RGB;
|
||||
}
|
||||
else
|
||||
if(nr_comp == 2)
|
||||
{
|
||||
step = 2 * width;
|
||||
sig_bit.gray = 8;
|
||||
sig_bit.red = sig_bit.green = sig_bit.blue = 0;
|
||||
sig_bit.alpha = 8;
|
||||
color_type = PNG_COLOR_TYPE_GRAY_ALPHA;
|
||||
}
|
||||
else /* 1 */
|
||||
{
|
||||
step = width;
|
||||
sig_bit.gray = 8;
|
||||
sig_bit.red = sig_bit.green = sig_bit.blue = sig_bit.alpha = 0;
|
||||
color_type = PNG_COLOR_TYPE_GRAY;
|
||||
}
|
||||
png_set_sBIT(png, info, &sig_bit);
|
||||
|
||||
png_set_IHDR(png, info, width, height, 8,
|
||||
color_type,
|
||||
PNG_INTERLACE_NONE,
|
||||
PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
|
||||
|
||||
png_set_gamma(png, 2.2, 1./2.2);
|
||||
|
||||
if(nr_comp > 2)
|
||||
{
|
||||
png_set_sRGB(png, info, PNG_sRGB_INTENT_PERCEPTUAL);
|
||||
}
|
||||
png_write_info(png, info);
|
||||
|
||||
s = buf;
|
||||
|
||||
for(y = 0; y < height; ++y)
|
||||
{
|
||||
png_write_row(png, s);
|
||||
|
||||
s += step;
|
||||
}
|
||||
png_write_end(png, info);
|
||||
|
||||
ok = 1;
|
||||
|
||||
fin:
|
||||
if(png)
|
||||
{
|
||||
png_destroy_write_struct(&png, &info);
|
||||
}
|
||||
return ok;
|
||||
}/* to_png() */
|
||||
|
||||
void PNG_save_file(Canvas *canvas, const char *write_idf)
|
||||
{
|
||||
FILE *writer;
|
||||
int width, height, nr_comp;
|
||||
|
||||
width = canvas->new_iwidth;
|
||||
height = canvas->new_iheight;
|
||||
nr_comp = canvas->new_idepth;
|
||||
|
||||
if((writer = fopen(write_idf, "wb")) == NULL)
|
||||
{
|
||||
fl_alert(DST_DID_NOT_OPEN_s, write_idf);
|
||||
return;
|
||||
}
|
||||
|
||||
if(to_png((unsigned char*)canvas->cbuf,
|
||||
width, height, nr_comp, writer) == 0)
|
||||
{
|
||||
fl_alert("%s", WRITE_PNG_FAILS_s);
|
||||
}
|
||||
fclose(writer);
|
||||
|
||||
}/* PNG_save_file() */
|
||||
|
||||
#endif /* OPJ_HAVE_LIBPNG */
|
|
@ -0,0 +1,12 @@
|
|||
#ifdef OPJ_HAVE_LIBPNG
|
||||
|
||||
#ifndef _FLVIEWER_PNG_HH_
|
||||
#define _FLVIEWER_PNG_HH_
|
||||
|
||||
extern void PNG_load(Canvas *canvas, FILE *reader, const char *read_idf,
|
||||
int64_t fsize);
|
||||
extern void PNG_save_file(Canvas *canvas, const char *write_idf);
|
||||
|
||||
#endif /* _FLVIEWER_PNG_HH_ */
|
||||
|
||||
#endif /* OPJ_HAVE_LIBPNG */
|
|
@ -0,0 +1,997 @@
|
|||
#include <config.h>
|
||||
/*
|
||||
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2007, Professor Benoit Macq
|
||||
* Copyright (c) 2001-2003, David Janssens
|
||||
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
|
||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "openjpeg.h"
|
||||
#include "opj_apps_config.h"
|
||||
|
||||
#ifdef OPJ_HAVE_LIBLCMS2
|
||||
#include <lcms2.h>
|
||||
#endif
|
||||
#ifdef OPJ_HAVE_LIBLCMS1
|
||||
#include <lcms.h>
|
||||
#endif
|
||||
|
||||
#include "viewerdefs.hh"
|
||||
#include "color.hh"
|
||||
|
||||
//#define DEBUG_SYCC
|
||||
|
||||
/*--------------------------------------------------------
|
||||
Matrix für sYCC, Amendment 1 to IEC 61966-2-1
|
||||
|
||||
Y : 0.299 0.587 0.114 :R
|
||||
Cb: -0.1687 -0.3312 0.5 :G
|
||||
Cr: 0.5 -0.4187 -0.0812 :B
|
||||
|
||||
Inverse:
|
||||
|
||||
R: 1 -3.68213e-05 1.40199 :Y
|
||||
G: 1.00003 -0.344125 -0.714128 :Cb - 2^(prec - 1)
|
||||
B: 0.999823 1.77204 -8.04142e-06 :Cr - 2^(prec - 1)
|
||||
|
||||
-----------------------------------------------------------*/
|
||||
static void sycc_to_rgb(int offset, int upb, int y, int cb, int cr,
|
||||
int *out_r, int *out_g, int *out_b)
|
||||
{
|
||||
int r, g, b;
|
||||
|
||||
cb -= offset; cr -= offset;
|
||||
r = y + (int)((float)1.402 * (float)cr);
|
||||
if(r < 0) r = 0; else if(r > upb) r = upb;
|
||||
*out_r = r;
|
||||
|
||||
g = y - (int)((float)0.344 * (float)cb + (float)0.714 * (float)cr);
|
||||
if(g < 0) g = 0; else if(g > upb) g = upb;
|
||||
*out_g = g;
|
||||
|
||||
b = y + (int)((float)1.772 * (float)cb);
|
||||
if(b < 0) b = 0; else if(b > upb) b = upb;
|
||||
*out_b = b;
|
||||
}
|
||||
|
||||
static void sycc444_to_rgb(opj_image_t *image, ImageInfo *dst)
|
||||
{
|
||||
int *r, *g, *b;
|
||||
const int *y, *cb, *cr;
|
||||
int maxw, maxh, max, i, offset, upb;
|
||||
size_t imax;
|
||||
|
||||
i = image->comps[0].prec;
|
||||
offset = 1<<(i - 1); upb = (1<<i)-1;
|
||||
|
||||
maxw = image->comps[0].w; maxh = image->comps[0].h;
|
||||
max = maxw * maxh;
|
||||
imax = max * sizeof(int);
|
||||
|
||||
y = image->comps[0].data;
|
||||
cb = image->comps[1].data;
|
||||
cr = image->comps[2].data;
|
||||
|
||||
dst->red = r = (int*)malloc(imax);
|
||||
dst->green = g = (int*)malloc(imax);
|
||||
dst->blue = b = (int*)malloc(imax);
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
{
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||
|
||||
++y; ++cb; ++cr; ++r; ++g; ++b;
|
||||
}
|
||||
dst->free_red = 1;
|
||||
dst->free_green = 1;
|
||||
dst->free_blue = 1;
|
||||
dst->numcomps = 3;
|
||||
dst->color_space = OPJ_CLRSPC_SRGB;
|
||||
|
||||
dst->dx[1] = dst->dx[0];
|
||||
dst->dx[2] = dst->dx[0];
|
||||
|
||||
dst->dy[1] = dst->dy[0];
|
||||
dst->dy[2] = dst->dy[0];
|
||||
|
||||
dst->prec[1] = dst->prec[0];
|
||||
dst->prec[2] = dst->prec[0];
|
||||
}// sycc444_to_rgb()
|
||||
|
||||
static void sycc422_to_rgb(opj_image_t *image, ImageInfo *dst)
|
||||
{
|
||||
int *r, *g, *b;
|
||||
const int *y, *cb, *cr;
|
||||
int maxw, maxh, max, offset, upb;
|
||||
int i, j;
|
||||
size_t imax;
|
||||
|
||||
i = image->comps[0].prec;
|
||||
offset = 1<<(i - 1); upb = (1<<i)-1;
|
||||
|
||||
maxw = image->comps[0].w;
|
||||
maxh = image->comps[0].h;
|
||||
max = maxw * maxh;
|
||||
imax = max *sizeof(int);
|
||||
|
||||
y = image->comps[0].data;
|
||||
cb = image->comps[1].data;
|
||||
cr = image->comps[2].data;
|
||||
|
||||
dst->red = r = (int*)malloc(imax);
|
||||
dst->green = g = (int*)malloc(imax);
|
||||
dst->blue = b = (int*)malloc(imax);
|
||||
|
||||
for(i = 0; i < maxh; ++i)
|
||||
{
|
||||
for(j = 0; j < (maxw & ~1); j += 2)
|
||||
{
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||
|
||||
++y; ++r; ++g; ++b;
|
||||
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||
|
||||
++y; ++r; ++g; ++b; ++cb; ++cr;
|
||||
}
|
||||
if(j < maxw)
|
||||
{
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
|
||||
|
||||
++y; ++r; ++g; ++b; ++cb; ++cr;
|
||||
}
|
||||
}
|
||||
dst->free_red = 1;
|
||||
dst->free_green = 1;
|
||||
dst->free_blue = 1;
|
||||
dst->color_space = OPJ_CLRSPC_SRGB;
|
||||
dst->numcomps = 3;
|
||||
|
||||
dst->dx[1] = dst->dx[0];
|
||||
dst->dx[2] = dst->dx[0];
|
||||
|
||||
dst->dy[1] = dst->dy[0];
|
||||
dst->dy[2] = dst->dy[0];
|
||||
|
||||
dst->prec[1] = dst->prec[0];
|
||||
dst->prec[2] = dst->prec[0];
|
||||
|
||||
image->color_space = OPJ_CLRSPC_SRGB;
|
||||
image->comps[1].w = maxw; image->comps[1].h = maxh;
|
||||
image->comps[2].w = maxw; image->comps[2].h = maxh;
|
||||
image->comps[1].dx = image->comps[0].dx;
|
||||
image->comps[2].dx = image->comps[0].dx;
|
||||
image->comps[1].dy = image->comps[0].dy;
|
||||
image->comps[2].dy = image->comps[0].dy;
|
||||
|
||||
}// sycc422_to_rgb()
|
||||
|
||||
static void sycc420_to_rgb(opj_image_t *image, ImageInfo *dst)
|
||||
{
|
||||
int *R, *G, *B, *nr, *ng, *nb;
|
||||
const int *y, *cb, *cr, *ny;
|
||||
int maxw, maxh, max, offset, upb;
|
||||
int i, j;
|
||||
size_t imax;
|
||||
|
||||
i = image->comps[0].prec;
|
||||
offset = 1<<(i - 1); upb = (1<<i)-1;
|
||||
|
||||
maxw = image->comps[0].w; maxh = image->comps[0].h;
|
||||
max = maxw * maxh;
|
||||
imax = sizeof(int) * max;
|
||||
|
||||
y = image->comps[0].data;
|
||||
cb = image->comps[1].data;
|
||||
cr = image->comps[2].data;
|
||||
|
||||
R = dst->red = (int*)malloc(imax);
|
||||
G = dst->green = (int*)malloc(imax);
|
||||
B = dst->blue = (int*)malloc(imax);
|
||||
#ifdef DEBUG_SYCC
|
||||
fprintf(stderr,"%s:%d:\n\tsycc420_to_rgb\n\tis_still(%d) W(%d) H(%d)\n"
|
||||
"\tRED(%p) GREEN(%p) BLUE(%p)\n",__FILE__,__LINE__,
|
||||
dst->is_still,maxw,maxh,(void*)dst->red,(void*)dst->green,
|
||||
(void*)dst->blue);
|
||||
#endif
|
||||
|
||||
for(i=0; i < (maxh & ~1); i += 2)
|
||||
{
|
||||
ny = y + maxw;
|
||||
nr = R + maxw; ng = G + maxw; nb = B + maxw;
|
||||
|
||||
for(j=0; j < (maxw & ~1); j += 2)
|
||||
{
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, R, G, B);
|
||||
|
||||
++y; ++R; ++G; ++B;
|
||||
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, R, G, B);
|
||||
|
||||
++y; ++R; ++G; ++B;
|
||||
|
||||
sycc_to_rgb(offset, upb, *ny, *cb, *cr, nr, ng, nb);
|
||||
|
||||
++ny; ++nr; ++ng; ++nb;
|
||||
|
||||
sycc_to_rgb(offset, upb, *ny, *cb, *cr, nr, ng, nb);
|
||||
|
||||
++ny; ++nr; ++ng; ++nb; ++cb; ++cr;
|
||||
}
|
||||
|
||||
if(j < maxw)
|
||||
{
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, R, G, B);
|
||||
|
||||
++y; ++R; ++G; ++B;
|
||||
|
||||
sycc_to_rgb(offset, upb, *ny, *cb, *cr, nr, ng, nb);
|
||||
|
||||
++ny; ++nr; ++ng; ++nb; ++cb; ++cr;
|
||||
}
|
||||
|
||||
y += maxw; R += maxw; G += maxw; B += maxw;
|
||||
}
|
||||
|
||||
if(i < maxh)
|
||||
{
|
||||
for(j = 0; j < (maxw & ~1); j += 2)
|
||||
{
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, R, G, B);
|
||||
|
||||
++y; ++R; ++G; ++B;
|
||||
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, R, G, B);
|
||||
|
||||
++y; ++R; ++G; ++B; ++cb; ++cr;
|
||||
}
|
||||
if(j < maxw)
|
||||
{
|
||||
sycc_to_rgb(offset, upb, *y, *cb, *cr, R, G, B);
|
||||
}
|
||||
}
|
||||
|
||||
dst->free_red = 1;
|
||||
dst->free_green = 1;
|
||||
dst->free_blue = 1;
|
||||
dst->numcomps = 3;
|
||||
dst->color_space = OPJ_CLRSPC_SRGB;
|
||||
|
||||
dst->dx[1] = dst->dx[0];
|
||||
dst->dx[2] = dst->dx[0];
|
||||
|
||||
dst->dy[1] = dst->dy[0];
|
||||
dst->dy[2] = dst->dy[0];
|
||||
|
||||
dst->prec[1] = dst->prec[0];
|
||||
dst->prec[2] = dst->prec[0];
|
||||
|
||||
image->color_space = OPJ_CLRSPC_SRGB;
|
||||
image->comps[1].w = maxw; image->comps[1].h = maxh;
|
||||
image->comps[2].w = maxw; image->comps[2].h = maxh;
|
||||
image->comps[1].dx = image->comps[0].dx;
|
||||
image->comps[2].dx = image->comps[0].dx;
|
||||
image->comps[1].dy = image->comps[0].dy;
|
||||
image->comps[2].dy = image->comps[0].dy;
|
||||
|
||||
}// sycc420_to_rgb()
|
||||
|
||||
void COLOR_sycc_to_rgb(opj_image_t *image, ImageInfo *dst)
|
||||
{
|
||||
#ifdef DEBUG_SYCC
|
||||
fprintf(stderr,"%s:%d:COLOR_sycc_to_rgb\n",
|
||||
__FILE__,__LINE__);
|
||||
fprintf(stderr,"\tcomponents(%d) dx(%d,%d,%d) dy(%d,%d,%d)\n",
|
||||
image->numcomps,
|
||||
image->comps[0].dx,image->comps[1].dx,image->comps[2].dx,
|
||||
image->comps[0].dy,image->comps[1].dy,image->comps[2].dy);
|
||||
#endif
|
||||
|
||||
if(image->numcomps < 3)
|
||||
{
|
||||
image->color_space = OPJ_CLRSPC_GRAY;
|
||||
dst->color_space = OPJ_CLRSPC_GRAY;
|
||||
dst->numcomps = image->numcomps;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if((image->comps[0].dx == 1)
|
||||
&& (image->comps[1].dx == 2)
|
||||
&& (image->comps[2].dx == 2)
|
||||
&& (image->comps[0].dy == 1)
|
||||
&& (image->comps[1].dy == 2)
|
||||
&& (image->comps[2].dy == 2))// horizontal and vertical sub-sample
|
||||
{
|
||||
sycc420_to_rgb(image, dst);
|
||||
return;
|
||||
}
|
||||
|
||||
if((image->comps[0].dx == 1)
|
||||
&& (image->comps[1].dx == 2)
|
||||
&& (image->comps[2].dx == 2)
|
||||
&& (image->comps[0].dy == 1)
|
||||
&& (image->comps[1].dy == 1)
|
||||
&& (image->comps[2].dy == 1))// horizontal sub-sample only
|
||||
{
|
||||
sycc422_to_rgb(image, dst);
|
||||
return;
|
||||
}
|
||||
|
||||
if((image->comps[0].dx == 1)
|
||||
&& (image->comps[1].dx == 1)
|
||||
&& (image->comps[2].dx == 1)
|
||||
&& (image->comps[0].dy == 1)
|
||||
&& (image->comps[1].dy == 1)
|
||||
&& (image->comps[2].dy == 1))// no sub-sample
|
||||
{
|
||||
sycc444_to_rgb(image, dst);
|
||||
return;
|
||||
}
|
||||
|
||||
if((image->comps[0].dx == 4)
|
||||
&& (image->comps[1].dx == 4)
|
||||
&& (image->comps[2].dx == 4)
|
||||
&& (image->comps[0].dy == 4)
|
||||
&& (image->comps[1].dy == 4)
|
||||
&& (image->comps[2].dy == 4))
|
||||
{
|
||||
// OK
|
||||
fprintf(stderr,"%s:%d:COLOR_sycc_to_rgb\n\tNO COVERSION\n",
|
||||
__FILE__,__LINE__);
|
||||
fprintf(stderr,"\tcomponents(%d) dx(%d,%d,%d) dy(%d,%d,%d)\n",
|
||||
image->numcomps,
|
||||
image->comps[0].dx,image->comps[1].dx,image->comps[2].dx,
|
||||
image->comps[0].dy,image->comps[1].dy,image->comps[2].dy);
|
||||
|
||||
return;
|
||||
}
|
||||
fprintf(stderr,"%s:%d:COLOR_sycc_to_rgb\n\tCAN NOT CONVERT\n",
|
||||
__FILE__,__LINE__);
|
||||
fprintf(stderr,"\tcomponents(%d) dx(%d,%d,%d) dy(%d,%d,%d)\n",
|
||||
image->numcomps,
|
||||
image->comps[0].dx,image->comps[1].dx,image->comps[2].dx,
|
||||
image->comps[0].dy,image->comps[1].dy,image->comps[2].dy);
|
||||
|
||||
|
||||
}// COLOR_sycc_to_rgb()
|
||||
|
||||
#if defined(OPJ_HAVE_LIBLCMS2) || defined(OPJ_HAVE_LIBLCMS1)
|
||||
|
||||
#ifdef OPJ_HAVE_LIBLCMS1
|
||||
// Bob Friesenhahn proposed:
|
||||
//
|
||||
#define cmsSigXYZData icSigXYZData
|
||||
#define cmsSigLabData icSigLabData
|
||||
#define cmsSigCmykData icSigCmykData
|
||||
#define cmsSigYCbCrData icSigYCbCrData
|
||||
#define cmsSigLuvData icSigLuvData
|
||||
#define cmsSigGrayData icSigGrayData
|
||||
#define cmsSigRgbData icSigRgbData
|
||||
#define cmsUInt32Number DWORD
|
||||
#define cmsUInt16Number WORD
|
||||
|
||||
#define cmsColorSpaceSignature icColorSpaceSignature
|
||||
#define cmsGetHeaderRenderingIntent cmsTakeRenderingIntent
|
||||
|
||||
#endif // OPJ_HAVE_LIBLCMS1
|
||||
|
||||
//#define DEBUG_PROFILE
|
||||
|
||||
void COLOR_apply_icc_profile(opj_image_t *image, ImageInfo *dst)
|
||||
{
|
||||
cmsHPROFILE in_prof, out_prof;
|
||||
cmsHTRANSFORM transform;
|
||||
cmsColorSpaceSignature out_space;
|
||||
cmsUInt32Number intent, in_type, out_type;
|
||||
size_t nr_samples;
|
||||
int *r, *g, *b;
|
||||
unsigned int prec, i, max, max_w, max_h, dmax, has_alpha2 = 0;
|
||||
OPJ_COLOR_SPACE oldspace;
|
||||
|
||||
#ifdef DEBUG_PROFILE
|
||||
{
|
||||
FILE *writer = fopen("debug.icm","wb");
|
||||
fwrite(image->icc_profile_buf, 1, image->icc_profile_len, writer);
|
||||
fclose(writer);
|
||||
}
|
||||
#endif
|
||||
|
||||
in_prof =
|
||||
cmsOpenProfileFromMem(image->icc_profile_buf,
|
||||
image->icc_profile_len);
|
||||
|
||||
if(in_prof == NULL) return ;
|
||||
|
||||
(void)cmsGetPCS(in_prof);
|
||||
out_space = cmsGetColorSpace(in_prof);
|
||||
intent = cmsGetHeaderRenderingIntent(in_prof);
|
||||
|
||||
max_w = image->comps[0].w;
|
||||
max_h = image->comps[0].h;
|
||||
prec = image->comps[0].prec;
|
||||
|
||||
oldspace = image->color_space;
|
||||
|
||||
if(out_space == cmsSigRgbData) // enumCS 16
|
||||
{
|
||||
if( prec <= 8 )
|
||||
{
|
||||
in_type = TYPE_RGB_8;
|
||||
out_type = TYPE_RGB_8;
|
||||
}
|
||||
else
|
||||
{
|
||||
in_type = TYPE_RGB_16;
|
||||
out_type = TYPE_RGB_16;
|
||||
}
|
||||
out_prof = cmsCreate_sRGBProfile();
|
||||
image->color_space = OPJ_CLRSPC_SRGB;
|
||||
}
|
||||
else
|
||||
if(out_space == cmsSigGrayData) // enumCS 17
|
||||
{
|
||||
if( prec <= 8 )
|
||||
{
|
||||
in_type = TYPE_GRAY_8;
|
||||
out_type = TYPE_RGB_8;
|
||||
}
|
||||
else //prec > 8
|
||||
{
|
||||
in_type = TYPE_GRAY_16;
|
||||
out_type = TYPE_RGB_16;
|
||||
}
|
||||
out_prof = cmsCreate_sRGBProfile();
|
||||
image->color_space = OPJ_CLRSPC_SRGB;
|
||||
}
|
||||
else
|
||||
if(out_space == cmsSigYCbCrData) // enumCS 18
|
||||
{
|
||||
fprintf(stderr,"\n%s:%d:\n\tout_space == cmsSigYCbCrData NOT HANDLED\n\n",
|
||||
__FILE__,__LINE__);
|
||||
cmsCloseProfile(in_prof);
|
||||
return ;
|
||||
#ifdef HIDDEN_CODE
|
||||
|
||||
in_type = TYPE_YCbCr_16;
|
||||
out_type = TYPE_RGB_16;
|
||||
out_prof = cmsCreate_sRGBProfile();
|
||||
image->color_space = OPJ_CLRSPC_SRGB;
|
||||
|
||||
#endif //HIDDEN_CODE
|
||||
}
|
||||
else
|
||||
{
|
||||
cmsCloseProfile(in_prof);
|
||||
return ;
|
||||
}
|
||||
|
||||
transform = cmsCreateTransform(in_prof, in_type,
|
||||
out_prof, out_type, intent, 0);
|
||||
|
||||
#ifdef OPJ_HAVE_LIBLCMS2
|
||||
// Possible for: LCMS_VERSION >= 2000 :
|
||||
cmsCloseProfile(in_prof);
|
||||
cmsCloseProfile(out_prof);
|
||||
#endif
|
||||
|
||||
if(transform == NULL)
|
||||
{
|
||||
image->color_space = oldspace;
|
||||
#ifdef OPJ_HAVE_LIBLCMS1
|
||||
cmsCloseProfile(in_prof);
|
||||
cmsCloseProfile(out_prof);
|
||||
#endif
|
||||
return ;
|
||||
}
|
||||
max = max_w * max_h;
|
||||
dmax = max * sizeof(int);
|
||||
|
||||
if(image->numcomps > 2)// RGB, RGBA
|
||||
{
|
||||
if( prec <= 8 )
|
||||
{
|
||||
unsigned char *inbuf, *outbuf, *in, *out;
|
||||
|
||||
nr_samples =
|
||||
(cmsUInt32Number)max * 3 * (cmsUInt32Number)sizeof(unsigned char);
|
||||
|
||||
in = inbuf = (unsigned char*)malloc(nr_samples);
|
||||
out = outbuf = (unsigned char*)malloc(nr_samples);
|
||||
|
||||
r = image->comps[0].data;
|
||||
g = image->comps[1].data;
|
||||
b = image->comps[2].data;
|
||||
// max = max_w * max_h; dmax = max * sizeof(int);
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
{
|
||||
*in++ = (unsigned char)*r++;
|
||||
*in++ = (unsigned char)*g++;
|
||||
*in++ = (unsigned char)*b++;
|
||||
}
|
||||
cmsDoTransform(transform, inbuf, outbuf, (cmsUInt32Number)max);
|
||||
|
||||
r = dst->red = (int*)malloc(dmax);
|
||||
g = dst->green = (int*)malloc(dmax);
|
||||
b = dst->blue = (int*)malloc(dmax);
|
||||
|
||||
dst->free_red = 1;
|
||||
dst->free_green = 1;
|
||||
dst->free_blue = 1;
|
||||
dst->numcomps = 3;
|
||||
dst->color_space = OPJ_CLRSPC_SRGB;
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
{
|
||||
*r++ = (int)*out++;
|
||||
*g++ = (int)*out++;
|
||||
*b++ = (int)*out++;
|
||||
}
|
||||
free(inbuf); free(outbuf);
|
||||
}
|
||||
else //prec > 8
|
||||
{
|
||||
unsigned short *inbuf, *outbuf, *in, *out;
|
||||
|
||||
nr_samples = max * 3 * sizeof(unsigned short);
|
||||
|
||||
in = inbuf = (unsigned short*)malloc(nr_samples);
|
||||
out = outbuf = (unsigned short*)malloc(nr_samples);
|
||||
|
||||
r = image->comps[0].data;
|
||||
g = image->comps[1].data;
|
||||
b = image->comps[2].data;
|
||||
// max = max_w * max_h; dmax = max * sizeof(int);
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
{
|
||||
*in++ = (unsigned short)*r++;
|
||||
*in++ = (unsigned short)*g++;
|
||||
*in++ = (unsigned short)*b++;
|
||||
}
|
||||
cmsDoTransform(transform, inbuf, outbuf, max);
|
||||
|
||||
r = dst->red = (int*)malloc(dmax);
|
||||
g = dst->green = (int*)malloc(dmax);
|
||||
b = dst->blue = (int*)malloc(dmax);
|
||||
|
||||
dst->free_red = 1;
|
||||
dst->free_green = 1;
|
||||
dst->free_blue = 1;
|
||||
dst->numcomps = 3;
|
||||
dst->color_space = OPJ_CLRSPC_SRGB;
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
{
|
||||
*r++ = (int)*out++;
|
||||
*g++ = (int)*out++;
|
||||
*b++ = (int)*out++;
|
||||
}
|
||||
free(inbuf); free(outbuf);
|
||||
}
|
||||
}
|
||||
else // image->numcomps <= 2 : GRAY -> RGB, GRAYA -> RGBA
|
||||
{
|
||||
has_alpha2 = (image->numcomps == 2);
|
||||
|
||||
if(prec <= 8)
|
||||
{
|
||||
unsigned char *in, *inbuf, *out, *outbuf;
|
||||
|
||||
nr_samples = max * 3 * sizeof(unsigned char);
|
||||
|
||||
in = inbuf = (unsigned char*)malloc(nr_samples);
|
||||
out = outbuf = (unsigned char*)malloc(nr_samples);
|
||||
|
||||
r = image->comps[0].data;
|
||||
|
||||
if(has_alpha2)
|
||||
{
|
||||
dst->alpha = image->comps[1].data;
|
||||
dst->prec[3] = image->comps[1].prec;
|
||||
dst->sgnd[3] = image->comps[1].sgnd;
|
||||
dst->has_alpha = 1;
|
||||
}
|
||||
// max = max_w * max_h; dmax = max * sizeof(int);
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
{
|
||||
*in++ = (unsigned char)*r++;
|
||||
}
|
||||
cmsDoTransform(transform, inbuf, outbuf, max);
|
||||
|
||||
r = dst->red = (int*)malloc(dmax);
|
||||
g = dst->green = (int*)malloc(dmax);
|
||||
b = dst->blue = (int*)malloc(dmax);
|
||||
|
||||
dst->free_red = 1;
|
||||
dst->free_green = 1;
|
||||
dst->free_blue = 1;
|
||||
dst->numcomps = 3 + has_alpha2;
|
||||
dst->color_space = OPJ_CLRSPC_SRGB;
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
{
|
||||
*r++ = (int)*out++;
|
||||
*g++ = (int)*out++;
|
||||
*b++ = (int)*out++;
|
||||
}
|
||||
free(inbuf); free(outbuf);
|
||||
}
|
||||
else // prec > 8
|
||||
{
|
||||
unsigned short *inbuf, *outbuf, *in, *out;
|
||||
|
||||
nr_samples =
|
||||
(cmsUInt32Number)max * 3 * (cmsUInt32Number)sizeof(unsigned short);
|
||||
|
||||
in = inbuf = (unsigned short*)malloc(nr_samples);
|
||||
out = outbuf = (unsigned short*)malloc(nr_samples);
|
||||
|
||||
r = image->comps[0].data;
|
||||
|
||||
if(has_alpha2)
|
||||
{
|
||||
dst->alpha = image->comps[1].data;
|
||||
dst->prec[3] = image->comps[1].prec;
|
||||
dst->sgnd[3] = image->comps[1].sgnd;
|
||||
dst->has_alpha = 1;
|
||||
}
|
||||
// max = max_w * max_h; dmax = max * sizeof(int);
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
{
|
||||
*in++ = (unsigned short)*r++;
|
||||
}
|
||||
cmsDoTransform(transform, inbuf, outbuf, (cmsUInt32Number)max);
|
||||
|
||||
r = dst->red = (int*)malloc(dmax);
|
||||
g = dst->green = (int*)malloc(dmax);
|
||||
b = dst->blue = (int*)malloc(dmax);
|
||||
|
||||
dst->free_red = 1;
|
||||
dst->free_green = 1;
|
||||
dst->free_blue = 1;
|
||||
dst->numcomps = 3 + has_alpha2;
|
||||
dst->color_space = OPJ_CLRSPC_SRGB;
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
{
|
||||
*r++ = (int)*out++;
|
||||
*g++ = (int)*out++;
|
||||
*b++ = (int)*out++;
|
||||
}
|
||||
free(inbuf); free(outbuf);
|
||||
} //if(prec <= 8)
|
||||
|
||||
dst->dx[0] = image->comps[0].dx;
|
||||
dst->dy[0] = image->comps[0].dy;
|
||||
dst->prec[0] = image->comps[0].prec;
|
||||
dst->sgnd[0] = image->comps[0].sgnd;
|
||||
|
||||
dst->dx[1] = image->comps[0].dx;
|
||||
dst->dy[1] = image->comps[0].dy;
|
||||
dst->prec[1] = image->comps[0].prec;
|
||||
dst->sgnd[1] = image->comps[0].sgnd;
|
||||
|
||||
dst->dx[2] = image->comps[0].dx;
|
||||
dst->dy[2] = image->comps[0].dy;
|
||||
dst->prec[2] = image->comps[0].prec;
|
||||
dst->sgnd[2] = image->comps[0].sgnd;
|
||||
|
||||
if(has_alpha2 == 0)
|
||||
{
|
||||
dst->dx[3] = image->comps[0].dx;
|
||||
dst->dy[3] = image->comps[0].dy;
|
||||
dst->prec[3] = image->comps[0].prec;
|
||||
dst->sgnd[3] = image->comps[0].sgnd;
|
||||
}
|
||||
}// if(image->numcomps > 2)
|
||||
|
||||
cmsDeleteTransform(transform);
|
||||
|
||||
#ifdef OPJ_HAVE_LIBLCMS1
|
||||
cmsCloseProfile(in_prof);
|
||||
cmsCloseProfile(out_prof);
|
||||
#endif
|
||||
|
||||
}// COLOR_apply_icc_profile()
|
||||
|
||||
void COLOR_apply_conversion(opj_image_t *image, ImageInfo *dst)
|
||||
{
|
||||
int *row;
|
||||
int enumcs, numcomps;
|
||||
|
||||
image->color_space = OPJ_CLRSPC_SRGB;
|
||||
dst->color_space = OPJ_CLRSPC_SRGB;
|
||||
|
||||
numcomps = dst->numcomps;
|
||||
|
||||
if(numcomps != 3)
|
||||
{
|
||||
fprintf(stderr,"%s:%d:\n\tnumcomps %d not handled. Quitting.\n",
|
||||
__FILE__,__LINE__,numcomps);
|
||||
return;
|
||||
}
|
||||
|
||||
row = (int*)image->icc_profile_buf;
|
||||
enumcs = row[0];
|
||||
|
||||
if(enumcs == 14)// CIELab
|
||||
{
|
||||
int *L, *a, *b, *red, *green, *blue;
|
||||
double rl, ol, ra, oa, rb, ob, prec0, prec1, prec2;
|
||||
double minL, maxL, mina, maxa, minb, maxb;
|
||||
unsigned int default_type;
|
||||
unsigned int i, max;
|
||||
cmsHPROFILE in, out;
|
||||
cmsHTRANSFORM transform;
|
||||
cmsUInt16Number RGB[3];
|
||||
cmsCIELab Lab;
|
||||
|
||||
in = cmsCreateLab4Profile(NULL);
|
||||
out = cmsCreate_sRGBProfile();
|
||||
|
||||
transform =
|
||||
cmsCreateTransform(in, TYPE_Lab_DBL, out, TYPE_RGB_16,
|
||||
INTENT_PERCEPTUAL, 0);
|
||||
|
||||
#ifdef OPJ_HAVE_LIBLCMS2
|
||||
cmsCloseProfile(in);
|
||||
cmsCloseProfile(out);
|
||||
#endif
|
||||
if(transform == NULL)
|
||||
{
|
||||
#ifdef OPJ_HAVE_LIBLCMS1
|
||||
cmsCloseProfile(in);
|
||||
cmsCloseProfile(out);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
prec0 = (double)image->comps[0].prec;
|
||||
prec1 = (double)image->comps[1].prec;
|
||||
prec2 = (double)image->comps[2].prec;
|
||||
|
||||
default_type = row[1];
|
||||
|
||||
if(default_type == 0x44454600)// DEF : default
|
||||
{
|
||||
rl = 100; ra = 170; rb = 200;
|
||||
ol = 0;
|
||||
oa = pow(2, prec1 - 1);
|
||||
ob = pow(2, prec2 - 2) + pow(2, prec2 - 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
rl = row[2]; ra = row[4]; rb = row[6];
|
||||
ol = row[3]; oa = row[5]; ob = row[7];
|
||||
}
|
||||
L = image->comps[0].data;
|
||||
a = image->comps[1].data;
|
||||
b = image->comps[2].data;
|
||||
|
||||
max = image->comps[0].w * image->comps[0].h;
|
||||
|
||||
red = dst->red = (int*)malloc(max * sizeof(int));
|
||||
green = dst->green = (int*)malloc(max * sizeof(int));
|
||||
blue = dst->blue = (int*)malloc(max * sizeof(int));
|
||||
|
||||
minL = -(rl * ol)/(pow(2, prec0)-1);
|
||||
maxL = minL + rl;
|
||||
|
||||
mina = -(ra * oa)/(pow(2, prec1)-1);
|
||||
maxa = mina + ra;
|
||||
|
||||
minb = -(rb * ob)/(pow(2, prec2)-1);
|
||||
maxb = minb + rb;
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
{
|
||||
Lab.L = minL + (double)(*L) * (maxL - minL)/(pow(2, prec0)-1); ++L;
|
||||
Lab.a = mina + (double)(*a) * (maxa - mina)/(pow(2, prec1)-1); ++a;
|
||||
Lab.b = minb + (double)(*b) * (maxb - minb)/(pow(2, prec2)-1); ++b;
|
||||
|
||||
cmsDoTransform(transform, &Lab, RGB, 1);
|
||||
|
||||
*red++ = RGB[0];
|
||||
*green++ = RGB[1];
|
||||
*blue++ = RGB[2];
|
||||
}
|
||||
cmsDeleteTransform(transform);
|
||||
#ifdef OPJ_HAVE_LIBLCMS1
|
||||
cmsCloseProfile(in);
|
||||
cmsCloseProfile(out);
|
||||
#endif
|
||||
|
||||
dst->free_red = 1;
|
||||
dst->free_green = 1;
|
||||
dst->free_blue = 1;
|
||||
dst->numcomps = 3;
|
||||
dst->color_space = OPJ_CLRSPC_SRGB;
|
||||
dst->prec[0] = 16;
|
||||
dst->prec[1] = 16;
|
||||
dst->prec[2] = 16;
|
||||
|
||||
dst->alpha = NULL;
|
||||
dst->has_alpha = 0;
|
||||
|
||||
image->color_space = OPJ_CLRSPC_SRGB;
|
||||
image->comps[0].prec = 16;
|
||||
image->comps[1].prec = 16;
|
||||
image->comps[2].prec = 16;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
fprintf(stderr,"%s:%d:\n\tenumCS %d not handled. Ignoring.\n",
|
||||
__FILE__,__LINE__, enumcs);
|
||||
|
||||
}// COLOR_apply_conversion()
|
||||
|
||||
#endif // OPJ_HAVE_LIBLCMS2 || OPJ_HAVE_LIBLCMS1
|
||||
|
||||
void COLOR_cmyk_to_rgb(opj_image_t *image, ImageInfo *dst)
|
||||
{
|
||||
int *R, *G, *B;
|
||||
int *sc, *sm, *sy, *sk;
|
||||
float C, M, Y, K;
|
||||
unsigned int w, h, max, prec, len, i;
|
||||
|
||||
w = image->comps[0].w;
|
||||
h = image->comps[0].h;
|
||||
prec = image->comps[0].prec;
|
||||
|
||||
if(prec != 8) return;
|
||||
if(image->numcomps != 4) return;
|
||||
|
||||
max = w * h;
|
||||
len = max * sizeof(int);
|
||||
|
||||
R = dst->red = (int*)malloc(len);
|
||||
G = dst->green = (int*)malloc(len);
|
||||
B = dst->blue = (int*)malloc(len);
|
||||
|
||||
sc = image->comps[0].data;
|
||||
sm = image->comps[1].data;
|
||||
sy = image->comps[2].data;
|
||||
sk = image->comps[3].data;
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
{
|
||||
// CMYK and CMY values from 0 to 1
|
||||
//
|
||||
C = (float)(*sc++)/(float)255.;
|
||||
M = (float)(*sm++)/(float)255;
|
||||
Y = (float)(*sy++)/(float)255;
|
||||
K = (float)(*sk++)/(float)255;
|
||||
|
||||
// CMYK -> CMY
|
||||
//
|
||||
C = ( C * ( (float)1. - K ) + K );
|
||||
M = ( M * ( (float)1. - K ) + K );
|
||||
Y = ( Y * ( (float)1. - K ) + K );
|
||||
|
||||
// CMY -> RGB : RGB results from 0 to 255
|
||||
//
|
||||
*R++ = (int)(unsigned char)(( (float)1. - C ) * (float)255.);
|
||||
*G++ = (int)(unsigned char)(( (float)1. - M ) * (float)255.);
|
||||
*B++ = (int)(unsigned char)(( (float)1. - Y ) * (float)255.);
|
||||
}
|
||||
|
||||
dst->free_red = 1;
|
||||
dst->free_green = 1;
|
||||
dst->free_blue = 1;
|
||||
dst->numcomps = 3;
|
||||
dst->color_space = OPJ_CLRSPC_SRGB;
|
||||
|
||||
image->color_space = OPJ_CLRSPC_SRGB;
|
||||
|
||||
}// COLOR_cmyk_to_rgb()
|
||||
|
||||
//
|
||||
// This code has been adopted from sjpx_openjpeg.c of ghostscript
|
||||
//
|
||||
void COLOR_esycc_to_rgb(opj_image_t *image, ImageInfo *dst)
|
||||
{
|
||||
int *s0, *s1, *s2;
|
||||
int *r, *g, *b;
|
||||
int y, cb, cr, sign1, sign2, val;
|
||||
unsigned int w, h, max, i;
|
||||
int flip_value = (1 << (image->comps[0].prec-1));
|
||||
int max_value = (~(-1 << image->comps[0].prec));
|
||||
|
||||
if(dst->numcomps != 3) return;
|
||||
|
||||
w = image->comps[0].w;
|
||||
h = image->comps[0].h;
|
||||
|
||||
s0 = image->comps[0].data;
|
||||
s1 = image->comps[1].data;
|
||||
s2 = image->comps[2].data;
|
||||
|
||||
sign1 = image->comps[1].sgnd;
|
||||
sign2 = image->comps[2].sgnd;
|
||||
|
||||
max = w * h;
|
||||
|
||||
r = dst->red = (int*)malloc(max * sizeof(int));
|
||||
g = dst->green = (int*)malloc(max * sizeof(int));
|
||||
b = dst->blue = (int*)malloc(max * sizeof(int));
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
{
|
||||
|
||||
y = *s0++; cb = *s1++; cr = *s2++;
|
||||
|
||||
if( !sign1) cb -= flip_value;
|
||||
if( !sign2) cr -= flip_value;
|
||||
|
||||
val = (int)
|
||||
((float)y - (float)0.0000368 * (float)cb
|
||||
+ (float)1.40199 * (float)cr + (float)0.5);
|
||||
|
||||
if(val > max_value) val = max_value; else if(val < 0) val = 0;
|
||||
*r++ = val;
|
||||
|
||||
val = (int)
|
||||
((float)1.0003 * (float)y - (float)0.344125 * (float)cb
|
||||
- (float)0.7141128 * (float)cr + (float)0.5);
|
||||
|
||||
if(val > max_value) val = max_value; else if(val < 0) val = 0;
|
||||
*g++ = val;
|
||||
|
||||
val = (int)
|
||||
((float)0.999823 * (float)y + (float)1.77204 * (float)cb
|
||||
- (float)0.000008 *(float)cr + (float)0.5);
|
||||
|
||||
if(val > max_value) val = max_value; else if(val < 0) val = 0;
|
||||
*b++ = val;
|
||||
}
|
||||
dst->free_red = 1;
|
||||
dst->free_green = 1;
|
||||
dst->free_blue = 1;
|
||||
dst->numcomps = 3;
|
||||
dst->color_space = OPJ_CLRSPC_SRGB;
|
||||
|
||||
image->color_space = OPJ_CLRSPC_SRGB;
|
||||
|
||||
}// COLOR_esycc_to_rgb()
|
||||
|
||||
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,61 @@
|
|||
#ifndef _FLIMAGE_COLOR_HH_
|
||||
#define _FLIMAGE_COLOR_HH_
|
||||
|
||||
/*
|
||||
* Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
|
||||
* Copyright (c) 2002-2007, Professor Benoit Macq
|
||||
* Copyright (c) 2001-2003, David Janssens
|
||||
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
|
||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
typedef struct image_info
|
||||
{
|
||||
int *red;
|
||||
int *green;
|
||||
int *blue;
|
||||
int *alpha;
|
||||
unsigned int numcomps;
|
||||
OPJ_COLOR_SPACE color_space;
|
||||
|
||||
unsigned int dx[4], dy[4], prec[4], sgnd[4];
|
||||
|
||||
unsigned char free_red, free_green, free_blue, unused_alpha;
|
||||
int has_alpha;
|
||||
int is_still;
|
||||
|
||||
} ImageInfo;
|
||||
|
||||
#if defined(OPJ_HAVE_LIBLCMS1) || defined(OPJ_HAVE_LIBLCMS2)
|
||||
extern void COLOR_apply_icc_profile(opj_image_t *image, ImageInfo *dst);
|
||||
extern void COLOR_apply_conversion(opj_image_t *image, ImageInfo *dst);
|
||||
#endif
|
||||
|
||||
extern void COLOR_sycc_to_rgb(opj_image_t *img, ImageInfo *dst);
|
||||
extern void COLOR_cmyk_to_rgb(opj_image_t *image, ImageInfo *dst);
|
||||
extern void COLOR_esycc_to_rgb(opj_image_t *image, ImageInfo *dst);
|
||||
|
||||
#endif /* _FLIMAGE_COLOR_HH_ */
|
|
@ -0,0 +1,25 @@
|
|||
#ifndef _FLIMAGE_CONFIG_H_
|
||||
#define _FLIMAGE_CONFIG_H
|
||||
|
||||
#define PACKAGE_VERSION "@FLVIEWER_VERSION@"
|
||||
#define PACKAGE_STRING "@FLVIEWER_PACKAGE_STRING@"
|
||||
|
||||
#cmakedefine WITH_ENGLISH
|
||||
#cmakedefine WITH_GERMAN
|
||||
|
||||
#cmakedefine HAVE_THREADS
|
||||
#cmakedefine HAVE_WINPORT
|
||||
|
||||
#cmakedefine HAVE_FSEEKI64 @HAVE_FSEEKI64@
|
||||
#cmakedefine HAVE_FSEEKO
|
||||
|
||||
#cmakedefine _LARGEFILE_SOURCE
|
||||
#cmakedefine _FILE_OFFSET_BITS @_FILE_OFFSET_BITS@
|
||||
|
||||
#if !defined(__APPLE__)
|
||||
#cmakedefine OPJ_BIG_ENDIAN
|
||||
#elif defined(__BIG_ENDIAN__)
|
||||
#cmakedefine OPJ_BIG_ENDIAN
|
||||
#endif
|
||||
#
|
||||
#endif /* _FLIMAGE_CONFIG_H_ */
|
|
@ -0,0 +1,41 @@
|
|||
#flimage-VERSION
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
|
||||
#
|
||||
PROJECT(convert)
|
||||
#
|
||||
IF(COMMAND CMAKE_POLICY)
|
||||
CMAKE_POLICY(SET CMP0003 NEW)
|
||||
ENDIF(COMMAND CMAKE_POLICY)
|
||||
#
|
||||
SET(CONVERT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
#
|
||||
FIND_PACKAGE(FLTK REQUIRED)
|
||||
#
|
||||
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
|
||||
#
|
||||
INCLUDE_DIRECTORIES(
|
||||
${FLTK_DIR}/include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_BINARY_DIR}
|
||||
)
|
||||
#-------------------
|
||||
IF(UNIX)
|
||||
FIND_PROGRAM(FLTK_CONFIG_SCRIPT fltk-config PATHS ${FLTK_BIN_DIR})
|
||||
#
|
||||
EXEC_PROGRAM(${FLTK_CONFIG_SCRIPT} ARGS --use-images --ldflags
|
||||
OUTPUT_VARIABLE LIBS)
|
||||
ELSE(UNIX)
|
||||
SET(LIBS ${FLTK_BASE_LIBRARY} ${FLTK_FORMS_LIBRARY} ${FLTK_GL_LIBRARY} ${FLTK_IMAGES_LIBRARY} )
|
||||
ENDIF(UNIX)
|
||||
|
||||
#-------------------
|
||||
SET(exe convert)
|
||||
SET(SRCS convert.cxx)
|
||||
ADD_EXECUTABLE(${exe} ${SRCS})
|
||||
TARGET_LINK_LIBRARIES(${exe} ${LIBS})
|
||||
#
|
||||
INSTALL(TARGETS ${exe}
|
||||
RUNTIME
|
||||
DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
#
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
cmake -DFLTK_INCLUDE_DIR:path="/usr/local/fltk13/" ..
|
||||
|
|
@ -0,0 +1 @@
|
|||
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXE_LINKER_FLAGS:string="/machine:x64" -DCMAKE_LIBRARY_PATH:path="C:/Users/Public" -DCMAKE_INCLUDE_PATH:path="C:/Users/Public/include" ..
|
|
@ -0,0 +1,40 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <FL/fl_utf8.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
const char *fname;
|
||||
char *write_idf;
|
||||
FILE *reader, *writer;
|
||||
unsigned int slen;
|
||||
char s[128];
|
||||
char d[512];
|
||||
|
||||
if(argc == 1) return 1;
|
||||
fname = argv[1];
|
||||
reader = fopen(fname, "r");
|
||||
if(reader == NULL)
|
||||
{
|
||||
printf("Can not open src file %s\n",fname);
|
||||
return 1;
|
||||
}
|
||||
slen = strlen(fname);
|
||||
write_idf = (char*)malloc(slen+8);
|
||||
strcpy(write_idf, fname); strcpy(write_idf+slen,"_utf8");
|
||||
printf("RESULT in:%s\n",write_idf);
|
||||
|
||||
writer = fopen(write_idf, "w");
|
||||
|
||||
while(fgets(s, 127, reader))
|
||||
{
|
||||
fl_utf8froma(d,512,s,strlen(s));
|
||||
|
||||
fprintf(writer,"%s", d);
|
||||
}
|
||||
|
||||
fclose(reader); fclose(writer); free(write_idf);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
#ifndef _FLIMAGE_PRINT_DIALOG_LANG_H_
|
||||
#define _FLIMAGE_PRINT_DIALOG_LANG_H_
|
||||
/* static const char _s[]={""}; */
|
||||
#ifdef WITH_ENGLISH
|
||||
static const char YES_s[]={"YES"};
|
||||
static const char NO_s[]={"NO"};
|
||||
static const char PRINTERPAGE_s[]={"Print Image (PostScript)"};
|
||||
static const char FILENAME_s[]={"Filename:"};
|
||||
static const char PRINT_s[]={"Print"};
|
||||
static const char PRINTCMD_s[]={"Command:"};
|
||||
static const char PRINTERNAMES_s[]={"Name:"};
|
||||
static const char PRINTER_s[]={"Printer"};
|
||||
static const char PRINTTO_s[]={"Print To"};
|
||||
static const char FILE_s[]={"File"};
|
||||
static const char CONTINUE_PRINT_s[]=
|
||||
{"File already exists.\n Continue?"};
|
||||
static const char COPIES_s[]={"Copies:"};
|
||||
static const char PORTRAIT_s[]={"Portrait"};
|
||||
static const char LANDSCAPE_s[]={"Landscape"};
|
||||
static const char LOWRES_s[]={"Low resolution"};
|
||||
static const char HIRES_s[]={"High resolution"};
|
||||
static const char COLOR_s[]={"Color"};
|
||||
static const char GRAY_s[]={"Gray"};
|
||||
static const char DOCFORMAT_s[]={"Format"};
|
||||
static const char OK_s[]={"OK"};
|
||||
static const char CANCEL_s[]={"Cancel"};
|
||||
|
||||
static const char NAME_s[]={"Name:"};
|
||||
static const char TITLE_s[]={"Title:"};
|
||||
static const char IMAGE_s[]={"Image"};
|
||||
static const char CENTER_s[]={"Center"};
|
||||
static const char MARGINS_s[]={"Margins(mm)"};
|
||||
static const char LEFT_s[]={"Left:"};
|
||||
static const char RIGHT_s[]={"Right:"};
|
||||
static const char TOP_s[]={"Top:"};
|
||||
static const char BOTTOM_s[]={"Bottom:"};
|
||||
static const char LOC_s[]={"Loc:"};
|
||||
static const char NO_FILENAME_FOUND_s[]=
|
||||
{"No file name found. Please enter."};
|
||||
static const char NAME_IS_DIR_s[]=
|
||||
{"Name exists and is directory name. Please change."};
|
||||
#endif /* WITH_ENGLISH */
|
||||
|
||||
#ifdef WITH_GERMAN
|
||||
|
||||
static const char YES_s[]={"Ja"};
|
||||
static const char NO_s[]={"Nein"};
|
||||
static const char NO_FILENAME_FOUND_s[]=
|
||||
{"Kein Datei-Name gefunden. Bitte eingeben."};
|
||||
static const char NAME_IS_DIR_s[]=
|
||||
{"Name ist Verzeichnis-Name. Bitte ändern."};
|
||||
static const char LOC_s[]={"Ort:"};
|
||||
static const char PRINTERPAGE_s[]={"Bild drucken (PostScript)"};
|
||||
static const char FILENAME_s[]={"Datei-Name:"};
|
||||
static const char PRINT_s[]={"Drucken"};
|
||||
static const char PRINTCMD_s[]={"Befehl:"};
|
||||
static const char PRINTERNAMES_s[]={"Name:"};
|
||||
static const char PRINTER_s[]={"Drucker"};
|
||||
static const char PRINTTO_s[]={"Ziel"};
|
||||
static const char FILE_s[]={"Datei"};
|
||||
static const char CONTINUE_PRINT_s[]=
|
||||
{"Datei besteht bereits.\n Weiter?"};
|
||||
static const char COPIES_s[]={"Kopien:"};
|
||||
static const char PORTRAIT_s[]={"Vertikal-Druck"};
|
||||
static const char LANDSCAPE_s[]={"Quer-Druck"};
|
||||
static const char LOWRES_s[]={"Auflösung gering"};
|
||||
static const char HIRES_s[]={"Auflösung hoch"};
|
||||
static const char COLOR_s[]={"Farbig"};
|
||||
static const char GRAY_s[]={"Grau"};
|
||||
static const char DOCFORMAT_s[]={"Format"};
|
||||
static const char OK_s[]={"OK"};
|
||||
static const char CANCEL_s[]={"Abbruch"};
|
||||
|
||||
static const char NAME_s[]={"Name:"};
|
||||
static const char TITLE_s[]={"Titel:"};
|
||||
static const char IMAGE_s[]={"Bild"};
|
||||
static const char CENTER_s[]={"Zentrieren"};
|
||||
static const char MARGINS_s[]={"Ränder(mm)"};
|
||||
static const char LEFT_s[]={"Links:"};
|
||||
static const char RIGHT_s[]={"Rechts:"};
|
||||
static const char TOP_s[]={"Oben:"};
|
||||
static const char BOTTOM_s[]={"Unten:"};
|
||||
|
||||
#endif /* WITH_GERMAN */
|
||||
|
||||
|
||||
|
||||
#endif /* _FLIMAGE_PRINT_DIALOG_LANG_H_ */
|
|
@ -0,0 +1,17 @@
|
|||
#ifndef _FLIMAGE_MJ2_FILE_LANG_H_
|
||||
#define _FLIMAGE_MJ2_FILE_LANG_H_
|
||||
|
||||
//static const char _s[]={""};
|
||||
#ifdef WITH_ENGLISH
|
||||
static const char MJ2_NO_FRAMES_FROM_s[]={"MJ2:Can not extract frames from"};
|
||||
static const char MJ2_SHOW_FAILS_s[]=
|
||||
{"MJ2:Can not show file\n%s\n samples(%d) width(%d) height(%d)"};
|
||||
#endif
|
||||
|
||||
#ifdef WITH_GERMAN
|
||||
static const char MJ2_NO_FRAMES_FROM_s[]={"MJ2:kann nichts finden in"};
|
||||
static const char MJ2_SHOW_FAILS_s[]=
|
||||
{"MJ2:kann Datei nicht zeigen für\n%s\n Bilder(%d) Weite(%d) Höhe(%d)"};
|
||||
#endif
|
||||
|
||||
#endif /* _FLIMAGE_MJ2_FILE_LANG_H_ */
|
|
@ -0,0 +1,30 @@
|
|||
#ifndef _FLIMAGE_OPJ_FILE_LANG_H_
|
||||
#define _FLIMAGE_OPJ_FILE_LANG_H_
|
||||
|
||||
//static const char _s[]={""};
|
||||
#ifdef WITH_ENGLISH
|
||||
static const char JPEG2000_DECODE_FAILS_s[]={"Got no JPEG2000 image for"};
|
||||
static const char DST_DID_NOT_OPEN_s[]={"Destination %s\n\tdid not open"};
|
||||
static const char WRITE_JPEG2000_FAILS_s[]={"Writing JPEG2000 file fails"};
|
||||
static const char GOT_NO_IMAGE_s[]={"opj_image_create() failed"};
|
||||
static const char WRONG_DST_EXT_s[]=
|
||||
{"Destination file %s\nhas wrong extension"};
|
||||
static const char WRITE_JP2_FAILS_s[]={"Writing JP2 file fails"};
|
||||
static const char JP2_DECODE_FAILS_s[]={"Got no JP2 image for"};
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef WITH_GERMAN
|
||||
static const char JPEG2000_DECODE_FAILS_s[]={"JPEG2000 Dekodierungsfehler für"};
|
||||
static const char DST_DID_NOT_OPEN_s[]={"Ziel-Datei %s\n\töffnet nicht"};
|
||||
static const char WRITE_JPEG2000_FAILS_s[]=
|
||||
{"JPEG2000-Datei läßt sich nicht schreiben"};
|
||||
static const char GOT_NO_IMAGE_s[]={"opj_image_create() scheitert"};
|
||||
static const char WRONG_DST_EXT_s[]=
|
||||
{"Ziel-Datei %s\nhat falsche Extension"};
|
||||
static const char WRITE_JP2_FAILS_s[]={"JP2-Datei läßt sich nicht schreiben"};
|
||||
static const char JP2_DECODE_FAILS_s[]={"JP2 Dekodierungsfehler für"};
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _FLIMAGE_OPJ_FILE_LANG_H_ */
|
|
@ -0,0 +1,15 @@
|
|||
#ifndef _FLIMAGE_PNG_LANG_H_
|
||||
#define _FLIMAGE_PNG_LANG_H_
|
||||
//static const char _s[]={""};
|
||||
#ifdef WITH_ENGLISH
|
||||
static const char DST_DID_NOT_OPEN_s[]={"Destination %s\n\tdid not open"};
|
||||
static const char WRITE_PNG_FAILS_s[]={"Writing PNG file fails"};
|
||||
|
||||
#endif
|
||||
#ifdef WITH_GERMAN
|
||||
static const char DST_DID_NOT_OPEN_s[]={"Ziel-Datei %s\n\töffnet nicht"};
|
||||
static const char WRITE_PNG_FAILS_s[]={"PNG-Datei läßt sich nicht schreiben"};
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _FLIMAGE_PNG_LANG_H_ */
|
|
@ -0,0 +1,119 @@
|
|||
#ifndef _FLIMAGE_FILE_LANG_H_
|
||||
#define _FLIMAGE_FILE_LANG_H_
|
||||
//static const char _s[]={""};
|
||||
#ifdef WITH_ENGLISH
|
||||
static const char CANNOT_USE_FILE_s[]= {"Can not use file"};
|
||||
static const char NO_DRIVER_FOUND_s[]= {"NO DRIVER FOUND"};
|
||||
static const char FILE_NOT_FOUND_s[]= {"File not found"};
|
||||
static const char CANNOT_LOAD_FILE_s[]= {"Can not load file"};
|
||||
static const char FILESIZE_TOO_LONG_s[]={"filesize too large. Ignored."};
|
||||
static const char NO_FILE_TO_PRINT_s[]={"No file to print."};
|
||||
static const char FILE_SIZE_ZERO_s[]={"File length is zero"};
|
||||
static const char USE_SYSTEM_COMMAND_TO_PRINT_s[]=
|
||||
{"Please use the system command(s)\nto print the file:"};
|
||||
static const char TILE_s[]={"Tile:"};
|
||||
static const char OF_s[]={" of "};
|
||||
static const char RELOAD_s[]={"Reload"};
|
||||
static const char REDUCTION_s[]={"Reduction:"};
|
||||
static const char NO_FILE_TO_SAVE_s[]={"No file to save"};
|
||||
static const char SAVE_AS_PNG_s[]={"Save As PNG"};
|
||||
static const char ENTER_PNG_TO_SAVE_s[]=
|
||||
{"Enter a name to save a PNG file:"};
|
||||
static const char FILE_EXISTS_s[]=
|
||||
{"File already exists.\n Continue?"};
|
||||
static const char SAVE_AS_OPJ_s[]={"Save As JP2/J2K"};
|
||||
static const char ENTER_OPJ_TO_SAVE_s[]=
|
||||
{"Enter a name to save a JP2/J2K file:"};
|
||||
static const char MISSING_PNG_EXT_s[]={"File extension not '.png'. Goon?"};
|
||||
static const char AREA_s[]={"Area:"};
|
||||
static const char FILENAME_TOO_LONG_s[]={"filename too long. Ignored."};
|
||||
|
||||
static const char EXIT_s[]={"Exit"};
|
||||
static const char STOP_s[]={"Stop"};
|
||||
static const char GOON_s[]={"Go on"};
|
||||
static const char RESTART_s[]={"Restart"};
|
||||
static const char FORWARD_s[]={"Step @>"};
|
||||
static const char BACKWARD_s[]={"@< Step"};
|
||||
static const char CLOSEFILE_s[]={"Close"};
|
||||
static const char BROWSE_s[]={"Browse"};
|
||||
static const char START_s[]={"Start:"};
|
||||
static const char ALLFRAMES_s[]={"Frames:"};
|
||||
static const char ALLTRACKS_s[]={"Tracks:"};
|
||||
static const char FILENAME_s[]={"File:"};
|
||||
static const char BLEND_s[]={"Blend"};
|
||||
static const char SHOW_s[]={"Show"};
|
||||
static const char LAYERS_s[]={"Layer:"};
|
||||
static const char WAITPLEASE_s[]={"Please, wait ..."};
|
||||
static const char SUCCESS_WITH_s[]={"Success with file:"};
|
||||
static const char FAILURE_WITH_s[]={"Failure with file:"};
|
||||
static const char POPUP_EXIT_s[]={"_Exit"};
|
||||
static const char PRINT_s[]={"Print"};
|
||||
static const char CANNOT_OPEN_s[]={"Can not open file:"};
|
||||
static const char GAMMA_s[]={"Gamma:"};
|
||||
static const char BRIGHTNESS_s[]={"Brightness:"};
|
||||
static const char CONTRAST_s[]={"Contrast:"};
|
||||
static const char CANCEL_s[]={"Cancel"};
|
||||
static const char CROP_s[]={"Section"};
|
||||
static const char LAYER_s[]={"Layer:"};
|
||||
static const char COMPONENT_s[]={"Component:"};
|
||||
#endif
|
||||
|
||||
#ifdef WITH_GERMAN
|
||||
static const char LAYER_s[]={"Schicht:"};
|
||||
static const char COMPONENT_s[]={"Komponente:"};
|
||||
static const char PRINT_s[]={"Drucken"};
|
||||
static const char POPUP_EXIT_s[]={"_Abbruch"};
|
||||
static const char CANNOT_OPEN_s[]={"Kann Datei nicht öffnen:"};
|
||||
static const char SUCCESS_WITH_s[]={"Erfolg mit Datei:"};
|
||||
static const char FAILURE_WITH_s[]={"Fehler mit Datei:"};
|
||||
static const char EXIT_s[]={"Abbruch"};
|
||||
static const char STOP_s[]={"Anhalten"};
|
||||
static const char GOON_s[]={"Weiter"};
|
||||
static const char RESTART_s[]={"Neustart"};
|
||||
static const char FORWARD_s[]={"Schritt @>"};
|
||||
static const char BACKWARD_s[]={"@< Schritt"};
|
||||
static const char CLOSEFILE_s[]={"Ende"};
|
||||
static const char BROWSE_s[]={"Suchen"};
|
||||
static const char START_s[]={"Start:"};
|
||||
static const char ALLFRAMES_s[]={"Rahmen:"};
|
||||
static const char ALLTRACKS_s[]={"Tracks:"};
|
||||
static const char FILENAME_s[]={"Datei:"};
|
||||
static const char BLEND_s[]={"Mischen"};
|
||||
static const char SHOW_s[]={"Zeigen"};
|
||||
static const char LAYERS_s[]={"Schicht:"};
|
||||
static const char WAITPLEASE_s[]={"Bitte warten ..."};
|
||||
static const char GAMMA_s[]={"Gamma:"};
|
||||
static const char BRIGHTNESS_s[]={"Helligkeit:"};
|
||||
static const char CONTRAST_s[]={"Kontrast:"};
|
||||
static const char CANCEL_s[]={"Abbruch"};
|
||||
static const char CROP_s[]={"Ausschnitt"};
|
||||
|
||||
static const char CANNOT_USE_FILE_s[]= {"Kann Datei nicht verwenden"};
|
||||
static const char NO_DRIVER_FOUND_s[]= {"KEIN TREIBER GEFUNDEN"};
|
||||
static const char FILE_NOT_FOUND_s[]= {"Datei nicht gefunden"};
|
||||
static const char CANNOT_LOAD_FILE_s[]= {"Kann Datei nicht laden"};
|
||||
static const char FILESIZE_TOO_LONG_s[]={"Datei ist zu groß. Ignoriert."};
|
||||
static const char NO_FILE_TO_PRINT_s[]={"Keine druckbare Datei gefunden."};
|
||||
static const char FILE_SIZE_ZERO_s[]={"Datei-Länge ist 0"};
|
||||
static const char USE_SYSTEM_COMMAND_TO_PRINT_s[]=
|
||||
{"Bitte System-Befehl(e) benutzen,\num folgende Datei zu drucken:"};
|
||||
static const char TILE_s[]={"Kachel:"};
|
||||
static const char OF_s[]={" von "};
|
||||
static const char RELOAD_s[]={"Neu laden"};
|
||||
static const char REDUCTION_s[]={"Verkleinerung:"};
|
||||
static const char NO_FILE_TO_SAVE_s[]={"Keine Datei zum Sichern gefunden"};
|
||||
static const char SAVE_AS_PNG_s[]={"Sichern als PNG"};
|
||||
static const char ENTER_PNG_TO_SAVE_s[]=
|
||||
{"Einen Name eingeben für eine PNG Datei:"};
|
||||
static const char FILE_EXISTS_s[]=
|
||||
{"Datei besteht bereits.\n Weiter?"};
|
||||
static const char SAVE_AS_OPJ_s[]={"Sichern als JP2/J2K"};
|
||||
static const char ENTER_OPJ_TO_SAVE_s[]=
|
||||
{"Einen Name eingeben für eine JP2/J2K Datei:"};
|
||||
static const char MISSING_PNG_EXT_s[]={"Datei-Endung nicht '.png'. Weiter?"};
|
||||
static const char AREA_s[]={"Fläche:"};
|
||||
static const char FILENAME_TOO_LONG_s[]={"Datei-Name zu lang. Ignoriert."};
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _FLIMAGE_LANG_H_ */
|
|
@ -0,0 +1,10 @@
|
|||
LIBS=`fltk-config --ldflags`
|
||||
INC=`fltk-config --cflags`
|
||||
CC=g++
|
||||
|
||||
Convert:
|
||||
rm -f convert
|
||||
$(CC) -Wall $(INC) convert.c -o convert $(LIBS)
|
||||
|
||||
clean:
|
||||
rm -f convert
|
|
@ -0,0 +1,40 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <FL/fl_utf8.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
const char *fname;
|
||||
char *write_idf;
|
||||
FILE *reader, *writer;
|
||||
unsigned int slen;
|
||||
char s[128];
|
||||
char d[512];
|
||||
|
||||
if(argc == 1) return 1;
|
||||
fname = argv[1];
|
||||
reader = fopen(fname, "r");
|
||||
if(reader == NULL)
|
||||
{
|
||||
printf("Can not open src file %s\n",fname);
|
||||
return 1;
|
||||
}
|
||||
slen = strlen(fname);
|
||||
write_idf = (char*)malloc(slen+8);
|
||||
strcpy(write_idf, fname); strcpy(write_idf+slen,"_utf8");
|
||||
printf("RESULT in:%s\n",write_idf);
|
||||
|
||||
writer = fopen(write_idf, "w");
|
||||
|
||||
while(fgets(s, 127, reader))
|
||||
{
|
||||
fl_utf8froma(d,512,s,strlen(s));
|
||||
|
||||
fprintf(writer,"%s", d);
|
||||
}
|
||||
|
||||
fclose(reader); fclose(writer); free(write_idf);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
#ifndef _FLIMAGE_PRINT_DIALOG_LANG_H_
|
||||
#define _FLIMAGE_PRINT_DIALOG_LANG_H_
|
||||
/* static const char _s[]={""}; */
|
||||
#ifdef WITH_ENGLISH
|
||||
static const char YES_s[]={"YES"};
|
||||
static const char NO_s[]={"NO"};
|
||||
static const char PRINTERPAGE_s[]={"Print Image (PostScript)"};
|
||||
static const char FILENAME_s[]={"Filename:"};
|
||||
static const char PRINT_s[]={"Print"};
|
||||
static const char PRINTCMD_s[]={"Command:"};
|
||||
static const char PRINTERNAMES_s[]={"Name:"};
|
||||
static const char PRINTER_s[]={"Printer"};
|
||||
static const char PRINTTO_s[]={"Print To"};
|
||||
static const char FILE_s[]={"File"};
|
||||
static const char CONTINUE_PRINT_s[]=
|
||||
{"File already exists.\n Continue?"};
|
||||
static const char COPIES_s[]={"Copies:"};
|
||||
static const char PORTRAIT_s[]={"Portrait"};
|
||||
static const char LANDSCAPE_s[]={"Landscape"};
|
||||
static const char LOWRES_s[]={"Low resolution"};
|
||||
static const char HIRES_s[]={"High resolution"};
|
||||
static const char COLOR_s[]={"Color"};
|
||||
static const char GRAY_s[]={"Gray"};
|
||||
static const char DOCFORMAT_s[]={"Format"};
|
||||
static const char OK_s[]={"OK"};
|
||||
static const char CANCEL_s[]={"Cancel"};
|
||||
|
||||
static const char NAME_s[]={"Name:"};
|
||||
static const char TITLE_s[]={"Title:"};
|
||||
static const char IMAGE_s[]={"Image"};
|
||||
static const char CENTER_s[]={"Center"};
|
||||
static const char MARGINS_s[]={"Margins(mm)"};
|
||||
static const char LEFT_s[]={"Left:"};
|
||||
static const char RIGHT_s[]={"Right:"};
|
||||
static const char TOP_s[]={"Top:"};
|
||||
static const char BOTTOM_s[]={"Bottom:"};
|
||||
static const char LOC_s[]={"Loc:"};
|
||||
static const char NO_FILENAME_FOUND_s[]=
|
||||
{"No file name found. Please enter."};
|
||||
static const char NAME_IS_DIR_s[]=
|
||||
{"Name exists and is directory name. Please change."};
|
||||
#endif /* WITH_ENGLISH */
|
||||
|
||||
#ifdef WITH_GERMAN
|
||||
|
||||
static const char YES_s[]={"Ja"};
|
||||
static const char NO_s[]={"Nein"};
|
||||
static const char NO_FILENAME_FOUND_s[]=
|
||||
{"Kein Datei-Name gefunden. Bitte eingeben."};
|
||||
static const char NAME_IS_DIR_s[]=
|
||||
{"Name ist Verzeichnis-Name. Bitte ändern."};
|
||||
static const char LOC_s[]={"Ort:"};
|
||||
static const char PRINTERPAGE_s[]={"Bild drucken (PostScript)"};
|
||||
static const char FILENAME_s[]={"Datei-Name:"};
|
||||
static const char PRINT_s[]={"Drucken"};
|
||||
static const char PRINTCMD_s[]={"Befehl:"};
|
||||
static const char PRINTERNAMES_s[]={"Name:"};
|
||||
static const char PRINTER_s[]={"Drucker"};
|
||||
static const char PRINTTO_s[]={"Ziel"};
|
||||
static const char FILE_s[]={"Datei"};
|
||||
static const char CONTINUE_PRINT_s[]=
|
||||
{"Datei besteht bereits.\n Weiter?"};
|
||||
static const char COPIES_s[]={"Kopien:"};
|
||||
static const char PORTRAIT_s[]={"Vertikal-Druck"};
|
||||
static const char LANDSCAPE_s[]={"Quer-Druck"};
|
||||
static const char LOWRES_s[]={"Auflösung gering"};
|
||||
static const char HIRES_s[]={"Auflösung hoch"};
|
||||
static const char COLOR_s[]={"Farbig"};
|
||||
static const char GRAY_s[]={"Grau"};
|
||||
static const char DOCFORMAT_s[]={"Format"};
|
||||
static const char OK_s[]={"OK"};
|
||||
static const char CANCEL_s[]={"Abbruch"};
|
||||
|
||||
static const char NAME_s[]={"Name:"};
|
||||
static const char TITLE_s[]={"Titel:"};
|
||||
static const char IMAGE_s[]={"Bild"};
|
||||
static const char CENTER_s[]={"Zentrieren"};
|
||||
static const char MARGINS_s[]={"Ränder(mm)"};
|
||||
static const char LEFT_s[]={"Links:"};
|
||||
static const char RIGHT_s[]={"Rechts:"};
|
||||
static const char TOP_s[]={"Oben:"};
|
||||
static const char BOTTOM_s[]={"Unten:"};
|
||||
|
||||
#endif /* WITH_GERMAN */
|
||||
|
||||
|
||||
|
||||
#endif /* _FLIMAGE_PRINT_DIALOG_LANG_H_ */
|
|
@ -0,0 +1,17 @@
|
|||
#ifndef _FLIMAGE_MJ2_FILE_LANG_H_
|
||||
#define _FLIMAGE_MJ2_FILE_LANG_H_
|
||||
|
||||
//static const char _s[]={""};
|
||||
#ifdef WITH_ENGLISH
|
||||
static const char MJ2_NO_FRAMES_FROM_s[]={"MJ2:Can not extract frames from"};
|
||||
static const char MJ2_SHOW_FAILS_s[]=
|
||||
{"MJ2:Can not show file\n%s\n samples(%d) width(%d) height(%d)"};
|
||||
#endif
|
||||
|
||||
#ifdef WITH_GERMAN
|
||||
static const char MJ2_NO_FRAMES_FROM_s[]={"MJ2:kann nichts finden in"};
|
||||
static const char MJ2_SHOW_FAILS_s[]=
|
||||
{"MJ2:kann Datei nicht zeigen für\n%s\n Bilder(%d) Weite(%d) Höhe(%d)"};
|
||||
#endif
|
||||
|
||||
#endif /* _FLIMAGE_MJ2_FILE_LANG_H_ */
|
|
@ -0,0 +1,30 @@
|
|||
#ifndef _FLIMAGE_OPJ_FILE_LANG_H_
|
||||
#define _FLIMAGE_OPJ_FILE_LANG_H_
|
||||
|
||||
//static const char _s[]={""};
|
||||
#ifdef WITH_ENGLISH
|
||||
static const char JPEG2000_DECODE_FAILS_s[]={"Got no JPEG2000 image for"};
|
||||
static const char DST_DID_NOT_OPEN_s[]={"Destination %s\n\tdid not open"};
|
||||
static const char WRITE_JPEG2000_FAILS_s[]={"Writing JPEG2000 file fails"};
|
||||
static const char GOT_NO_IMAGE_s[]={"opj_image_create() failed"};
|
||||
static const char WRONG_DST_EXT_s[]=
|
||||
{"Destination file %s\nhas wrong extension"};
|
||||
static const char WRITE_JP2_FAILS_s[]={"Writing JP2 file fails"};
|
||||
static const char JP2_DECODE_FAILS_s[]={"Got no JP2 image for"};
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef WITH_GERMAN
|
||||
static const char JPEG2000_DECODE_FAILS_s[]={"JPEG2000 Dekodierungsfehler für"};
|
||||
static const char DST_DID_NOT_OPEN_s[]={"Ziel-Datei %s\n\töffnet nicht"};
|
||||
static const char WRITE_JPEG2000_FAILS_s[]=
|
||||
{"JPEG2000-Datei läßt sich nicht schreiben"};
|
||||
static const char GOT_NO_IMAGE_s[]={"opj_image_create() scheitert"};
|
||||
static const char WRONG_DST_EXT_s[]=
|
||||
{"Ziel-Datei %s\nhat falsche Extension"};
|
||||
static const char WRITE_JP2_FAILS_s[]={"JP2-Datei läßt sich nicht schreiben"};
|
||||
static const char JP2_DECODE_FAILS_s[]={"JP2 Dekodierungsfehler für"};
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _FLIMAGE_OPJ_FILE_LANG_H_ */
|
|
@ -0,0 +1,15 @@
|
|||
#ifndef _FLIMAGE_PNG_LANG_H_
|
||||
#define _FLIMAGE_PNG_LANG_H_
|
||||
//static const char _s[]={""};
|
||||
#ifdef WITH_ENGLISH
|
||||
static const char DST_DID_NOT_OPEN_s[]={"Destination %s\n\tdid not open"};
|
||||
static const char WRITE_PNG_FAILS_s[]={"Writing PNG file fails"};
|
||||
|
||||
#endif
|
||||
#ifdef WITH_GERMAN
|
||||
static const char DST_DID_NOT_OPEN_s[]={"Ziel-Datei %s\n\töffnet nicht"};
|
||||
static const char WRITE_PNG_FAILS_s[]={"PNG-Datei läßt sich nicht schreiben"};
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _FLIMAGE_PNG_LANG_H_ */
|
|
@ -0,0 +1,119 @@
|
|||
#ifndef _FLIMAGE_FILE_LANG_H_
|
||||
#define _FLIMAGE_FILE_LANG_H_
|
||||
//static const char _s[]={""};
|
||||
#ifdef WITH_ENGLISH
|
||||
static const char CANNOT_USE_FILE_s[]= {"Can not use file"};
|
||||
static const char NO_DRIVER_FOUND_s[]= {"NO DRIVER FOUND"};
|
||||
static const char FILE_NOT_FOUND_s[]= {"File not found"};
|
||||
static const char CANNOT_LOAD_FILE_s[]= {"Can not load file"};
|
||||
static const char FILESIZE_TOO_LONG_s[]={"filesize too large. Ignored."};
|
||||
static const char NO_FILE_TO_PRINT_s[]={"No file to print."};
|
||||
static const char FILE_SIZE_ZERO_s[]={"File length is zero"};
|
||||
static const char USE_SYSTEM_COMMAND_TO_PRINT_s[]=
|
||||
{"Please use the system command(s)\nto print the file:"};
|
||||
static const char TILE_s[]={"Tile:"};
|
||||
static const char OF_s[]={" of "};
|
||||
static const char RELOAD_s[]={"Reload"};
|
||||
static const char REDUCTION_s[]={"Reduction:"};
|
||||
static const char NO_FILE_TO_SAVE_s[]={"No file to save"};
|
||||
static const char SAVE_AS_PNG_s[]={"Save As PNG"};
|
||||
static const char ENTER_PNG_TO_SAVE_s[]=
|
||||
{"Enter a name to save a PNG file:"};
|
||||
static const char FILE_EXISTS_s[]=
|
||||
{"File already exists.\n Continue?"};
|
||||
static const char SAVE_AS_OPJ_s[]={"Save As JP2/J2K"};
|
||||
static const char ENTER_OPJ_TO_SAVE_s[]=
|
||||
{"Enter a name to save a JP2/J2K file:"};
|
||||
static const char MISSING_PNG_EXT_s[]={"File extension not '.png'. Goon?"};
|
||||
static const char AREA_s[]={"Area:"};
|
||||
static const char FILENAME_TOO_LONG_s[]={"filename too long. Ignored."};
|
||||
|
||||
static const char EXIT_s[]={"Exit"};
|
||||
static const char STOP_s[]={"Stop"};
|
||||
static const char GOON_s[]={"Go on"};
|
||||
static const char RESTART_s[]={"Restart"};
|
||||
static const char FORWARD_s[]={"Step @>"};
|
||||
static const char BACKWARD_s[]={"@< Step"};
|
||||
static const char CLOSEFILE_s[]={"Close"};
|
||||
static const char BROWSE_s[]={"Browse"};
|
||||
static const char START_s[]={"Start:"};
|
||||
static const char ALLFRAMES_s[]={"Frames:"};
|
||||
static const char ALLTRACKS_s[]={"Tracks:"};
|
||||
static const char FILENAME_s[]={"File:"};
|
||||
static const char BLEND_s[]={"Blend"};
|
||||
static const char SHOW_s[]={"Show"};
|
||||
static const char LAYERS_s[]={"Layer:"};
|
||||
static const char WAITPLEASE_s[]={"Please, wait ..."};
|
||||
static const char SUCCESS_WITH_s[]={"Success with file:"};
|
||||
static const char FAILURE_WITH_s[]={"Failure with file:"};
|
||||
static const char POPUP_EXIT_s[]={"_Exit"};
|
||||
static const char PRINT_s[]={"Print"};
|
||||
static const char CANNOT_OPEN_s[]={"Can not open file:"};
|
||||
static const char GAMMA_s[]={"Gamma:"};
|
||||
static const char BRIGHTNESS_s[]={"Brightness:"};
|
||||
static const char CONTRAST_s[]={"Contrast:"};
|
||||
static const char CANCEL_s[]={"Cancel"};
|
||||
static const char CROP_s[]={"Section"};
|
||||
static const char LAYER_s[]={"Layer:"};
|
||||
static const char COMPONENT_s[]={"Component:"};
|
||||
#endif
|
||||
|
||||
#ifdef WITH_GERMAN
|
||||
static const char LAYER_s[]={"Schicht:"};
|
||||
static const char COMPONENT_s[]={"Komponente:"};
|
||||
static const char PRINT_s[]={"Drucken"};
|
||||
static const char POPUP_EXIT_s[]={"_Abbruch"};
|
||||
static const char CANNOT_OPEN_s[]={"Kann Datei nicht öffnen:"};
|
||||
static const char SUCCESS_WITH_s[]={"Erfolg mit Datei:"};
|
||||
static const char FAILURE_WITH_s[]={"Fehler mit Datei:"};
|
||||
static const char EXIT_s[]={"Abbruch"};
|
||||
static const char STOP_s[]={"Anhalten"};
|
||||
static const char GOON_s[]={"Weiter"};
|
||||
static const char RESTART_s[]={"Neustart"};
|
||||
static const char FORWARD_s[]={"Schritt @>"};
|
||||
static const char BACKWARD_s[]={"@< Schritt"};
|
||||
static const char CLOSEFILE_s[]={"Ende"};
|
||||
static const char BROWSE_s[]={"Suchen"};
|
||||
static const char START_s[]={"Start:"};
|
||||
static const char ALLFRAMES_s[]={"Rahmen:"};
|
||||
static const char ALLTRACKS_s[]={"Tracks:"};
|
||||
static const char FILENAME_s[]={"Datei:"};
|
||||
static const char BLEND_s[]={"Mischen"};
|
||||
static const char SHOW_s[]={"Zeigen"};
|
||||
static const char LAYERS_s[]={"Schicht:"};
|
||||
static const char WAITPLEASE_s[]={"Bitte warten ..."};
|
||||
static const char GAMMA_s[]={"Gamma:"};
|
||||
static const char BRIGHTNESS_s[]={"Helligkeit:"};
|
||||
static const char CONTRAST_s[]={"Kontrast:"};
|
||||
static const char CANCEL_s[]={"Abbruch"};
|
||||
static const char CROP_s[]={"Ausschnitt"};
|
||||
|
||||
static const char CANNOT_USE_FILE_s[]= {"Kann Datei nicht verwenden"};
|
||||
static const char NO_DRIVER_FOUND_s[]= {"KEIN TREIBER GEFUNDEN"};
|
||||
static const char FILE_NOT_FOUND_s[]= {"Datei nicht gefunden"};
|
||||
static const char CANNOT_LOAD_FILE_s[]= {"Kann Datei nicht laden"};
|
||||
static const char FILESIZE_TOO_LONG_s[]={"Datei ist zu groß. Ignoriert."};
|
||||
static const char NO_FILE_TO_PRINT_s[]={"Keine druckbare Datei gefunden."};
|
||||
static const char FILE_SIZE_ZERO_s[]={"Datei-Länge ist 0"};
|
||||
static const char USE_SYSTEM_COMMAND_TO_PRINT_s[]=
|
||||
{"Bitte System-Befehl(e) benutzen,\num folgende Datei zu drucken:"};
|
||||
static const char TILE_s[]={"Kachel:"};
|
||||
static const char OF_s[]={" von "};
|
||||
static const char RELOAD_s[]={"Neu laden"};
|
||||
static const char REDUCTION_s[]={"Verkleinerung:"};
|
||||
static const char NO_FILE_TO_SAVE_s[]={"Keine Datei zum Sichern gefunden"};
|
||||
static const char SAVE_AS_PNG_s[]={"Sichern als PNG"};
|
||||
static const char ENTER_PNG_TO_SAVE_s[]=
|
||||
{"Einen Name eingeben für eine PNG Datei:"};
|
||||
static const char FILE_EXISTS_s[]=
|
||||
{"Datei besteht bereits.\n Weiter?"};
|
||||
static const char SAVE_AS_OPJ_s[]={"Sichern als JP2/J2K"};
|
||||
static const char ENTER_OPJ_TO_SAVE_s[]=
|
||||
{"Einen Name eingeben für eine JP2/J2K Datei:"};
|
||||
static const char MISSING_PNG_EXT_s[]={"Datei-Endung nicht '.png'. Weiter?"};
|
||||
static const char AREA_s[]={"Fläche:"};
|
||||
static const char FILENAME_TOO_LONG_s[]={"Datei-Name zu lang. Ignoriert."};
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _FLIMAGE_LANG_H_ */
|
|
@ -0,0 +1,32 @@
|
|||
|
||||
flviewer /home/IMG/MJ2/hall-420-1056x576-yuv-r00.mj2
|
||||
|
||||
|
||||
*** glibc detected *** /graphics/FLVIEWER/TRUNK-2.0/v0.1.6/openjpeg-2.x-trunk-r2871-1-flviewer-0.1.6/BUILD/bin/flviewer: double free or corruption (fasttop): 0x00007fffec17f680 ***
|
||||
^C
|
||||
Program received signal SIGINT, Interrupt.
|
||||
0x00007ffff63a2a94 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
|
||||
(gdb) bt
|
||||
#0 0x00007ffff63a2a94 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
|
||||
#1 0x000000000041c782 in get_rgb_buffer() ()
|
||||
#2 0x000000000041dc44 in OPENMJ2_load(canvas*, char const*, unsigned long) ()
|
||||
#3 0x000000000040a3d8 in chooser_cb(char const*) ()
|
||||
#4 0x00007ffff72bb5ba in Fl_Widget::do_callback(Fl_Widget*, void*) ()
|
||||
from /usr/local/fltk13/lib/libfltk.so.1.3
|
||||
#5 0x00007ffff72982d3 in Fl_Input_::handletext(int, int, int, int, int) ()
|
||||
from /usr/local/fltk13/lib/libfltk.so.1.3
|
||||
#6 0x00007ffff727b5ca in Fl::focus(Fl_Widget*) () from /usr/local/fltk13/lib/libfltk.so.1.3
|
||||
#7 0x00007ffff72bb442 in Fl_Widget::take_focus() () from /usr/local/fltk13/lib/libfltk.so.1.3
|
||||
#8 0x00007ffff728bbb7 in Fl_Group::navigation(int) () from /usr/local/fltk13/lib/libfltk.so.1.3
|
||||
#9 0x00007ffff728c0e9 in Fl_Group::handle(int) () from /usr/local/fltk13/lib/libfltk.so.1.3
|
||||
#10 0x00007ffff727af1d in send(int, Fl_Widget*, Fl_Window*) ()
|
||||
from /usr/local/fltk13/lib/libfltk.so.1.3
|
||||
#11 0x00007ffff727c676 in Fl::handle_(int, Fl_Window*) () from /usr/local/fltk13/lib/libfltk.so.1.3
|
||||
#12 0x00007ffff727c59e in Fl::handle_(int, Fl_Window*) () from /usr/local/fltk13/lib/libfltk.so.1.3
|
||||
#13 0x00007ffff72c1d58 in fl_handle(_XEvent const&) () from /usr/local/fltk13/lib/libfltk.so.1.3
|
||||
#14 0x00007ffff72c1de5 in do_queued_events() () from /usr/local/fltk13/lib/libfltk.so.1.3
|
||||
#15 0x00007ffff72c1f9a in fl_wait(double) () from /usr/local/fltk13/lib/libfltk.so.1.3
|
||||
#16 0x00007ffff727c16d in Fl::wait(double) () from /usr/local/fltk13/lib/libfltk.so.1.3
|
||||
#17 0x00007ffff727c193 in Fl::run() () from /usr/local/fltk13/lib/libfltk.so.1.3
|
||||
#18 0x0000000000408039 in main ()
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,97 @@
|
|||
#ifndef _FLVIEWER_HH_
|
||||
#define _FLVIEWER_HH_
|
||||
|
||||
#include <FL/Fl_Shared_Image.H>
|
||||
#include <FL/Fl_RGB_Image.H>
|
||||
#include <limits.h>
|
||||
|
||||
/* off_t st_size; */
|
||||
#define FILESIZE_LIMIT (LONG_MAX - 100)
|
||||
|
||||
#define IS_MOVIE 0
|
||||
#define IS_STILL 1
|
||||
|
||||
#define FULLY_OPAQUE 255
|
||||
#define FULLY_TRANSPARENT 0
|
||||
|
||||
#ifdef _WIN32
|
||||
#define strcasecmp _stricmp
|
||||
#define strncasecmp _strnicmp
|
||||
#define snprintf _snprintf
|
||||
#define sprintf _scprintf
|
||||
#define strdup _strdup
|
||||
#define popen _popen
|
||||
#define pclose _pclose
|
||||
#endif /* _WIN32 */
|
||||
|
||||
typedef struct canvas
|
||||
{
|
||||
Fl_RGB_Image *new_rgb;
|
||||
const char *read_idf;
|
||||
const void *cbuf;
|
||||
int new_iwidth, new_iheight, new_idepth;
|
||||
int selected_frame, top_frame;
|
||||
int selected_track, top_track;
|
||||
unsigned char bg_red, bg_green, bg_blue;
|
||||
|
||||
void (*pause)(void);
|
||||
void (*resume)(void);
|
||||
void (*restart)(void);
|
||||
void (*forward)(void);
|
||||
void (*backward)(void);
|
||||
void (*fin)(void);
|
||||
void (*cleanup)(void);
|
||||
void (*current)(void);
|
||||
|
||||
} Canvas;
|
||||
|
||||
extern char *root_dir;
|
||||
|
||||
/* PROTOTYPES */
|
||||
|
||||
extern void FLViewer_url(const char *fname, int w, int h);
|
||||
extern void FLViewer_animation(int v);
|
||||
extern void FLViewer_frames_animation(int v);
|
||||
|
||||
extern void FLViewer_show_frame(int n, int m);
|
||||
extern int FLViewer_frame_selected(void);
|
||||
extern void FLViewer_wait(void);
|
||||
|
||||
extern void FLViewer_clear_wait(void);
|
||||
extern void FLViewer_use_buffer(const void *b, unsigned int w, unsigned int h,
|
||||
int depth);
|
||||
|
||||
extern void FLViewer_movie_runs(int v);
|
||||
extern void FLViewer_close_reader(void);
|
||||
|
||||
extern void FLViewer_mj2_animation(int v);
|
||||
|
||||
extern int FLViewer_has_tile_and_reduction(void);
|
||||
extern void FLViewer_put_max_tiles_and_reduction(int mx_tiles, int mx_reduct);
|
||||
extern void FLViewer_get_max_tiles_and_reduction(int *out_mx_tiles,
|
||||
int *out_mx_reduct);
|
||||
|
||||
extern void FLViewer_get_tile_and_reduction(int *out_tile, int *out_reduct);
|
||||
extern void FLViewer_tiles_activate(int v);
|
||||
|
||||
extern void FLViewer_area_activate(int v);
|
||||
extern int FLViewer_has_area_values();
|
||||
extern void FLViewer_get_area_values(int *out_x0, int *out_y0,
|
||||
int *out_x1, int *out_y1);
|
||||
|
||||
extern void FLViewer_reset_tiles_and_reduction();
|
||||
extern void FLViewer_set_max_reduction(int mx_reduct);
|
||||
extern void FLViewer_set_max_tiles(int mx_tiles);
|
||||
|
||||
extern int FLViewer_nr_threads(void);
|
||||
extern void FLViewer_canvas_top_frame(int v);
|
||||
|
||||
extern void FLViewer_threads_activate(int v);
|
||||
extern void FLViewer_header_deactivate();
|
||||
|
||||
extern void FLViewer_layer_component_activate(int v);
|
||||
|
||||
extern void FLViewer_clear_tree();
|
||||
extern void FLViewer_show_track(int n, int m);
|
||||
|
||||
#endif /* _FLVIEWER_HH_ */
|
|
@ -0,0 +1,67 @@
|
|||
#ifndef _HAVE_THREADS_HH_
|
||||
#define _HAVE_THREADS_HH_
|
||||
|
||||
#if defined(HAVE_NPTH_THREADS) && defined(_WIN32)
|
||||
|
||||
#define PTHREAD_mutex_lock npth_mutex_lock
|
||||
#define PTHREAD_mutex_unlock npth_mutex_unlock
|
||||
#define PTHREAD_mutex_init npth_mutex_init
|
||||
#define PTHREAD_mutex_destroy npth_mutex_destroy
|
||||
|
||||
#define PTHREAD_cond_wait npth_cond_wait
|
||||
#define PTHREAD_cond_signal npth_cond_signal
|
||||
#define PTHREAD_cond_init npth_cond_init
|
||||
#define PTHREAD_cond_broadcast npth_cond_broadcast
|
||||
#define PTHREAD_cond_destroy npth_cond_destroy
|
||||
|
||||
#define PTHREAD_create npth_create
|
||||
#define PTHREAD_join npth_join
|
||||
|
||||
#define PTHREAD_cond_t npth_cond_t
|
||||
#define PTHREAD_mutex_t npth_mutex_t
|
||||
#define PTHREAD_t npth_t
|
||||
|
||||
#define PTHREAD_init npth_init
|
||||
|
||||
#elif defined(_WIN32)
|
||||
|
||||
#define PTHREAD_mutex_lock pthread_mutex_lock
|
||||
#define PTHREAD_mutex_unlock pthread_mutex_unlock
|
||||
#define PTHREAD_mutex_init pthread_mutex_init
|
||||
#define PTHREAD_mutex_destroy pthread_mutex_destroy
|
||||
|
||||
#define PTHREAD_cond_wait pthread_cond_wait
|
||||
#define PTHREAD_cond_signal pthread_cond_signal
|
||||
#define PTHREAD_cond_init pthread_cond_init
|
||||
#define PTHREAD_cond_broadcast pthread_cond_broadcast
|
||||
#define PTHREAD_cond_destroy pthread_cond_destroy
|
||||
|
||||
#define PTHREAD_create pthread_create
|
||||
#define PTHREAD_join pthread_join
|
||||
|
||||
#define PTHREAD_cond_t pthread_cond_t
|
||||
#define PTHREAD_mutex_t pthread_mutex_t
|
||||
#define PTHREAD_t pthread_t
|
||||
|
||||
#else /* not _WIN32 */
|
||||
|
||||
#define PTHREAD_mutex_lock pthread_mutex_lock
|
||||
#define PTHREAD_mutex_unlock pthread_mutex_unlock
|
||||
#define PTHREAD_mutex_init pthread_mutex_init
|
||||
#define PTHREAD_mutex_destroy pthread_mutex_destroy
|
||||
|
||||
#define PTHREAD_cond_wait pthread_cond_wait
|
||||
#define PTHREAD_cond_signal pthread_cond_signal
|
||||
#define PTHREAD_cond_init pthread_cond_init
|
||||
#define PTHREAD_cond_broadcast pthread_cond_broadcast
|
||||
#define PTHREAD_cond_destroy pthread_cond_destroy
|
||||
|
||||
#define PTHREAD_create pthread_create
|
||||
#define PTHREAD_join pthread_join
|
||||
|
||||
#define PTHREAD_cond_t pthread_cond_t
|
||||
#define PTHREAD_mutex_t pthread_mutex_t
|
||||
#define PTHREAD_t pthread_t
|
||||
|
||||
#endif
|
||||
#endif /* _HAVE_THREADS_HH_ */
|
|
@ -0,0 +1,88 @@
|
|||
#ifndef _FLIMAGE_PRINT_DIALOG_LANG_H_
|
||||
#define _FLIMAGE_PRINT_DIALOG_LANG_H_
|
||||
/* static const char _s[]={""}; */
|
||||
#ifdef WITH_ENGLISH
|
||||
static const char YES_s[]={"YES"};
|
||||
static const char NO_s[]={"NO"};
|
||||
static const char PRINTERPAGE_s[]={"Print Image (PostScript)"};
|
||||
static const char FILENAME_s[]={"Filename:"};
|
||||
static const char PRINT_s[]={"Print"};
|
||||
static const char PRINTCMD_s[]={"Command:"};
|
||||
static const char PRINTERNAMES_s[]={"Name:"};
|
||||
static const char PRINTER_s[]={"Printer"};
|
||||
static const char PRINTTO_s[]={"Print To"};
|
||||
static const char FILE_s[]={"File"};
|
||||
static const char CONTINUE_PRINT_s[]=
|
||||
{"File already exists.\n Continue?"};
|
||||
static const char COPIES_s[]={"Copies:"};
|
||||
static const char PORTRAIT_s[]={"Portrait"};
|
||||
static const char LANDSCAPE_s[]={"Landscape"};
|
||||
static const char LOWRES_s[]={"Low resolution"};
|
||||
static const char HIRES_s[]={"High resolution"};
|
||||
static const char COLOR_s[]={"Color"};
|
||||
static const char GRAY_s[]={"Gray"};
|
||||
static const char DOCFORMAT_s[]={"Format"};
|
||||
static const char OK_s[]={"OK"};
|
||||
static const char CANCEL_s[]={"Cancel"};
|
||||
|
||||
static const char NAME_s[]={"Name:"};
|
||||
static const char TITLE_s[]={"Title:"};
|
||||
static const char IMAGE_s[]={"Image"};
|
||||
static const char CENTER_s[]={"Center"};
|
||||
static const char MARGINS_s[]={"Margins(mm)"};
|
||||
static const char LEFT_s[]={"Left:"};
|
||||
static const char RIGHT_s[]={"Right:"};
|
||||
static const char TOP_s[]={"Top:"};
|
||||
static const char BOTTOM_s[]={"Bottom:"};
|
||||
static const char LOC_s[]={"Loc:"};
|
||||
static const char NO_FILENAME_FOUND_s[]=
|
||||
{"No file name found. Please enter."};
|
||||
static const char NAME_IS_DIR_s[]=
|
||||
{"Name exists and is directory name. Please change."};
|
||||
#endif /* WITH_ENGLISH */
|
||||
|
||||
#ifdef WITH_GERMAN
|
||||
|
||||
static const char YES_s[]={"Ja"};
|
||||
static const char NO_s[]={"Nein"};
|
||||
static const char NO_FILENAME_FOUND_s[]=
|
||||
{"Kein Datei-Name gefunden. Bitte eingeben."};
|
||||
static const char NAME_IS_DIR_s[]=
|
||||
{"Name ist Verzeichnis-Name. Bitte ändern."};
|
||||
static const char LOC_s[]={"Ort:"};
|
||||
static const char PRINTERPAGE_s[]={"Bild drucken (PostScript)"};
|
||||
static const char FILENAME_s[]={"Datei-Name:"};
|
||||
static const char PRINT_s[]={"Drucken"};
|
||||
static const char PRINTCMD_s[]={"Befehl:"};
|
||||
static const char PRINTERNAMES_s[]={"Name:"};
|
||||
static const char PRINTER_s[]={"Drucker"};
|
||||
static const char PRINTTO_s[]={"Ziel"};
|
||||
static const char FILE_s[]={"Datei"};
|
||||
static const char CONTINUE_PRINT_s[]=
|
||||
{"Datei besteht bereits.\n Weiter?"};
|
||||
static const char COPIES_s[]={"Kopien:"};
|
||||
static const char PORTRAIT_s[]={"Vertikal-Druck"};
|
||||
static const char LANDSCAPE_s[]={"Quer-Druck"};
|
||||
static const char LOWRES_s[]={"Auflösung gering"};
|
||||
static const char HIRES_s[]={"Auflösung hoch"};
|
||||
static const char COLOR_s[]={"Farbig"};
|
||||
static const char GRAY_s[]={"Grau"};
|
||||
static const char DOCFORMAT_s[]={"Format"};
|
||||
static const char OK_s[]={"OK"};
|
||||
static const char CANCEL_s[]={"Abbruch"};
|
||||
|
||||
static const char NAME_s[]={"Name:"};
|
||||
static const char TITLE_s[]={"Titel:"};
|
||||
static const char IMAGE_s[]={"Bild"};
|
||||
static const char CENTER_s[]={"Zentrieren"};
|
||||
static const char MARGINS_s[]={"Ränder(mm)"};
|
||||
static const char LEFT_s[]={"Links:"};
|
||||
static const char RIGHT_s[]={"Rechts:"};
|
||||
static const char TOP_s[]={"Oben:"};
|
||||
static const char BOTTOM_s[]={"Unten:"};
|
||||
|
||||
#endif /* WITH_GERMAN */
|
||||
|
||||
|
||||
|
||||
#endif /* _FLIMAGE_PRINT_DIALOG_LANG_H_ */
|
|
@ -0,0 +1,17 @@
|
|||
#ifndef _FLIMAGE_MJ2_FILE_LANG_H_
|
||||
#define _FLIMAGE_MJ2_FILE_LANG_H_
|
||||
|
||||
//static const char _s[]={""};
|
||||
#ifdef WITH_ENGLISH
|
||||
static const char MJ2_NO_FRAMES_FROM_s[]={"MJ2:Can not extract frames from"};
|
||||
static const char MJ2_SHOW_FAILS_s[]=
|
||||
{"MJ2:Can not show file\n%s\n samples(%d) width(%d) height(%d)"};
|
||||
#endif
|
||||
|
||||
#ifdef WITH_GERMAN
|
||||
static const char MJ2_NO_FRAMES_FROM_s[]={"MJ2:kann nichts finden in"};
|
||||
static const char MJ2_SHOW_FAILS_s[]=
|
||||
{"MJ2:kann Datei nicht zeigen für\n%s\n Bilder(%d) Weite(%d) Höhe(%d)"};
|
||||
#endif
|
||||
|
||||
#endif /* _FLIMAGE_MJ2_FILE_LANG_H_ */
|
|
@ -0,0 +1,30 @@
|
|||
#ifndef _FLIMAGE_OPJ_FILE_LANG_H_
|
||||
#define _FLIMAGE_OPJ_FILE_LANG_H_
|
||||
|
||||
//static const char _s[]={""};
|
||||
#ifdef WITH_ENGLISH
|
||||
static const char JPEG2000_DECODE_FAILS_s[]={"Got no JPEG2000 image for"};
|
||||
static const char DST_DID_NOT_OPEN_s[]={"Destination %s\n\tdid not open"};
|
||||
static const char WRITE_JPEG2000_FAILS_s[]={"Writing JPEG2000 file fails"};
|
||||
static const char GOT_NO_IMAGE_s[]={"opj_image_create() failed"};
|
||||
static const char WRONG_DST_EXT_s[]=
|
||||
{"Destination file %s\nhas wrong extension"};
|
||||
static const char WRITE_JP2_FAILS_s[]={"Writing JP2 file fails"};
|
||||
static const char JP2_DECODE_FAILS_s[]={"Got no JP2 image for"};
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef WITH_GERMAN
|
||||
static const char JPEG2000_DECODE_FAILS_s[]={"JPEG2000 Dekodierungsfehler für"};
|
||||
static const char DST_DID_NOT_OPEN_s[]={"Ziel-Datei %s\n\töffnet nicht"};
|
||||
static const char WRITE_JPEG2000_FAILS_s[]=
|
||||
{"JPEG2000-Datei läßt sich nicht schreiben"};
|
||||
static const char GOT_NO_IMAGE_s[]={"opj_image_create() scheitert"};
|
||||
static const char WRONG_DST_EXT_s[]=
|
||||
{"Ziel-Datei %s\nhat falsche Extension"};
|
||||
static const char WRITE_JP2_FAILS_s[]={"JP2-Datei läßt sich nicht schreiben"};
|
||||
static const char JP2_DECODE_FAILS_s[]={"JP2 Dekodierungsfehler für"};
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _FLIMAGE_OPJ_FILE_LANG_H_ */
|
|
@ -0,0 +1,15 @@
|
|||
#ifndef _FLIMAGE_PNG_LANG_H_
|
||||
#define _FLIMAGE_PNG_LANG_H_
|
||||
//static const char _s[]={""};
|
||||
#ifdef WITH_ENGLISH
|
||||
static const char DST_DID_NOT_OPEN_s[]={"Destination %s\n\tdid not open"};
|
||||
static const char WRITE_PNG_FAILS_s[]={"Writing PNG file fails"};
|
||||
|
||||
#endif
|
||||
#ifdef WITH_GERMAN
|
||||
static const char DST_DID_NOT_OPEN_s[]={"Ziel-Datei %s\n\töffnet nicht"};
|
||||
static const char WRITE_PNG_FAILS_s[]={"PNG-Datei läßt sich nicht schreiben"};
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _FLIMAGE_PNG_LANG_H_ */
|
|
@ -0,0 +1,119 @@
|
|||
#ifndef _FLIMAGE_FILE_LANG_H_
|
||||
#define _FLIMAGE_FILE_LANG_H_
|
||||
//static const char _s[]={""};
|
||||
#ifdef WITH_ENGLISH
|
||||
static const char CANNOT_USE_FILE_s[]= {"Can not use file"};
|
||||
static const char NO_DRIVER_FOUND_s[]= {"NO DRIVER FOUND"};
|
||||
static const char FILE_NOT_FOUND_s[]= {"File not found"};
|
||||
static const char CANNOT_LOAD_FILE_s[]= {"Can not load file"};
|
||||
static const char FILESIZE_TOO_LONG_s[]={"filesize too large. Ignored."};
|
||||
static const char NO_FILE_TO_PRINT_s[]={"No file to print."};
|
||||
static const char FILE_SIZE_ZERO_s[]={"File length is zero"};
|
||||
static const char USE_SYSTEM_COMMAND_TO_PRINT_s[]=
|
||||
{"Please use the system command(s)\nto print the file:"};
|
||||
static const char TILE_s[]={"Tile:"};
|
||||
static const char OF_s[]={" of "};
|
||||
static const char RELOAD_s[]={"Reload"};
|
||||
static const char REDUCTION_s[]={"Reduction:"};
|
||||
static const char NO_FILE_TO_SAVE_s[]={"No file to save"};
|
||||
static const char SAVE_AS_PNG_s[]={"Save As PNG"};
|
||||
static const char ENTER_PNG_TO_SAVE_s[]=
|
||||
{"Enter a name to save a PNG file:"};
|
||||
static const char FILE_EXISTS_s[]=
|
||||
{"File already exists.\n Continue?"};
|
||||
static const char SAVE_AS_OPJ_s[]={"Save As JP2/J2K"};
|
||||
static const char ENTER_OPJ_TO_SAVE_s[]=
|
||||
{"Enter a name to save a JP2/J2K file:"};
|
||||
static const char MISSING_PNG_EXT_s[]={"File extension not '.png'. Goon?"};
|
||||
static const char AREA_s[]={"Area:"};
|
||||
static const char FILENAME_TOO_LONG_s[]={"filename too long. Ignored."};
|
||||
|
||||
static const char EXIT_s[]={"Exit"};
|
||||
static const char STOP_s[]={"Stop"};
|
||||
static const char GOON_s[]={"Go on"};
|
||||
static const char RESTART_s[]={"Restart"};
|
||||
static const char FORWARD_s[]={"Step @>"};
|
||||
static const char BACKWARD_s[]={"@< Step"};
|
||||
static const char CLOSEFILE_s[]={"Close"};
|
||||
static const char BROWSE_s[]={"Browse"};
|
||||
static const char START_s[]={"Start:"};
|
||||
static const char ALLFRAMES_s[]={"Frames:"};
|
||||
static const char ALLTRACKS_s[]={"Tracks:"};
|
||||
static const char FILENAME_s[]={"File:"};
|
||||
static const char BLEND_s[]={"Blend"};
|
||||
static const char SHOW_s[]={"Show"};
|
||||
static const char LAYERS_s[]={"Layer:"};
|
||||
static const char WAITPLEASE_s[]={"Please, wait ..."};
|
||||
static const char SUCCESS_WITH_s[]={"Success with file:"};
|
||||
static const char FAILURE_WITH_s[]={"Failure with file:"};
|
||||
static const char POPUP_EXIT_s[]={"_Exit"};
|
||||
static const char PRINT_s[]={"Print"};
|
||||
static const char CANNOT_OPEN_s[]={"Can not open file:"};
|
||||
static const char GAMMA_s[]={"Gamma:"};
|
||||
static const char BRIGHTNESS_s[]={"Brightness:"};
|
||||
static const char CONTRAST_s[]={"Contrast:"};
|
||||
static const char CANCEL_s[]={"Cancel"};
|
||||
static const char CROP_s[]={"Section"};
|
||||
static const char LAYER_s[]={"Layer:"};
|
||||
static const char COMPONENT_s[]={"Component:"};
|
||||
#endif
|
||||
|
||||
#ifdef WITH_GERMAN
|
||||
static const char LAYER_s[]={"Schicht:"};
|
||||
static const char COMPONENT_s[]={"Komponente:"};
|
||||
static const char PRINT_s[]={"Drucken"};
|
||||
static const char POPUP_EXIT_s[]={"_Abbruch"};
|
||||
static const char CANNOT_OPEN_s[]={"Kann Datei nicht öffnen:"};
|
||||
static const char SUCCESS_WITH_s[]={"Erfolg mit Datei:"};
|
||||
static const char FAILURE_WITH_s[]={"Fehler mit Datei:"};
|
||||
static const char EXIT_s[]={"Abbruch"};
|
||||
static const char STOP_s[]={"Anhalten"};
|
||||
static const char GOON_s[]={"Weiter"};
|
||||
static const char RESTART_s[]={"Neustart"};
|
||||
static const char FORWARD_s[]={"Schritt @>"};
|
||||
static const char BACKWARD_s[]={"@< Schritt"};
|
||||
static const char CLOSEFILE_s[]={"Ende"};
|
||||
static const char BROWSE_s[]={"Suchen"};
|
||||
static const char START_s[]={"Start:"};
|
||||
static const char ALLFRAMES_s[]={"Rahmen:"};
|
||||
static const char ALLTRACKS_s[]={"Tracks:"};
|
||||
static const char FILENAME_s[]={"Datei:"};
|
||||
static const char BLEND_s[]={"Mischen"};
|
||||
static const char SHOW_s[]={"Zeigen"};
|
||||
static const char LAYERS_s[]={"Schicht:"};
|
||||
static const char WAITPLEASE_s[]={"Bitte warten ..."};
|
||||
static const char GAMMA_s[]={"Gamma:"};
|
||||
static const char BRIGHTNESS_s[]={"Helligkeit:"};
|
||||
static const char CONTRAST_s[]={"Kontrast:"};
|
||||
static const char CANCEL_s[]={"Abbruch"};
|
||||
static const char CROP_s[]={"Ausschnitt"};
|
||||
|
||||
static const char CANNOT_USE_FILE_s[]= {"Kann Datei nicht verwenden"};
|
||||
static const char NO_DRIVER_FOUND_s[]= {"KEIN TREIBER GEFUNDEN"};
|
||||
static const char FILE_NOT_FOUND_s[]= {"Datei nicht gefunden"};
|
||||
static const char CANNOT_LOAD_FILE_s[]= {"Kann Datei nicht laden"};
|
||||
static const char FILESIZE_TOO_LONG_s[]={"Datei ist zu groß. Ignoriert."};
|
||||
static const char NO_FILE_TO_PRINT_s[]={"Keine druckbare Datei gefunden."};
|
||||
static const char FILE_SIZE_ZERO_s[]={"Datei-Länge ist 0"};
|
||||
static const char USE_SYSTEM_COMMAND_TO_PRINT_s[]=
|
||||
{"Bitte System-Befehl(e) benutzen,\num folgende Datei zu drucken:"};
|
||||
static const char TILE_s[]={"Kachel:"};
|
||||
static const char OF_s[]={" von "};
|
||||
static const char RELOAD_s[]={"Neu laden"};
|
||||
static const char REDUCTION_s[]={"Verkleinerung:"};
|
||||
static const char NO_FILE_TO_SAVE_s[]={"Keine Datei zum Sichern gefunden"};
|
||||
static const char SAVE_AS_PNG_s[]={"Sichern als PNG"};
|
||||
static const char ENTER_PNG_TO_SAVE_s[]=
|
||||
{"Einen Name eingeben für eine PNG Datei:"};
|
||||
static const char FILE_EXISTS_s[]=
|
||||
{"Datei besteht bereits.\n Weiter?"};
|
||||
static const char SAVE_AS_OPJ_s[]={"Sichern als JP2/J2K"};
|
||||
static const char ENTER_OPJ_TO_SAVE_s[]=
|
||||
{"Einen Name eingeben für eine JP2/J2K Datei:"};
|
||||
static const char MISSING_PNG_EXT_s[]={"Datei-Endung nicht '.png'. Weiter?"};
|
||||
static const char AREA_s[]={"Fläche:"};
|
||||
static const char FILENAME_TOO_LONG_s[]={"Datei-Name zu lang. Ignoriert."};
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _FLIMAGE_LANG_H_ */
|
|
@ -0,0 +1,89 @@
|
|||
#ifndef _FLVIEWER_PAPER_SIZES_HH_
|
||||
#define _FLVIEWER_PAPER_SIZES_HH_
|
||||
|
||||
#define PSIZE_POS 1
|
||||
|
||||
static struct papersize
|
||||
{
|
||||
const char *name;
|
||||
double paper_w, paper_h; /* in mm */
|
||||
const char *media_s;
|
||||
} paper_sizes[] = {
|
||||
{"A3", 297, 420, "A3"},
|
||||
{"A4", 210, 297, "A4"},
|
||||
{"A5", 148, 210, "A5"},
|
||||
{"A6", 105, 148, "BBox"},
|
||||
{"9x13 cm", 88.9, 127, "BBox"}, /* 3.5x5 inch */
|
||||
{"10x15 cm", 101.6, 152.4, "BBox"}, /* 4x6 inch */
|
||||
{"PHOTO4.5x6", 114.3, 152.4, "BBox"}, /* digital cameras */
|
||||
{"13x18 cm", 127, 177.8, "BBox"}, /* 5x7 inches */
|
||||
{"20x25 cm", 203.2, 254, "BBox"}, /* 8x10 inches */
|
||||
{"LETTER", 215.9, 297.4, "letter"}, /* 8.5x11 inches */
|
||||
{"LEDGER", 279.4, 431.8, "ledger"}, /* 11x17 inches */
|
||||
{"LEGAL", 215.9, 355.6, "legal"}, /* 8.5x14 inches */
|
||||
/*--
|
||||
{""},
|
||||
{""},
|
||||
{""},
|
||||
--*/
|
||||
{NULL, 0, 0, NULL}
|
||||
};
|
||||
|
||||
#ifdef INFO_ONLY
|
||||
/*----------------------
|
||||
DOTS MM
|
||||
media_w = paper_w * (72./25.4);
|
||||
media_h = paper_h * (72./25.4);
|
||||
|
||||
ISO 216 sizes
|
||||
(mm × mm) A Series
|
||||
A0 841 × 1189
|
||||
A1 594 × 841
|
||||
A2 420 × 594
|
||||
A3 297 × 420
|
||||
A4 210 × 297
|
||||
A5 148 × 210
|
||||
A6 105 × 148
|
||||
A7 74 × 105
|
||||
A8 52 × 74
|
||||
A9 37 × 52
|
||||
A10 26 × 37
|
||||
|
||||
ISO 216 sizes
|
||||
(mm × mm) B Series
|
||||
B0 1000 × 1414
|
||||
B1 707 × 1000
|
||||
B2 500 × 707
|
||||
B3 353 × 500
|
||||
B4 250 × 353
|
||||
B5 176 × 250
|
||||
B6 125 × 176
|
||||
B7 88 × 125
|
||||
B8 62 × 88
|
||||
B9 44 × 62
|
||||
B10 31 × 44
|
||||
|
||||
|
||||
269 sizes
|
||||
(mm × mm) C Series
|
||||
C0 917 × 1297
|
||||
C1 648 × 917
|
||||
C2 458 × 648
|
||||
C3 324 × 458
|
||||
C4 229 × 324
|
||||
C5 162 × 229
|
||||
C6 114 × 162
|
||||
C7/6 81 × 162
|
||||
C7 81 × 114
|
||||
C8 57 × 81
|
||||
C9 40 × 57
|
||||
C10 28 × 40
|
||||
DLE 110 × 220
|
||||
|
||||
|
||||
|
||||
----------------------*/
|
||||
#endif /* INFO_ONLY */
|
||||
|
||||
|
||||
#endif /* _FLVIEWER_PAPER_SIZES_HH_ */
|
|
@ -0,0 +1,721 @@
|
|||
#include <config.h>
|
||||
/*
|
||||
* author(s) and license
|
||||
*/
|
||||
/*
|
||||
* TODO: background_color other than FL_WHITE for transparent pixels
|
||||
* TODO: minimal margin: 6.35 mm (18 dots); 6.703 mm (19 dots)
|
||||
*/
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
|
||||
#define popen _popen
|
||||
#define pclose _pclose
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <FL/Fl.H>
|
||||
#include <FL/Fl_Window.H>
|
||||
#include <FL/Fl_Group.H>
|
||||
#include <FL/Fl_Input.H>
|
||||
#include <FL/Fl_Output.H>
|
||||
#include <FL/Fl_Button.H>
|
||||
#include <FL/Fl_Check_Button.H>
|
||||
#include <FL/Fl_Radio_Button.H>
|
||||
#include <FL/Fl_Round_Button.H>
|
||||
#include <FL/Fl_Int_Input.H>
|
||||
#include <FL/Fl_Float_Input.H>
|
||||
#include <FL/Fl_Choice.H>
|
||||
#include <FL/Fl_Menu_Item.H>
|
||||
#include <FL/fl_ask.H>
|
||||
#include <FL/filename.H>
|
||||
|
||||
|
||||
#include "lang/dialog_lang.h_utf8"
|
||||
#include "print_gui.hh"
|
||||
#include "paper_sizes.hh"
|
||||
|
||||
extern char *root_dir;
|
||||
/* configurable option ? */
|
||||
#define SHOW_PRINTER_LOC
|
||||
|
||||
#define LOCAL_PRINTER
|
||||
|
||||
#ifdef LOCAL_PRINTER
|
||||
#define LOCAL_CMD "pdq -P"
|
||||
#define LOCAL_NAME "postscript"
|
||||
#define LOCAL_LOC "Kyocera FS-920"
|
||||
#endif
|
||||
|
||||
#define PNAME_POS 0
|
||||
#define PRINT_CMD "lpr -P"
|
||||
|
||||
#define WIN_W 640
|
||||
#define WIN_H 380
|
||||
#define TAB_W (WIN_W - 10)
|
||||
#define GROUP_W TAB_W
|
||||
#define GROUP_H (WIN_H - 60)
|
||||
#define BOX_W (GROUP_W - 10)
|
||||
|
||||
|
||||
/* lpadmin -L "location" */
|
||||
|
||||
typedef struct printer_info
|
||||
{
|
||||
char *cmd;
|
||||
char *name;
|
||||
char *loc;
|
||||
}PrinterInfo;
|
||||
|
||||
static PrinterInfo *printer_info;
|
||||
|
||||
static void fill_paper_size(PrintInfo *print)
|
||||
{
|
||||
Fl_Choice *c = print->paper_size;
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while(paper_sizes[i].name)
|
||||
{
|
||||
c->add(paper_sizes[i].name);
|
||||
++i;
|
||||
}
|
||||
c->value(PSIZE_POS);
|
||||
print->paper_size_pos = PSIZE_POS;
|
||||
}
|
||||
|
||||
static void paper_size_cb(Fl_Widget *wid, void *v)
|
||||
{
|
||||
PrintInfo *print = (PrintInfo*)v;
|
||||
print->paper_size_pos = print->paper_size->value();
|
||||
}
|
||||
|
||||
static PrinterInfo *append(PrinterInfo *tab, const char *n)
|
||||
{
|
||||
const char *o;
|
||||
int i = 0;
|
||||
|
||||
if(tab)
|
||||
{
|
||||
while((o = tab[i].name))
|
||||
{
|
||||
if(strcmp(o, n) == 0) return tab;
|
||||
++i;
|
||||
}
|
||||
}
|
||||
tab = (PrinterInfo*)realloc(tab, (i+2)*sizeof(PrinterInfo));
|
||||
|
||||
if(tab != NULL)
|
||||
{
|
||||
tab[i].cmd = strdup(PRINT_CMD);
|
||||
tab[i].name = strdup(n);
|
||||
|
||||
tab[i].loc = strdup(n);
|
||||
|
||||
tab[i+1].name = NULL; tab[i+1].loc = NULL; tab[i+1].cmd = NULL;
|
||||
}
|
||||
return tab;
|
||||
}
|
||||
#ifndef _WIN32
|
||||
/*
|
||||
|
||||
lpstat -p
|
||||
|
||||
printer FS_920 is idle. enabled since ...
|
||||
printer HP_Desk is idle. enabled since ...
|
||||
*/
|
||||
static void add_lpr_printer_names(void)
|
||||
{
|
||||
FILE *p;
|
||||
char buf[1024];
|
||||
|
||||
if((p = popen("lpstat -p 2> /dev/null", "r")) == NULL)
|
||||
{
|
||||
fputs("\n Can not print\n", stderr);
|
||||
return;
|
||||
}
|
||||
while(fgets(buf, sizeof(buf), p) != NULL)
|
||||
{
|
||||
char *start, *end;
|
||||
|
||||
start = buf;
|
||||
if(strncmp(start, "printer ", 8) != 0) continue;
|
||||
start += 8;
|
||||
if(strstr(start, "enabled") == NULL) continue;
|
||||
end = start;
|
||||
while(*end && !isspace(*end)) ++end;
|
||||
*end = 0;
|
||||
printer_info = append(printer_info, start);
|
||||
}
|
||||
pclose(p);
|
||||
}
|
||||
#endif /* _WIN32 */
|
||||
|
||||
static void free_printer_info()
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
while(printer_info[i].name)
|
||||
{
|
||||
free(printer_info[i].cmd);
|
||||
free(printer_info[i].name);
|
||||
|
||||
free(printer_info[i].loc);
|
||||
|
||||
++i;
|
||||
}
|
||||
free(printer_info);
|
||||
|
||||
}
|
||||
|
||||
static void fill_printer_names(PrintInfo *print)
|
||||
{
|
||||
Fl_Choice *c = print->printer_name;
|
||||
int i = 0;
|
||||
|
||||
#ifdef LOCAL_PRINTER
|
||||
printer_info = (PrinterInfo*)calloc(2, sizeof(PrinterInfo));
|
||||
|
||||
printer_info[0].cmd = strdup(LOCAL_CMD);
|
||||
printer_info[0].name = strdup(LOCAL_NAME);
|
||||
printer_info[0].loc = strdup(LOCAL_LOC);
|
||||
|
||||
if(printer_info == NULL
|
||||
|| printer_info[0].cmd == NULL
|
||||
|| printer_info[0].name == NULL
|
||||
|| printer_info[0].loc == NULL)
|
||||
{
|
||||
fprintf(stderr,"print_gui.cxx:%d:\n\tmemory out\n",__LINE__);
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32
|
||||
add_lpr_printer_names();
|
||||
#endif /* _WIN32 */
|
||||
|
||||
while(printer_info[i].name)
|
||||
{
|
||||
c->add(printer_info[i].name);
|
||||
++i;
|
||||
}
|
||||
c->value(PNAME_POS);
|
||||
print->printer_pos = PNAME_POS;
|
||||
}
|
||||
|
||||
static void printer_name_cb(Fl_Widget *w, void *v)
|
||||
{
|
||||
PrintInfo *print = (PrintInfo*)v;
|
||||
print->printer_pos = print->printer_name->value();
|
||||
|
||||
#ifdef SHOW_PRINTER_LOC
|
||||
print->loc->value(printer_info[print->printer_pos].loc);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void to_printer_cb(Fl_Widget *wid, void *data)
|
||||
{
|
||||
Fl_Radio_Button *b = (Fl_Radio_Button*)wid;
|
||||
PrintInfo *print = (PrintInfo*)data;
|
||||
|
||||
if(!b->value())
|
||||
{
|
||||
print->printer_group->deactivate();
|
||||
print->file_group->activate();
|
||||
print->fname->value("image.ps");
|
||||
}
|
||||
else
|
||||
{
|
||||
print->printer_group->activate();
|
||||
print->fname->value("");
|
||||
print->file_group->deactivate();
|
||||
}
|
||||
}
|
||||
|
||||
static void to_file_cb(Fl_Widget *wid, void *data)
|
||||
{
|
||||
Fl_Radio_Button *b = (Fl_Radio_Button*)wid;
|
||||
PrintInfo *print = (PrintInfo*)data;
|
||||
|
||||
if(!b->value())
|
||||
{
|
||||
print->fname->value("");
|
||||
print->file_group->deactivate();
|
||||
print->printer_group->activate();
|
||||
}
|
||||
else
|
||||
{
|
||||
print->fname->value("image.ps");
|
||||
print->file_group->activate();
|
||||
print->printer_group->deactivate();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void portrait_cb(Fl_Widget *w, void *data)
|
||||
{
|
||||
PrintInfo *info = (PrintInfo*)data;
|
||||
info->paper_layout[0] = 'P';
|
||||
}
|
||||
|
||||
static void landscape_cb(Fl_Widget *w, void *data)
|
||||
{
|
||||
PrintInfo *info = (PrintInfo*)data;
|
||||
info->paper_layout[0] = 'L';
|
||||
}
|
||||
|
||||
static void lowres_cb(Fl_Widget *w, void *data)
|
||||
{
|
||||
PrintInfo *info = (PrintInfo*)data;
|
||||
info->resolution = 300;
|
||||
}
|
||||
|
||||
static void hires_cb(Fl_Widget *w, void *data)
|
||||
{
|
||||
PrintInfo *info = (PrintInfo*)data;
|
||||
info->resolution = 600;
|
||||
}
|
||||
|
||||
static void color_cb(Fl_Widget *w, void *data)
|
||||
{
|
||||
PrintInfo *info = (PrintInfo*)data;
|
||||
info->pcolor[0] = 'C';
|
||||
}
|
||||
|
||||
static void gray_cb(Fl_Widget *w, void *data)
|
||||
{
|
||||
PrintInfo *info = (PrintInfo*)data;
|
||||
info->pcolor[0] = 'G';
|
||||
}
|
||||
|
||||
static void ok_cb(Fl_Widget *w, void *data)
|
||||
{
|
||||
PrintInfo *print = (PrintInfo*)data;
|
||||
const char *cs;
|
||||
struct stat sb;
|
||||
|
||||
if(print->to_file->value())
|
||||
{
|
||||
cs = print->fname->value();
|
||||
if(*cs == 0)
|
||||
{
|
||||
fl_message("%s", NO_FILENAME_FOUND_s);
|
||||
return;
|
||||
}
|
||||
if(stat(cs, &sb) == 0)
|
||||
{
|
||||
if((sb.st_mode & S_IFMT) == S_IFDIR)
|
||||
{
|
||||
fl_message("%s", NAME_IS_DIR_s);
|
||||
return;
|
||||
}
|
||||
if(fl_choice(CONTINUE_PRINT_s, "NO", "YES", NULL) == 0) return;
|
||||
}
|
||||
print->fname_s = strdup(cs);
|
||||
|
||||
if(print->fname_s == NULL)
|
||||
{
|
||||
fprintf(stderr,"print_gui.cxx:%d:\n\tmemory out\n",__LINE__);
|
||||
exit(1);
|
||||
}
|
||||
}/* if(print->to_file->value()) */
|
||||
else
|
||||
if(print->to_printer->value())
|
||||
{
|
||||
size_t len = strlen(root_dir) + 20;
|
||||
|
||||
print->printer_s = strdup(print->printer_name->text());
|
||||
print->command_s = strdup(printer_info[print->printer_pos].cmd);
|
||||
print->fname_s = (char*)malloc(len);
|
||||
|
||||
if(print->printer_s == NULL
|
||||
|| print->command_s == NULL
|
||||
|| print->fname == NULL)
|
||||
{
|
||||
fprintf(stderr,"print_gui.cxx:%d:\n\tmemory out\n",__LINE__);
|
||||
exit(1);
|
||||
}
|
||||
#ifdef _WIN32
|
||||
sprintf_s(print->fname_s, len, "%s\\.flimage.ps", root_dir);
|
||||
#else
|
||||
snprintf(print->fname_s, len, "%s/.flimage.ps", root_dir);
|
||||
#endif
|
||||
print->remove_fname = 1;
|
||||
}/* if(print->to_printer->value()) */
|
||||
|
||||
print->format_s = strdup(paper_sizes[print->paper_size_pos].name);
|
||||
print->media_s = strdup(paper_sizes[print->paper_size_pos].media_s);
|
||||
|
||||
if(print->format_s == NULL || print->media_s == NULL)
|
||||
{
|
||||
fprintf(stderr,"print_gui.cxx:%d:\n\tmemory out\n",__LINE__);
|
||||
if(print->format_s) free(print->format_s);
|
||||
|
||||
exit(1);
|
||||
}
|
||||
print->fpaper_w = paper_sizes[print->paper_size_pos].paper_w;
|
||||
print->fpaper_h = paper_sizes[print->paper_size_pos].paper_h;
|
||||
|
||||
cs = print->copies->value();
|
||||
|
||||
if(*cs)
|
||||
print->nr_copies = atoi(cs);
|
||||
else
|
||||
print->nr_copies = 1;
|
||||
|
||||
print->title_s = strdup(print->title->value());
|
||||
|
||||
if(print->title_s == NULL)
|
||||
{
|
||||
fprintf(stderr,"print_gui.cxx:%d:\n\tmemory out\n",__LINE__);
|
||||
exit(1);
|
||||
}
|
||||
print->fmargin_lhs = atof(print->margin_lhs->value());
|
||||
print->fmargin_rhs = atof(print->margin_rhs->value());
|
||||
print->fmargin_top = atof(print->margin_top->value());
|
||||
print->fmargin_bot = atof(print->margin_bot->value());
|
||||
|
||||
print->center = print->center_image->value();
|
||||
if(print->paper_layout[0] == 'L')
|
||||
print->want_landscape = 1;
|
||||
else
|
||||
print->want_portrait = 1;
|
||||
|
||||
if(print-> pcolor[0] == 'C')
|
||||
print->want_color = 1;
|
||||
else
|
||||
print->want_gray = 1;
|
||||
|
||||
if(printer_info)
|
||||
free_printer_info();
|
||||
|
||||
delete print->win;
|
||||
|
||||
print->ok = 1;
|
||||
|
||||
print->win_destroy = 1;
|
||||
|
||||
}/* ok_cb() */
|
||||
|
||||
static void cancel_cb(Fl_Widget *, void *data)
|
||||
{
|
||||
PrintInfo *print = (PrintInfo*)data;
|
||||
|
||||
if(printer_info)
|
||||
free_printer_info();
|
||||
|
||||
delete print->win;
|
||||
|
||||
print->ok = 0;
|
||||
|
||||
print->win_destroy = 1;
|
||||
}
|
||||
|
||||
void Print_gui_create(PrintInfo *print)
|
||||
{
|
||||
Fl_Window* win;
|
||||
Fl_Group *page1;
|
||||
int x, y, group_x, group_y, top_y, lhs_x;
|
||||
int label_x, label_y;
|
||||
|
||||
print->win = win = new Fl_Window(WIN_W, WIN_H);
|
||||
win->box(FL_FLAT_BOX);
|
||||
win->color(FL_BACKGROUND_COLOR);
|
||||
win->begin();
|
||||
|
||||
group_x = 0; group_y = 20;
|
||||
|
||||
page1 = new Fl_Group(group_x, group_y, GROUP_W, GROUP_H, PRINTERPAGE_s);
|
||||
page1->box(FL_FLAT_BOX);
|
||||
page1->color(FL_BACKGROUND_COLOR);
|
||||
page1->labelfont(FL_HELVETICA_BOLD_ITALIC);
|
||||
page1->labelsize(13);
|
||||
page1->labelcolor(FL_BLACK);
|
||||
page1->begin();
|
||||
|
||||
group_x += 4; group_y += 12;
|
||||
{
|
||||
Fl_Group *format;
|
||||
|
||||
x = group_x; y = group_y;
|
||||
format = new Fl_Group(x, y, GROUP_W-6, 96);
|
||||
format->box(FL_EMBOSSED_BOX);
|
||||
format->begin();
|
||||
|
||||
x += 10; y -= 10;
|
||||
label_x = x; label_y = y;
|
||||
lhs_x = group_x; top_y = group_y + 12;
|
||||
x = lhs_x; y = top_y;
|
||||
{
|
||||
Fl_Round_Button *o;
|
||||
Fl_Group *g = new Fl_Group(x, y, 150, 40);
|
||||
g->begin();
|
||||
x += 3; y += 0;
|
||||
|
||||
Fl_Round_Button *r1 = new Fl_Round_Button(x, y, 150, 20, COLOR_s);
|
||||
r1->type(FL_RADIO_BUTTON);
|
||||
r1->callback(color_cb, print);
|
||||
r1->clear_visible_focus();
|
||||
print->color = r1;
|
||||
|
||||
y += 20;
|
||||
o = new Fl_Round_Button(x, y, 150, 20, GRAY_s);
|
||||
o->value(1);
|
||||
o->type(FL_RADIO_BUTTON);
|
||||
print->pcolor[0] = 'G';
|
||||
o->callback(gray_cb, print);
|
||||
o->clear_visible_focus();
|
||||
print->gray = o;
|
||||
g->end();
|
||||
y = g->y() + g->h();
|
||||
}
|
||||
x = lhs_x;
|
||||
{
|
||||
Fl_Round_Button *o;
|
||||
Fl_Group *g = new Fl_Group(x, y, 150, 40);
|
||||
g->begin();
|
||||
|
||||
x += 3; y += 0;
|
||||
o = new Fl_Round_Button(x, y, 150, 20, LOWRES_s);
|
||||
o->callback(lowres_cb, print);
|
||||
o->type(FL_RADIO_BUTTON);
|
||||
o->value(1);
|
||||
o->clear_visible_focus();
|
||||
print->resolution = 300;
|
||||
print->lowres = o;
|
||||
|
||||
y += 20;
|
||||
o = new Fl_Round_Button(x, y, 150, 20, HIRES_s);
|
||||
o->type(FL_RADIO_BUTTON);
|
||||
o->callback(hires_cb, print);
|
||||
o->clear_visible_focus();
|
||||
print->hires = o;
|
||||
|
||||
g->end();
|
||||
x = g->x() + g->w() + 10;
|
||||
}
|
||||
y = top_y;
|
||||
print->paper_size = new Fl_Choice(x,y,110,23);
|
||||
print->paper_size->clear_visible_focus();
|
||||
fill_paper_size(print);
|
||||
print->paper_size->callback(paper_size_cb, print);
|
||||
|
||||
y = top_y; x = format->w() - 154;
|
||||
{
|
||||
Fl_Round_Button *o;
|
||||
Fl_Group *g = new Fl_Group(x, y, 150, 40);
|
||||
g->begin();
|
||||
|
||||
x += 0; y += 0;
|
||||
o = new Fl_Round_Button(x, y, 150, 20, PORTRAIT_s);
|
||||
o->type(FL_RADIO_BUTTON);
|
||||
o->callback(portrait_cb, print);
|
||||
o->value(1);
|
||||
o->clear_visible_focus();
|
||||
print->paper_layout[0] = 'P';
|
||||
print->portrait = o;
|
||||
|
||||
y += 20;
|
||||
o = new Fl_Round_Button(x, y, 150, 20, LANDSCAPE_s);
|
||||
o->type(FL_RADIO_BUTTON);
|
||||
o->callback(landscape_cb, print);
|
||||
o->clear_visible_focus();
|
||||
print->landscape = o;
|
||||
|
||||
g->end();
|
||||
y = g->y() + g->h();
|
||||
}
|
||||
x = format->w() - 150;
|
||||
print->center_image = new Fl_Check_Button(x, y, 25, 25, CENTER_s);
|
||||
print->center_image->clear_visible_focus();
|
||||
|
||||
format->end();
|
||||
group_y = format->y() + format->h() + 12;
|
||||
{
|
||||
Fl_Group *c = new Fl_Group(label_x, label_y, 100, 20, DOCFORMAT_s);
|
||||
c->box(FL_EMBOSSED_BOX);
|
||||
c->align(FL_ALIGN_INSIDE);
|
||||
c->end();
|
||||
}
|
||||
}
|
||||
x = group_x; y = group_y;
|
||||
{
|
||||
Fl_Group *g;
|
||||
g = new Fl_Group(x, y, 178, 38);
|
||||
g->box(FL_EMBOSSED_BOX);
|
||||
g->begin();
|
||||
|
||||
label_x = x+10; label_y = y-10;
|
||||
x += 7; y += 12;
|
||||
{
|
||||
Fl_Round_Button *o = new Fl_Round_Button(x, y, 96, 22, PRINTER_s);
|
||||
o->type(FL_RADIO_BUTTON);
|
||||
o->callback(to_printer_cb, print);
|
||||
o->value(1);
|
||||
o->clear_visible_focus();
|
||||
print->to_printer = o;
|
||||
}
|
||||
x += 100;
|
||||
{
|
||||
Fl_Round_Button *o = new Fl_Round_Button(x, y, 67, 22, FILE_s);
|
||||
o->type(FL_RADIO_BUTTON);
|
||||
o->callback(to_file_cb, print);
|
||||
o->clear_visible_focus();
|
||||
print->to_file = o;
|
||||
}
|
||||
g->end();
|
||||
x = g->x() + g->w() + 1;
|
||||
{
|
||||
Fl_Group *c = new Fl_Group(label_x, label_y, 100, 20, PRINTTO_s);
|
||||
c->box(FL_EMBOSSED_BOX);
|
||||
c->align(FL_ALIGN_INSIDE);
|
||||
c->end();
|
||||
}
|
||||
}
|
||||
y = group_y;
|
||||
{
|
||||
Fl_Group *g;
|
||||
g = new Fl_Group(x, y, GROUP_W-x-4, 40);
|
||||
g->box(FL_EMBOSSED_BOX);
|
||||
g->begin();
|
||||
|
||||
label_x = x+10; label_y = y-10;
|
||||
x += 70; y += 12;
|
||||
{
|
||||
print->copies = new Fl_Int_Input(x, y, 50, 24, COPIES_s);
|
||||
print->copies->value("1");
|
||||
}
|
||||
x += 130;
|
||||
{
|
||||
print->title = new Fl_Input(x, y, g->x() + g->w()-x-4, 24, TITLE_s);
|
||||
print->title->value("No title");
|
||||
}
|
||||
g->end();
|
||||
group_y = g->y() + g->h() + 12;
|
||||
{
|
||||
Fl_Group *c = new Fl_Group(label_x, label_y, 100, 20, PRINT_s);
|
||||
c->box(FL_EMBOSSED_BOX);
|
||||
c->align(FL_ALIGN_INSIDE);
|
||||
c->end();
|
||||
}
|
||||
}
|
||||
x = group_x; y = group_y;
|
||||
print->printer_group = new Fl_Group(x, y-10, GROUP_W-6, 50);
|
||||
print->printer_group->begin();
|
||||
{
|
||||
Fl_Choice *o;
|
||||
Fl_Group *g;
|
||||
g = new Fl_Group(x, y, GROUP_W-6, 40);
|
||||
g->box(FL_EMBOSSED_BOX);
|
||||
g->begin();
|
||||
|
||||
label_x = x+10; label_y = y-10;
|
||||
x += 120; y += 12;
|
||||
o = new Fl_Choice(x, y, 140, 24, PRINTERNAMES_s);
|
||||
o->align(FL_ALIGN_LEFT);
|
||||
o->callback(printer_name_cb, print);
|
||||
print->printer_name = o;
|
||||
|
||||
fill_printer_names(print);
|
||||
|
||||
#ifdef SHOW_PRINTER_LOC
|
||||
x += 240;
|
||||
print->loc = new Fl_Output(x, y, 140, 24, LOC_s);
|
||||
print->loc->value(printer_info[print->printer_pos].loc);
|
||||
print->loc->clear_visible_focus();
|
||||
#endif
|
||||
g->end();
|
||||
{
|
||||
Fl_Group *c = new Fl_Group(label_x, label_y, 100, 20, PRINTER_s);
|
||||
c->box(FL_EMBOSSED_BOX);
|
||||
c->align(FL_ALIGN_INSIDE);
|
||||
c->end();
|
||||
}
|
||||
}
|
||||
print->printer_group->end();
|
||||
group_y = print->printer_group->y() + print->printer_group->h() + 12;
|
||||
|
||||
x = group_x; y = group_y;
|
||||
print->file_group = new Fl_Group(x, y-10, GROUP_W-6, 50);
|
||||
print->file_group->deactivate();
|
||||
print->file_group->begin();
|
||||
{
|
||||
Fl_Group *g;
|
||||
g = new Fl_Group(x, y, GROUP_W-6, 40);
|
||||
g->box(FL_EMBOSSED_BOX);
|
||||
g->begin();
|
||||
|
||||
label_x = x+10; label_y = y-10;
|
||||
x += 120; y += 12;
|
||||
print->fname = new Fl_Input(x, y, 280, 24, NAME_s);
|
||||
|
||||
g->end();
|
||||
{
|
||||
Fl_Group *c = new Fl_Group(label_x, label_y, 100, 20, FILE_s);
|
||||
c->box(FL_EMBOSSED_BOX);
|
||||
c->align(FL_ALIGN_INSIDE);
|
||||
c->end();
|
||||
}
|
||||
|
||||
}
|
||||
print->file_group->end();
|
||||
group_y = print->file_group->y() + print->file_group->h() + 12;
|
||||
|
||||
x = group_x; y = group_y;
|
||||
{
|
||||
Fl_Group *g = new Fl_Group(x, y, GROUP_W-6, 40);
|
||||
g->box(FL_EMBOSSED_BOX);
|
||||
g->begin();
|
||||
|
||||
label_x = x+10; label_y = y-10;
|
||||
x += 80; y += 12;
|
||||
print->margin_lhs = new Fl_Float_Input(x, y, 50, 24, LEFT_s);
|
||||
print->margin_lhs->value("25.51");
|
||||
|
||||
x += 130;
|
||||
print->margin_rhs = new Fl_Float_Input(x, y, 50, 24, RIGHT_s);
|
||||
print->margin_rhs->value("6.35");
|
||||
|
||||
x += 130;
|
||||
print->margin_top = new Fl_Float_Input(x, y, 50, 24, TOP_s);
|
||||
print->margin_top->value("6.35");
|
||||
|
||||
x += 130;
|
||||
print->margin_bot = new Fl_Float_Input(x, y, 50, 24, BOTTOM_s);
|
||||
print->margin_bot->value("6.35");
|
||||
|
||||
g->end();
|
||||
{
|
||||
Fl_Group *c = new Fl_Group(label_x, label_y, 100, 20, MARGINS_s);
|
||||
c->box(FL_EMBOSSED_BOX);
|
||||
c->align(FL_ALIGN_INSIDE);
|
||||
c->end();
|
||||
}
|
||||
|
||||
}
|
||||
page1->end();
|
||||
|
||||
y = WIN_H - 35;
|
||||
int dx = (WIN_W - 200)/3;
|
||||
x = dx;
|
||||
{
|
||||
Fl_Button* o = new Fl_Button(x, y, 100, 30, PRINT_s);
|
||||
o->callback(ok_cb, print);
|
||||
}
|
||||
x += 100 + dx;
|
||||
{
|
||||
Fl_Button* o = new Fl_Button(x, y, 100, 30, CANCEL_s);
|
||||
o->color(FL_YELLOW);
|
||||
o->callback(cancel_cb, print);
|
||||
}
|
||||
win->end();
|
||||
win->show();
|
||||
|
||||
while( !print->win_destroy)
|
||||
Fl::wait(1.0);
|
||||
|
||||
}/* Print_gui_create() */
|
|
@ -0,0 +1,48 @@
|
|||
#ifndef _FLVIEWER_PRINT_GUI_HH_
|
||||
#define _FLVIEWER_PRINT_GUI_HH_
|
||||
|
||||
#include <FL/Fl_Round_Button.H>
|
||||
#include <FL/Fl_Int_Input.H>
|
||||
#include <FL/Fl_Float_Input.H>
|
||||
|
||||
typedef struct print_info
|
||||
{
|
||||
Fl_Window* win;
|
||||
|
||||
Fl_Choice *paper_size, *printer_name;
|
||||
Fl_Round_Button *portrait, *landscape;
|
||||
|
||||
Fl_Round_Button *lowres, *hires;
|
||||
|
||||
Fl_Round_Button *color, *gray;
|
||||
|
||||
Fl_Group *printer_group, *file_group;
|
||||
Fl_Round_Button *to_printer, *to_file;
|
||||
|
||||
Fl_Output *loc;
|
||||
|
||||
Fl_Input *title, *fname;
|
||||
Fl_Button *center_image;
|
||||
Fl_Int_Input *copies;
|
||||
Fl_Float_Input *margin_lhs, *margin_rhs, *margin_top, *margin_bot;
|
||||
|
||||
char ok, remove_fname, center;
|
||||
char want_portrait, want_landscape, want_color, want_gray;
|
||||
int resolution, nr_copies;
|
||||
int paper_size_pos, printer_pos;
|
||||
int win_destroy;
|
||||
|
||||
char paper_layout[2];
|
||||
char pcolor[2];
|
||||
|
||||
double fmargin_lhs, fmargin_rhs, fmargin_top, fmargin_bot;
|
||||
double fpaper_w, fpaper_h;
|
||||
char *fname_s, *command_s, *title_s, *printer_s, *format_s;
|
||||
char *media_s;
|
||||
|
||||
} PrintInfo;
|
||||
|
||||
|
||||
void Print_gui_create(PrintInfo *p);
|
||||
|
||||
#endif /* _FLVIEWER_PRINT_GUI_HH_ */
|
|
@ -0,0 +1,673 @@
|
|||
#include <config.h>
|
||||
/*
|
||||
* Author(s): Ameet A. Raval, Frans van Hoesel, Andrew Ford, szukw000
|
||||
*
|
||||
* NOTE: rle16(): files can be sufficiently shorter
|
||||
* if the image has a small number of colors.
|
||||
* rle8() : extends the file.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
#include "ps_image.hh"
|
||||
|
||||
#define MAX_COL 12
|
||||
#define TM_BASE_YEAR 1900
|
||||
|
||||
/* RLE values */
|
||||
#define USHORT_BLOCK_MASK 0x8000
|
||||
#define USHORT_BLOCK_LEN 21845
|
||||
#define USHORT_MAX_INDEX 21845
|
||||
|
||||
#define UCHAR_MAX_INDEX 256
|
||||
|
||||
#define FULLY_TRANSPARENT 0
|
||||
#define FULLY_OPAQUE 255
|
||||
|
||||
static void ps_print_hex(PSInfo *ps, unsigned short val, int flush)
|
||||
{
|
||||
static unsigned char hexline[128];
|
||||
static unsigned char digit[] = "0123456789abcdef";
|
||||
|
||||
if(!flush)
|
||||
{
|
||||
hexline[ps->PS_hexi++] = (unsigned char)
|
||||
digit[((unsigned) val >>(unsigned) 4) & (unsigned) 0x0f];
|
||||
hexline[ps->PS_hexi++] = (unsigned char)
|
||||
digit[(unsigned) val & (unsigned) 0x0f];
|
||||
}
|
||||
if((flush && ps->PS_hexi) || (ps->PS_hexi >77))
|
||||
{
|
||||
hexline[ps->PS_hexi] = '\0';
|
||||
ps->PS_hexi = 0;
|
||||
fprintf(ps->writer, "%s\n", hexline);
|
||||
}
|
||||
}
|
||||
|
||||
struct ps_color
|
||||
{
|
||||
unsigned char red, green, blue;
|
||||
unsigned char dirty;
|
||||
};
|
||||
|
||||
static unsigned char *mono_to_rgb(PSInfo *ps)
|
||||
{
|
||||
unsigned char *buf, *d, *s;
|
||||
unsigned int i, max;
|
||||
|
||||
max = ps->image_w * ps->image_h;
|
||||
buf = (unsigned char*)malloc(max * 3);
|
||||
|
||||
if(buf == NULL)
|
||||
{
|
||||
fprintf(stderr,"ps_image.cxx:%d:\n\tmemory out\n",__LINE__);
|
||||
return NULL;
|
||||
}
|
||||
d = buf; s = ps->src_buf;
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
{
|
||||
*d++ = *s; *d++ = *s; *d++ = *s; ++s;
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
/* rgba_to_rgb() uses the alpha_composite()-code from :
|
||||
* libpng-VERSION/contrib/gregbook/rpng2-x.c
|
||||
*/
|
||||
static unsigned char *rgba_to_rgb(PSInfo *ps)
|
||||
{
|
||||
unsigned char *buf, *d, *s;
|
||||
unsigned int i, max;
|
||||
unsigned char bg_red, bg_green, bg_blue;
|
||||
unsigned short red, green, blue, alpha, c;
|
||||
|
||||
bg_red = ps->bg_red; bg_green = ps->bg_green; bg_blue = ps->bg_blue;
|
||||
max = ps->image_w * ps->image_h;
|
||||
buf = (unsigned char*)malloc(max * 3);
|
||||
|
||||
if(buf == NULL)
|
||||
{
|
||||
fprintf(stderr,"ps_image.cxx:%d:\n\tmemory out\n",__LINE__);
|
||||
return NULL;
|
||||
}
|
||||
d = buf; s = ps->src_buf;
|
||||
|
||||
for(i = 0; i < max; ++i)
|
||||
{
|
||||
red = (unsigned short)*s++;
|
||||
green = (unsigned short)*s++;
|
||||
blue = (unsigned short)*s++;
|
||||
alpha = (unsigned short)*s++;
|
||||
|
||||
if(alpha == FULLY_OPAQUE)
|
||||
{
|
||||
*d++ = (unsigned char)red;
|
||||
*d++ = (unsigned char)green;
|
||||
*d++ = (unsigned char)blue;
|
||||
continue;
|
||||
}
|
||||
if(alpha == FULLY_TRANSPARENT)
|
||||
{
|
||||
*d++ = bg_red;
|
||||
*d++ = bg_green;
|
||||
*d++ = bg_blue;
|
||||
continue;
|
||||
}
|
||||
/* transition */
|
||||
c = red * alpha
|
||||
+ (unsigned short)bg_red * (FULLY_OPAQUE - alpha) + 128;
|
||||
*d++ = (unsigned char)((c + (c>>8))>>8);
|
||||
|
||||
c = green * alpha
|
||||
+ (unsigned short)bg_green * (FULLY_OPAQUE - alpha) + 128;
|
||||
*d++ = (unsigned char)((c + (c>>8))>>8);
|
||||
|
||||
c = blue * alpha
|
||||
+ (unsigned short)bg_blue * (FULLY_OPAQUE - alpha) + 128;
|
||||
*d++ = (unsigned char)((c + (c>>8))>>8);
|
||||
|
||||
}/* for(i ) */
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
/*
|
||||
* Run-Length-Encoding of image.
|
||||
* RLE is done to reduce the file size and therefore the time to send
|
||||
* the file to the printer. You get longer processing time instead.
|
||||
*
|
||||
* RLE is encoded as such:
|
||||
* <count> <value> # 'run' of count+1 equal pixels
|
||||
* <count | MASK> <count+1 data bytes> # count+1 non-equal pixels
|
||||
* count can range between 0 and 127 for uchar
|
||||
* and between 0 and 21845 for ushort
|
||||
*
|
||||
* returns the length of the RLE line vector
|
||||
*
|
||||
* Implementation Limits of PostScript: 'string' 65535
|
||||
*
|
||||
* max. triple: 21845
|
||||
*
|
||||
* Depending of the image size the encoding is split into:
|
||||
*
|
||||
* if len is <= 2^16 - 1: rle16_encode()
|
||||
*/
|
||||
|
||||
static int rle16_encode(unsigned short *scanline,
|
||||
unsigned short *rleline, unsigned short *block, int wide)
|
||||
{
|
||||
int i, j, rlen;
|
||||
unsigned short blocklen, isrun;
|
||||
unsigned short pix;
|
||||
|
||||
blocklen = isrun = 0; rlen = 0;
|
||||
|
||||
for(i = 0; i < wide; i++)
|
||||
{
|
||||
/* there are 5 possible states:
|
||||
* 0: block empty.
|
||||
* 1: block is a run, current pix == previous pix
|
||||
* 2: block is a run, current pix != previous pix
|
||||
* 3: block not a run, current pix == previous pix
|
||||
* 4: block not a run, current pix != previous pix
|
||||
*/
|
||||
pix = scanline[i];
|
||||
if(!blocklen)
|
||||
{
|
||||
/* case 0: empty
|
||||
*/
|
||||
block[blocklen++] = pix;
|
||||
isrun = 1;
|
||||
}
|
||||
else
|
||||
if(isrun)
|
||||
{
|
||||
if(pix == block[blocklen-1])
|
||||
{
|
||||
/* case 1: isrun, prev == cur
|
||||
*/
|
||||
block[blocklen++] = pix;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* case 2: isrun, prev != cur
|
||||
*/
|
||||
if(blocklen>1)
|
||||
{
|
||||
/* we have a run block to flush */
|
||||
rleline[rlen++] = blocklen-1;
|
||||
rleline[rlen++] = block[0];
|
||||
/* start new run block with pix */
|
||||
block[0] = pix;
|
||||
blocklen = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* blocklen<=1, turn into non-run */
|
||||
isrun = 0;
|
||||
block[blocklen++] = pix;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* not a run */
|
||||
if(pix == block[blocklen-1])
|
||||
{
|
||||
/* case 3: non-run, prev == cur
|
||||
*/
|
||||
if(blocklen>1)
|
||||
{
|
||||
/* have a non-run block to flush */
|
||||
rleline[rlen++] = (blocklen-1) | USHORT_BLOCK_MASK;
|
||||
for(j=0; j<blocklen; j++)
|
||||
rleline[rlen++] = block[j];
|
||||
/* start new run block with pix */
|
||||
block[0] = pix;
|
||||
blocklen = isrun = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* blocklen <= 1 turn into a run */
|
||||
isrun = 1;
|
||||
block[blocklen++] = pix;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* case 4: non-run, prev != cur
|
||||
*/
|
||||
block[blocklen++] = pix;
|
||||
}
|
||||
}
|
||||
|
||||
/* max block length. flush */
|
||||
if(blocklen == USHORT_BLOCK_LEN)
|
||||
{
|
||||
if(isrun)
|
||||
{
|
||||
rleline[rlen++] = blocklen-1;
|
||||
rleline[rlen++] = block[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
rleline[rlen++] = (blocklen-1) | USHORT_BLOCK_MASK;
|
||||
for(j=0; j<blocklen; j++)
|
||||
rleline[rlen++] = block[j];
|
||||
}
|
||||
blocklen = 0;
|
||||
}
|
||||
}/* for(i) */
|
||||
|
||||
/* flush last block */
|
||||
if(blocklen)
|
||||
{
|
||||
if(isrun)
|
||||
{
|
||||
rleline[rlen++] = blocklen-1;
|
||||
rleline[rlen++] = block[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
rleline[rlen++] = (blocklen-1) | USHORT_BLOCK_MASK;
|
||||
for(j=0; j<blocklen; j++)
|
||||
rleline[rlen++] = block[j];
|
||||
}
|
||||
}
|
||||
return rlen;
|
||||
}/* rle16_encode() */
|
||||
|
||||
/*
|
||||
* Writes code for the colormap of the following image.
|
||||
* If !color: writes a mono-ized graymap.
|
||||
*/
|
||||
static void write_colormap(PSInfo *ps, int nc,
|
||||
struct ps_color *ps_colors)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* define the colormap */
|
||||
fprintf(ps->writer, "/cmap %d string def\n\n\n", nc * 3);
|
||||
|
||||
/* load up the colormap */
|
||||
fputs("currentfile cmap readhexstring\n", ps->writer);
|
||||
|
||||
for(i=0; i < nc; i++)
|
||||
{
|
||||
fprintf(ps->writer, "%02x%02x%02x", ps_colors[i].red,
|
||||
ps_colors[i].green, ps_colors[i].blue);
|
||||
|
||||
if((i%(MAX_COL+1)) == MAX_COL) fputs("\n", ps->writer);
|
||||
}
|
||||
/* lose return values from readhexstring */
|
||||
fputs("\npop pop\n", ps->writer);
|
||||
|
||||
}/* write_colormap() */
|
||||
|
||||
static int create_image_data(PSInfo *ps, unsigned char *src_buf,
|
||||
struct ps_color **out_colors, unsigned short **out_dst,
|
||||
int *out_dst_len)
|
||||
{
|
||||
unsigned char *src;
|
||||
struct ps_color *ps_colors;
|
||||
unsigned short *dst;
|
||||
unsigned int src_len, dst_len, i, free_index;
|
||||
unsigned int r, g, b;
|
||||
|
||||
src = src_buf;
|
||||
src_len = ps->image_w * ps->image_h * 3;
|
||||
|
||||
i = (src_len/3) * (unsigned int)sizeof(struct ps_color);
|
||||
|
||||
dst = (unsigned short*)calloc(1, i);
|
||||
ps_colors = (struct ps_color*)calloc(1, i);
|
||||
|
||||
if(dst == NULL || ps_colors == NULL)
|
||||
{
|
||||
goto fails;
|
||||
}
|
||||
dst_len = 0; *out_dst = dst; *out_colors = ps_colors;
|
||||
|
||||
ps_colors[0].red = *src++;
|
||||
ps_colors[0].green = *src++;
|
||||
ps_colors[0].blue = *src++;
|
||||
free_index = 1;
|
||||
src_len -= 3; *dst++ = 0; dst_len = 1;
|
||||
|
||||
while(src_len > 0)
|
||||
{
|
||||
r = *src++; g = *src++; b = *src++; src_len -= 3;
|
||||
i = (r<<3) + (r>>11) + g;
|
||||
i = (i<<3) + (i>>23) + b;
|
||||
i %= free_index;
|
||||
|
||||
while(i < free_index)
|
||||
{
|
||||
if(ps_colors[i].dirty == 0)
|
||||
{
|
||||
ps_colors[i].red = (unsigned char)r;
|
||||
ps_colors[i].green = (unsigned char)g;
|
||||
ps_colors[i].blue = (unsigned char)b;
|
||||
ps_colors[i].dirty = 1;
|
||||
break;
|
||||
}
|
||||
if(r == ps_colors[i].red
|
||||
&& g == ps_colors[i].green
|
||||
&& b == ps_colors[i].blue)
|
||||
break;
|
||||
++i;
|
||||
}
|
||||
if(i == free_index)
|
||||
{
|
||||
if(++free_index == USHORT_MAX_INDEX)
|
||||
{
|
||||
/* no colormap, no ps_colors */
|
||||
break;
|
||||
}
|
||||
ps_colors[i].red = (unsigned char)r;
|
||||
ps_colors[i].green = (unsigned char)g;
|
||||
ps_colors[i].blue = (unsigned char)b;
|
||||
ps_colors[i].dirty = 1;
|
||||
}
|
||||
*dst++ = i; ++dst_len;
|
||||
}/* while(src_len > 0) */
|
||||
|
||||
*out_dst_len = dst_len;
|
||||
|
||||
return free_index;
|
||||
|
||||
fails:
|
||||
if(dst != NULL) free(dst);
|
||||
|
||||
fprintf(stderr,"ps_image.cxx:%d:\n\tmemory out\n",__LINE__);
|
||||
return 0;
|
||||
|
||||
}/* create_image_data() */
|
||||
|
||||
const char *prolog_open_cs =
|
||||
"%%!PS-Adobe-3.0\n"
|
||||
"%%%%Creator: %s\n"
|
||||
"%%%%Title: %s\n"
|
||||
"%%%%LanguageLevel: 2\n"
|
||||
"%%%%CreationDate: %s\n"
|
||||
"%%%%Pages: 1\n"
|
||||
"%%%%PageOrder: Ascend\n";
|
||||
|
||||
const char *rle16_cs =
|
||||
"/RLECMAPIMAGE16 { /buffer 2 string def /rgbval 3 string def\n"
|
||||
" /block 65535 string def\n"
|
||||
" { currentfile buffer readhexstring pop pop\n"
|
||||
" /bcount buffer 0 get 256 mul buffer 1 get add store\n"
|
||||
" bcount 32768 ge\n"
|
||||
" {\n"
|
||||
" 0 1 bcount 32768 sub\n"
|
||||
" { currentfile buffer readhexstring pop pop\n"
|
||||
" /mapidx buffer 0 get 256 mul buffer 1 get add 3 mul store\n"
|
||||
" /rgbval cmap mapidx 3 getinterval store\n"
|
||||
" block exch 3 mul rgbval putinterval\n"
|
||||
" } for\n"
|
||||
" block 0 bcount 32767 sub 3 mul getinterval\n"
|
||||
" }\n"
|
||||
" {\n"
|
||||
" currentfile buffer readhexstring pop pop\n"
|
||||
" /mapidx buffer 0 get 256 mul buffer 1 get add 3 mul store\n"
|
||||
" /rgbval cmap mapidx 3 getinterval store\n"
|
||||
" 0 1 bcount { block exch 3 mul rgbval putinterval } for\n"
|
||||
" block 0 bcount 1 add 3 mul getinterval\n"
|
||||
" } ifelse\n"
|
||||
" }\n"
|
||||
" false 3 colorimage\n"
|
||||
"} bind def\n";
|
||||
|
||||
const char *ps_date(void)
|
||||
{
|
||||
static char buf[128];
|
||||
struct tm *stm;
|
||||
time_t t;
|
||||
|
||||
t = time(NULL);
|
||||
stm = localtime(&t);
|
||||
#ifdef _WIN32
|
||||
sprintf_s(buf, 128, "%4d-%02d-%02d",
|
||||
stm->tm_year + TM_BASE_YEAR, stm->tm_mon+1, stm->tm_mday);
|
||||
#else
|
||||
snprintf(buf, 128, "%4d-%02d-%02d",
|
||||
stm->tm_year + TM_BASE_YEAR, stm->tm_mon+1, stm->tm_mday);
|
||||
#endif
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
static void write_header(PSInfo *ps, int max_index)
|
||||
{
|
||||
double lhs, top, rhs, bot, box_w, box_h, x, y;
|
||||
const char *moveto;
|
||||
|
||||
fprintf(ps->writer, prolog_open_cs, PACKAGE_STRING, ps->title_s,
|
||||
ps_date());
|
||||
|
||||
lhs = ps->fmargin_lhs;
|
||||
top = ps->fmargin_top;
|
||||
rhs = ps->fmargin_rhs;
|
||||
bot = ps->fmargin_bot;
|
||||
|
||||
if(ps->portrait)
|
||||
{
|
||||
box_w = ps->fmedia_w - lhs - rhs;
|
||||
box_h = ps->fmedia_h - top - bot;
|
||||
ps->fscale_w = ps->image_w; ps->fscale_h = ps->image_h;
|
||||
|
||||
if(ps->fscale_w > box_w)
|
||||
{
|
||||
ps->fscale_w = box_w;
|
||||
ps->fscale_h = box_w * (double)ps->image_h/(double)ps->image_w;
|
||||
}
|
||||
else
|
||||
if(ps->fscale_h > box_h)
|
||||
{
|
||||
ps->fscale_w = box_h * (double)ps->image_h/(double)ps->image_w;
|
||||
ps->fscale_h = box_h;
|
||||
}
|
||||
x = lhs; y = box_h + bot;
|
||||
|
||||
if(ps->center)
|
||||
{
|
||||
if(ps->fscale_h < box_h) y -= (box_h - ps->fscale_h)/2.;
|
||||
if(ps->fscale_w < box_w) x += (box_w - ps->fscale_w)/2.;
|
||||
}
|
||||
fprintf(ps->writer, "%%%%Orientation: Portrait\n"
|
||||
"%%%%BoundingBox: %d %d %d %d\n"
|
||||
"%%%%DocumentMedia: %s %d %d 0 () ()\n",
|
||||
(int)lhs, (int)top, (int)box_w, (int)box_h,
|
||||
ps->media_s, (int)ps->fmedia_w, (int)ps->fmedia_h);
|
||||
|
||||
moveto = "save\n%.4f %.4f moveto\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(ps->landscape);
|
||||
|
||||
box_w = ps->fmedia_w - lhs - rhs;
|
||||
box_h = ps->fmedia_h - top - bot;
|
||||
ps->fscale_w = ps->image_w; ps->fscale_h = ps->image_h;
|
||||
|
||||
if(ps->fscale_h > box_w)
|
||||
{
|
||||
ps->fscale_w = box_w * (double)ps->image_w/(double)ps->image_h;
|
||||
ps->fscale_h = box_w;
|
||||
}
|
||||
else
|
||||
if(ps->fscale_w > box_h)
|
||||
{
|
||||
ps->fscale_w = box_h;
|
||||
ps->fscale_h = box_h * (double)ps->image_w/(double)ps->image_h;
|
||||
}
|
||||
x = lhs; y = bot;
|
||||
|
||||
if(ps->center)
|
||||
{
|
||||
if(ps->fscale_h < box_w) x += (box_w - ps->fscale_h)/2.;
|
||||
if(ps->fscale_w < box_h) y += (box_h - ps->fscale_w)/2.;
|
||||
}
|
||||
fprintf(ps->writer, "%%%%Orientation: Landscape\n"
|
||||
"%%%%BoundingBox: %d %d %d %d\n"
|
||||
"%%%%DocumentMedia: %s %d %d 0 () ()\n",
|
||||
(int)lhs, (int)top, (int)box_w, (int)box_h,
|
||||
ps->media_s, (int)ps->fmedia_w, (int)ps->fmedia_h);
|
||||
|
||||
moveto = "save\n%.4f %.4f translate 90 rotate 0. 0. moveto\n";
|
||||
|
||||
}
|
||||
fputs("%%EndComments\n%%BeginProlog\n", ps->writer);
|
||||
|
||||
if(max_index < USHORT_MAX_INDEX)
|
||||
fputs(rle16_cs, ps->writer);
|
||||
|
||||
fputs("%%EndProlog\n%%BeginSetup\n%%EndSetup\n%%Page: 1 1\n"
|
||||
"%%BeginPageSetup\n%%EndPageSetup\n", ps->writer);
|
||||
|
||||
fprintf(ps->writer, moveto, x, y);
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"%s:%d:write_header\n\tMARGINS(%.4f,%.4f,%.4f,%.4f)\n\t"
|
||||
"BOX w(%.4f) h(%.4f) SCALE w(%.4f) h(%.4f)\n\tX(%.4f) Y(%.4f)\n",
|
||||
__FILE__,__LINE__, top,rhs,bot,lhs,box_w,box_h,ps->fscale_w,
|
||||
ps->fscale_h,x,y);
|
||||
#endif
|
||||
}/* write_header() */
|
||||
|
||||
int PS_image_draw(PSInfo *ps)
|
||||
{
|
||||
struct ps_color *ps_colors;
|
||||
unsigned short *dst_buf, *src;
|
||||
unsigned char *rgb_buf;
|
||||
unsigned short *rle_line;
|
||||
unsigned short *block;
|
||||
int i, j, width, height, rle_len, dst_len;
|
||||
int max_index;
|
||||
|
||||
width = ps->image_w;
|
||||
height = ps->image_h;
|
||||
dst_buf = NULL; ps_colors = NULL;
|
||||
|
||||
if(ps->image_channels == 1)
|
||||
rgb_buf = mono_to_rgb(ps);
|
||||
else
|
||||
if(ps->image_channels == 4)
|
||||
rgb_buf = rgba_to_rgb(ps);
|
||||
else
|
||||
rgb_buf = ps->src_buf;
|
||||
|
||||
if(rgb_buf == NULL)
|
||||
{
|
||||
fprintf(stderr,".cxx:%d:\n\tmemory out\n",__LINE__);
|
||||
return 0;
|
||||
}
|
||||
max_index =
|
||||
create_image_data(ps, rgb_buf, &ps_colors, &dst_buf, &dst_len);
|
||||
|
||||
if(max_index == 0)
|
||||
{
|
||||
if(ps->image_channels != 3) free(rgb_buf);
|
||||
|
||||
if(dst_buf) free(dst_buf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* small images without colormap:
|
||||
*/
|
||||
if(max_index < UCHAR_MAX_INDEX)
|
||||
max_index = USHORT_MAX_INDEX;
|
||||
|
||||
write_header(ps, max_index);
|
||||
|
||||
fprintf(ps->writer, "20 dict begin\n/pix %d string def\n\n", width * 3);
|
||||
|
||||
/* position and scaling
|
||||
*/
|
||||
fprintf(ps->writer, "gsave currentpoint %.4f sub translate"
|
||||
" %.4f %.4f scale\n", ps->fscale_h, ps->fscale_w, ps->fscale_h);
|
||||
|
||||
if(max_index < USHORT_MAX_INDEX)
|
||||
{
|
||||
write_colormap(ps, max_index, ps_colors);
|
||||
}
|
||||
fprintf(ps->writer, "%d %d 8\n", width, height);
|
||||
|
||||
/* mapping matrix
|
||||
*/
|
||||
fprintf(ps->writer, "[%d 0 0 -%d 0 %d]\n", width, height, height);
|
||||
|
||||
rle_line = NULL; block = NULL;
|
||||
|
||||
if(max_index < USHORT_MAX_INDEX)
|
||||
{
|
||||
unsigned short val;
|
||||
|
||||
rle_line = (unsigned short*) malloc(width * 2 * sizeof(unsigned short));
|
||||
block = (unsigned short*) malloc(width * sizeof(unsigned short));
|
||||
|
||||
if(rle_line == NULL || block == NULL)
|
||||
{
|
||||
goto fails;
|
||||
}
|
||||
fputs("RLECMAPIMAGE16\n", ps->writer);
|
||||
|
||||
src = dst_buf;
|
||||
|
||||
for(i=0; i < height; i++)
|
||||
{
|
||||
rle_len = rle16_encode(src, rle_line, block, width);
|
||||
src += width;
|
||||
j = -1;
|
||||
|
||||
while(++j < rle_len)
|
||||
{
|
||||
val = rle_line[j];
|
||||
ps_print_hex(ps, val>>8, 0);
|
||||
ps_print_hex(ps, val%256, 0);
|
||||
}
|
||||
ps_print_hex(ps, '\0', 1); /* Flush the hex buffer */
|
||||
}
|
||||
free(rle_line); free(block);
|
||||
}
|
||||
else /* max_index >= USHORT_MAX_INDEX */
|
||||
{
|
||||
unsigned char *src;
|
||||
int col, src_len;
|
||||
|
||||
fputs("{currentfile pix readhexstring pop}\n"
|
||||
"false 3 colorimage\n", ps->writer);
|
||||
|
||||
src = rgb_buf; src_len = width * height * 3;
|
||||
col = 0;
|
||||
|
||||
while(src_len > 0)
|
||||
{
|
||||
fprintf(ps->writer, "%02x%02x%02x", src[0], src[1], src[2]);
|
||||
src += 3; src_len -= 3;
|
||||
if(++col > MAX_COL)
|
||||
{
|
||||
fputs("\n", ps->writer); col = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(ps->image_channels != 3)
|
||||
free(rgb_buf);
|
||||
free(dst_buf); free(ps_colors);
|
||||
|
||||
fputs("end\ngrestore\nrestore\nshowpage\n%%Trailer\n%%EOF\n", ps->writer);
|
||||
|
||||
return 1;
|
||||
|
||||
fails:
|
||||
if(rle_line != NULL) free(rle_line);
|
||||
|
||||
fprintf(stderr,"ps_image.cxx:%d:\n\tmemory out\n",__LINE__);
|
||||
return 0;
|
||||
|
||||
} /* PS_image_write() */
|
|
@ -0,0 +1,31 @@
|
|||
#ifndef _FLVIEWER_PS_IMAGE_HH_
|
||||
#define _FLVIEWER_PS_IMAGE_HH_
|
||||
|
||||
typedef struct psinfo
|
||||
{
|
||||
char portrait, landscape, center;
|
||||
char *format;
|
||||
/* Normally bg_red = bg_green = bg_blue = 255:
|
||||
*/
|
||||
unsigned char bg_red, bg_green, bg_blue;
|
||||
|
||||
unsigned char *src_buf;
|
||||
char *title_s;
|
||||
char *media_s;
|
||||
|
||||
int image_channels;
|
||||
int image_w, image_h;
|
||||
|
||||
double fmedia_w, fmedia_h;
|
||||
double fmargin_top, fmargin_rhs, fmargin_bot, fmargin_lhs;
|
||||
double fscale_w, fscale_h;
|
||||
|
||||
int PS_hexi;
|
||||
|
||||
FILE *writer;
|
||||
} PSInfo;
|
||||
|
||||
|
||||
extern int PS_image_draw(PSInfo *psi);
|
||||
|
||||
#endif /* _FLVIEWER_PS_IMAGE_HH_ */
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,805 @@
|
|||
#include <config.h>
|
||||
/*
|
||||
* author(s) and license
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "rgb_color.hh"
|
||||
|
||||
static struct rgb_and_name{unsigned char r, g, b; const char *cname;}
|
||||
rgb_names[] = {
|
||||
{0xf0,0xf8,0xff,"alice blue"},
|
||||
{0xf0,0xf8,0xff,"aliceblue"},
|
||||
{0xfa,0xeb,0xd7,"antique white"},
|
||||
{0xfa,0xeb,0xd7,"antiquewhite"},
|
||||
{0xff,0xef,0xdb,"antiquewhite1"},
|
||||
{0xee,0xdf,0xcc,"antiquewhite2"},
|
||||
{0xcd,0xc0,0xb0,"antiquewhite3"},
|
||||
{0x8b,0x83,0x78,"antiquewhite4"},
|
||||
{0x7f,0xff,0xd4,"aquamarine"},
|
||||
{0x7f,0xff,0xd4,"aquamarine1"},
|
||||
{0x76,0xee,0xc6,"aquamarine2"},
|
||||
{0x66,0xcd,0xaa,"aquamarine3"},
|
||||
{0x45,0x8b,0x74,"aquamarine4"},
|
||||
{0xf0,0xff,0xff,"azure"},
|
||||
{0xf0,0xff,0xff,"azure1"},
|
||||
{0xe0,0xee,0xee,"azure2"},
|
||||
{0xc1,0xcd,0xcd,"azure3"},
|
||||
{0x83,0x8b,0x8b,"azure4"},
|
||||
{0xf5,0xf5,0xdc,"beige"},
|
||||
{0xff,0xe4,0xc4,"bisque"},
|
||||
{0xff,0xe4,0xc4,"bisque1"},
|
||||
{0xee,0xd5,0xb7,"bisque2"},
|
||||
{0xcd,0xb7,0x9e,"bisque3"},
|
||||
{0x8b,0x7d,0x6b,"bisque4"},
|
||||
{0x00,0x00,0x00,"black"},
|
||||
{0xff,0xeb,0xcd,"blanched almond"},
|
||||
{0xff,0xeb,0xcd,"blanchedalmond"},
|
||||
{0x00,0x00,0xff,"blue"},
|
||||
{0x8a,0x2b,0xe2,"blue violet"},
|
||||
{0x00,0x00,0xff,"blue1"},
|
||||
{0x00,0x00,0xee,"blue2"},
|
||||
{0x00,0x00,0xcd,"blue3"},
|
||||
{0x00,0x00,0x8b,"blue4"},
|
||||
{0x8a,0x2b,0xe2,"blueviolet"},
|
||||
{0xa5,0x2a,0x2a,"brown"},
|
||||
{0xff,0x40,0x40,"brown1"},
|
||||
{0xee,0x3b,0x3b,"brown2"},
|
||||
{0xcd,0x33,0x33,"brown3"},
|
||||
{0x8b,0x23,0x23,"brown4"},
|
||||
{0xde,0xb8,0x87,"burlywood"},
|
||||
{0xff,0xd3,0x9b,"burlywood1"},
|
||||
{0xee,0xc5,0x91,"burlywood2"},
|
||||
{0xcd,0xaa,0x7d,"burlywood3"},
|
||||
{0x8b,0x73,0x55,"burlywood4"},
|
||||
{0x5f,0x9e,0xa0,"cadet blue"},
|
||||
{0x5f,0x9e,0xa0,"cadetblue"},
|
||||
{0x98,0xf5,0xff,"cadetblue1"},
|
||||
{0x8e,0xe5,0xee,"cadetblue2"},
|
||||
{0x7a,0xc5,0xcd,"cadetblue3"},
|
||||
{0x53,0x86,0x8b,"cadetblue4"},
|
||||
{0x7f,0xff,0x00,"chartreuse"},
|
||||
{0x7f,0xff,0x00,"chartreuse1"},
|
||||
{0x76,0xee,0x00,"chartreuse2"},
|
||||
{0x66,0xcd,0x00,"chartreuse3"},
|
||||
{0x45,0x8b,0x00,"chartreuse4"},
|
||||
{0xd2,0x69,0x1e,"chocolate"},
|
||||
{0xff,0x7f,0x24,"chocolate1"},
|
||||
{0xee,0x76,0x21,"chocolate2"},
|
||||
{0xcd,0x66,0x1d,"chocolate3"},
|
||||
{0x8b,0x45,0x13,"chocolate4"},
|
||||
{0xff,0x7f,0x50,"coral"},
|
||||
{0xff,0x72,0x56,"coral1"},
|
||||
{0xee,0x6a,0x50,"coral2"},
|
||||
{0xcd,0x5b,0x45,"coral3"},
|
||||
{0x8b,0x3e,0x2f,"coral4"},
|
||||
{0x64,0x95,0xed,"cornflower blue"},
|
||||
{0x64,0x95,0xed,"cornflowerblue"},
|
||||
{0xff,0xf8,0xdc,"cornsilk"},
|
||||
{0xff,0xf8,0xdc,"cornsilk1"},
|
||||
{0xee,0xe8,0xcd,"cornsilk2"},
|
||||
{0xcd,0xc8,0xb1,"cornsilk3"},
|
||||
{0x8b,0x88,0x78,"cornsilk4"},
|
||||
{0x00,0xff,0xff,"cyan"},
|
||||
{0x00,0xff,0xff,"cyan1"},
|
||||
{0x00,0xee,0xee,"cyan2"},
|
||||
{0x00,0xcd,0xcd,"cyan3"},
|
||||
{0x00,0x8b,0x8b,"cyan4"},
|
||||
{0x00,0x00,0x8b,"dark blue"},
|
||||
{0x00,0x8b,0x8b,"dark cyan"},
|
||||
{0xb8,0x86,0x0b,"dark goldenrod"},
|
||||
{0xa9,0xa9,0xa9,"dark gray"},
|
||||
{0x00,0x64,0x00,"dark green"},
|
||||
{0xa9,0xa9,0xa9,"dark grey"},
|
||||
{0xbd,0xb7,0x6b,"dark khaki"},
|
||||
{0x8b,0x00,0x8b,"dark magenta"},
|
||||
{0x55,0x6b,0x2f,"dark olive green"},
|
||||
{0xff,0x8c,0x00,"dark orange"},
|
||||
{0x99,0x32,0xcc,"dark orchid"},
|
||||
{0x8b,0x00,0x00,"dark red"},
|
||||
{0xe9,0x96,0x7a,"dark salmon"},
|
||||
{0x8f,0xbc,0x8f,"dark sea green"},
|
||||
{0x48,0x3d,0x8b,"dark slate blue"},
|
||||
{0x2f,0x4f,0x4f,"dark slate gray"},
|
||||
{0x2f,0x4f,0x4f,"dark slate grey"},
|
||||
{0x00,0xce,0xd1,"dark turquoise"},
|
||||
{0x94,0x00,0xd3,"dark violet"},
|
||||
{0x00,0x00,0x8b,"darkblue"},
|
||||
{0x00,0x8b,0x8b,"darkcyan"},
|
||||
{0xb8,0x86,0x0b,"darkgoldenrod"},
|
||||
{0xff,0xb9,0x0f,"darkgoldenrod1"},
|
||||
{0xee,0xad,0x0e,"darkgoldenrod2"},
|
||||
{0xcd,0x95,0x0c,"darkgoldenrod3"},
|
||||
{0x8b,0x65,0x08,"darkgoldenrod4"},
|
||||
{0xa9,0xa9,0xa9,"darkgray"},
|
||||
{0x00,0x64,0x00,"darkgreen"},
|
||||
{0xa9,0xa9,0xa9,"darkgrey"},
|
||||
{0xbd,0xb7,0x6b,"darkkhaki"},
|
||||
{0x8b,0x00,0x8b,"darkmagenta"},
|
||||
{0x55,0x6b,0x2f,"darkolivegreen"},
|
||||
{0xca,0xff,0x70,"darkolivegreen1"},
|
||||
{0xbc,0xee,0x68,"darkolivegreen2"},
|
||||
{0xa2,0xcd,0x5a,"darkolivegreen3"},
|
||||
{0x6e,0x8b,0x3d,"darkolivegreen4"},
|
||||
{0xff,0x8c,0x00,"darkorange"},
|
||||
{0xff,0x7f,0x00,"darkorange1"},
|
||||
{0xee,0x76,0x00,"darkorange2"},
|
||||
{0xcd,0x66,0x00,"darkorange3"},
|
||||
{0x8b,0x45,0x00,"darkorange4"},
|
||||
{0x99,0x32,0xcc,"darkorchid"},
|
||||
{0xbf,0x3e,0xff,"darkorchid1"},
|
||||
{0xb2,0x3a,0xee,"darkorchid2"},
|
||||
{0x9a,0x32,0xcd,"darkorchid3"},
|
||||
{0x68,0x22,0x8b,"darkorchid4"},
|
||||
{0x8b,0x00,0x00,"darkred"},
|
||||
{0xe9,0x96,0x7a,"darksalmon"},
|
||||
{0x8f,0xbc,0x8f,"darkseagreen"},
|
||||
{0xc1,0xff,0xc1,"darkseagreen1"},
|
||||
{0xb4,0xee,0xb4,"darkseagreen2"},
|
||||
{0x9b,0xcd,0x9b,"darkseagreen3"},
|
||||
{0x69,0x8b,0x69,"darkseagreen4"},
|
||||
{0x48,0x3d,0x8b,"darkslateblue"},
|
||||
{0x2f,0x4f,0x4f,"darkslategray"},
|
||||
{0x97,0xff,0xff,"darkslategray1"},
|
||||
{0x8d,0xee,0xee,"darkslategray2"},
|
||||
{0x79,0xcd,0xcd,"darkslategray3"},
|
||||
{0x52,0x8b,0x8b,"darkslategray4"},
|
||||
{0x2f,0x4f,0x4f,"darkslategrey"},
|
||||
{0x00,0xce,0xd1,"darkturquoise"},
|
||||
{0x94,0x00,0xd3,"darkviolet"},
|
||||
{0xff,0x14,0x93,"deep pink"},
|
||||
{0x00,0xbf,0xff,"deep sky blue"},
|
||||
{0xff,0x14,0x93,"deeppink"},
|
||||
{0xff,0x14,0x93,"deeppink1"},
|
||||
{0xee,0x12,0x89,"deeppink2"},
|
||||
{0xcd,0x10,0x76,"deeppink3"},
|
||||
{0x8b,0x0a,0x50,"deeppink4"},
|
||||
{0x00,0xbf,0xff,"deepskyblue"},
|
||||
{0x00,0xbf,0xff,"deepskyblue1"},
|
||||
{0x00,0xb2,0xee,"deepskyblue2"},
|
||||
{0x00,0x9a,0xcd,"deepskyblue3"},
|
||||
{0x00,0x68,0x8b,"deepskyblue4"},
|
||||
{0x69,0x69,0x69,"dim gray"},
|
||||
{0x69,0x69,0x69,"dim grey"},
|
||||
{0x69,0x69,0x69,"dimgray"},
|
||||
{0x69,0x69,0x69,"dimgrey"},
|
||||
{0x1e,0x90,0xff,"dodger blue"},
|
||||
{0x1e,0x90,0xff,"dodgerblue"},
|
||||
{0x1e,0x90,0xff,"dodgerblue1"},
|
||||
{0x1c,0x86,0xee,"dodgerblue2"},
|
||||
{0x18,0x74,0xcd,"dodgerblue3"},
|
||||
{0x10,0x4e,0x8b,"dodgerblue4"},
|
||||
{0xb2,0x22,0x22,"firebrick"},
|
||||
{0xff,0x30,0x30,"firebrick1"},
|
||||
{0xee,0x2c,0x2c,"firebrick2"},
|
||||
{0xcd,0x26,0x26,"firebrick3"},
|
||||
{0x8b,0x1a,0x1a,"firebrick4"},
|
||||
{0xff,0xfa,0xf0,"floral white"},
|
||||
{0xff,0xfa,0xf0,"floralwhite"},
|
||||
{0x22,0x8b,0x22,"forest green"},
|
||||
{0x22,0x8b,0x22,"forestgreen"},
|
||||
{0xdc,0xdc,0xdc,"gainsboro"},
|
||||
{0xf8,0xf8,0xff,"ghost white"},
|
||||
{0xf8,0xf8,0xff,"ghostwhite"},
|
||||
{0xff,0xd7,0x00,"gold"},
|
||||
{0xff,0xd7,0x00,"gold1"},
|
||||
{0xee,0xc9,0x00,"gold2"},
|
||||
{0xcd,0xad,0x00,"gold3"},
|
||||
{0x8b,0x75,0x00,"gold4"},
|
||||
{0xda,0xa5,0x20,"goldenrod"},
|
||||
{0xff,0xc1,0x25,"goldenrod1"},
|
||||
{0xee,0xb4,0x22,"goldenrod2"},
|
||||
{0xcd,0x9b,0x1d,"goldenrod3"},
|
||||
{0x8b,0x69,0x14,"goldenrod4"},
|
||||
{0xbe,0xbe,0xbe,"gray"},
|
||||
{0x00,0x00,0x00,"gray0"},
|
||||
{0x03,0x03,0x03,"gray1"},
|
||||
{0x1a,0x1a,0x1a,"gray10"},
|
||||
{0xff,0xff,0xff,"gray100"},
|
||||
{0x1c,0x1c,0x1c,"gray11"},
|
||||
{0x1f,0x1f,0x1f,"gray12"},
|
||||
{0x21,0x21,0x21,"gray13"},
|
||||
{0x24,0x24,0x24,"gray14"},
|
||||
{0x26,0x26,0x26,"gray15"},
|
||||
{0x29,0x29,0x29,"gray16"},
|
||||
{0x2b,0x2b,0x2b,"gray17"},
|
||||
{0x2e,0x2e,0x2e,"gray18"},
|
||||
{0x30,0x30,0x30,"gray19"},
|
||||
{0x05,0x05,0x05,"gray2"},
|
||||
{0x33,0x33,0x33,"gray20"},
|
||||
{0x36,0x36,0x36,"gray21"},
|
||||
{0x38,0x38,0x38,"gray22"},
|
||||
{0x3b,0x3b,0x3b,"gray23"},
|
||||
{0x3d,0x3d,0x3d,"gray24"},
|
||||
{0x40,0x40,0x40,"gray25"},
|
||||
{0x42,0x42,0x42,"gray26"},
|
||||
{0x45,0x45,0x45,"gray27"},
|
||||
{0x47,0x47,0x47,"gray28"},
|
||||
{0x4a,0x4a,0x4a,"gray29"},
|
||||
{0x08,0x08,0x08,"gray3"},
|
||||
{0x4d,0x4d,0x4d,"gray30"},
|
||||
{0x4f,0x4f,0x4f,"gray31"},
|
||||
{0x52,0x52,0x52,"gray32"},
|
||||
{0x54,0x54,0x54,"gray33"},
|
||||
{0x57,0x57,0x57,"gray34"},
|
||||
{0x59,0x59,0x59,"gray35"},
|
||||
{0x5c,0x5c,0x5c,"gray36"},
|
||||
{0x5e,0x5e,0x5e,"gray37"},
|
||||
{0x61,0x61,0x61,"gray38"},
|
||||
{0x63,0x63,0x63,"gray39"},
|
||||
{0x0a,0x0a,0x0a,"gray4"},
|
||||
{0x66,0x66,0x66,"gray40"},
|
||||
{0x69,0x69,0x69,"gray41"},
|
||||
{0x6b,0x6b,0x6b,"gray42"},
|
||||
{0x6e,0x6e,0x6e,"gray43"},
|
||||
{0x70,0x70,0x70,"gray44"},
|
||||
{0x73,0x73,0x73,"gray45"},
|
||||
{0x75,0x75,0x75,"gray46"},
|
||||
{0x78,0x78,0x78,"gray47"},
|
||||
{0x7a,0x7a,0x7a,"gray48"},
|
||||
{0x7d,0x7d,0x7d,"gray49"},
|
||||
{0x0d,0x0d,0x0d,"gray5"},
|
||||
{0x7f,0x7f,0x7f,"gray50"},
|
||||
{0x82,0x82,0x82,"gray51"},
|
||||
{0x85,0x85,0x85,"gray52"},
|
||||
{0x87,0x87,0x87,"gray53"},
|
||||
{0x8a,0x8a,0x8a,"gray54"},
|
||||
{0x8c,0x8c,0x8c,"gray55"},
|
||||
{0x8f,0x8f,0x8f,"gray56"},
|
||||
{0x91,0x91,0x91,"gray57"},
|
||||
{0x94,0x94,0x94,"gray58"},
|
||||
{0x96,0x96,0x96,"gray59"},
|
||||
{0x0f,0x0f,0x0f,"gray6"},
|
||||
{0x99,0x99,0x99,"gray60"},
|
||||
{0x9c,0x9c,0x9c,"gray61"},
|
||||
{0x9e,0x9e,0x9e,"gray62"},
|
||||
{0xa1,0xa1,0xa1,"gray63"},
|
||||
{0xa3,0xa3,0xa3,"gray64"},
|
||||
{0xa6,0xa6,0xa6,"gray65"},
|
||||
{0xa8,0xa8,0xa8,"gray66"},
|
||||
{0xab,0xab,0xab,"gray67"},
|
||||
{0xad,0xad,0xad,"gray68"},
|
||||
{0xb0,0xb0,0xb0,"gray69"},
|
||||
{0x12,0x12,0x12,"gray7"},
|
||||
{0xb3,0xb3,0xb3,"gray70"},
|
||||
{0xb5,0xb5,0xb5,"gray71"},
|
||||
{0xb8,0xb8,0xb8,"gray72"},
|
||||
{0xba,0xba,0xba,"gray73"},
|
||||
{0xbd,0xbd,0xbd,"gray74"},
|
||||
{0xbf,0xbf,0xbf,"gray75"},
|
||||
{0xc2,0xc2,0xc2,"gray76"},
|
||||
{0xc4,0xc4,0xc4,"gray77"},
|
||||
{0xc7,0xc7,0xc7,"gray78"},
|
||||
{0xc9,0xc9,0xc9,"gray79"},
|
||||
{0x14,0x14,0x14,"gray8"},
|
||||
{0xcc,0xcc,0xcc,"gray80"},
|
||||
{0xcf,0xcf,0xcf,"gray81"},
|
||||
{0xd1,0xd1,0xd1,"gray82"},
|
||||
{0xd4,0xd4,0xd4,"gray83"},
|
||||
{0xd6,0xd6,0xd6,"gray84"},
|
||||
{0xd9,0xd9,0xd9,"gray85"},
|
||||
{0xdb,0xdb,0xdb,"gray86"},
|
||||
{0xde,0xde,0xde,"gray87"},
|
||||
{0xe0,0xe0,0xe0,"gray88"},
|
||||
{0xe3,0xe3,0xe3,"gray89"},
|
||||
{0x17,0x17,0x17,"gray9"},
|
||||
{0xe5,0xe5,0xe5,"gray90"},
|
||||
{0xe8,0xe8,0xe8,"gray91"},
|
||||
{0xeb,0xeb,0xeb,"gray92"},
|
||||
{0xed,0xed,0xed,"gray93"},
|
||||
{0xf0,0xf0,0xf0,"gray94"},
|
||||
{0xf2,0xf2,0xf2,"gray95"},
|
||||
{0xf5,0xf5,0xf5,"gray96"},
|
||||
{0xf7,0xf7,0xf7,"gray97"},
|
||||
{0xfa,0xfa,0xfa,"gray98"},
|
||||
{0xfc,0xfc,0xfc,"gray99"},
|
||||
{0x00,0xff,0x00,"green"},
|
||||
{0xad,0xff,0x2f,"green yellow"},
|
||||
{0x00,0xff,0x00,"green1"},
|
||||
{0x00,0xee,0x00,"green2"},
|
||||
{0x00,0xcd,0x00,"green3"},
|
||||
{0x00,0x8b,0x00,"green4"},
|
||||
{0xad,0xff,0x2f,"greenyellow"},
|
||||
{0xbe,0xbe,0xbe,"grey"},
|
||||
{0x00,0x00,0x00,"grey0"},
|
||||
{0x03,0x03,0x03,"grey1"},
|
||||
{0x1a,0x1a,0x1a,"grey10"},
|
||||
{0xff,0xff,0xff,"grey100"},
|
||||
{0x1c,0x1c,0x1c,"grey11"},
|
||||
{0x1f,0x1f,0x1f,"grey12"},
|
||||
{0x21,0x21,0x21,"grey13"},
|
||||
{0x24,0x24,0x24,"grey14"},
|
||||
{0x26,0x26,0x26,"grey15"},
|
||||
{0x29,0x29,0x29,"grey16"},
|
||||
{0x2b,0x2b,0x2b,"grey17"},
|
||||
{0x2e,0x2e,0x2e,"grey18"},
|
||||
{0x30,0x30,0x30,"grey19"},
|
||||
{0x05,0x05,0x05,"grey2"},
|
||||
{0x33,0x33,0x33,"grey20"},
|
||||
{0x36,0x36,0x36,"grey21"},
|
||||
{0x38,0x38,0x38,"grey22"},
|
||||
{0x3b,0x3b,0x3b,"grey23"},
|
||||
{0x3d,0x3d,0x3d,"grey24"},
|
||||
{0x40,0x40,0x40,"grey25"},
|
||||
{0x42,0x42,0x42,"grey26"},
|
||||
{0x45,0x45,0x45,"grey27"},
|
||||
{0x47,0x47,0x47,"grey28"},
|
||||
{0x4a,0x4a,0x4a,"grey29"},
|
||||
{0x08,0x08,0x08,"grey3"},
|
||||
{0x4d,0x4d,0x4d,"grey30"},
|
||||
{0x4f,0x4f,0x4f,"grey31"},
|
||||
{0x52,0x52,0x52,"grey32"},
|
||||
{0x54,0x54,0x54,"grey33"},
|
||||
{0x57,0x57,0x57,"grey34"},
|
||||
{0x59,0x59,0x59,"grey35"},
|
||||
{0x5c,0x5c,0x5c,"grey36"},
|
||||
{0x5e,0x5e,0x5e,"grey37"},
|
||||
{0x61,0x61,0x61,"grey38"},
|
||||
{0x63,0x63,0x63,"grey39"},
|
||||
{0x0a,0x0a,0x0a,"grey4"},
|
||||
{0x66,0x66,0x66,"grey40"},
|
||||
{0x69,0x69,0x69,"grey41"},
|
||||
{0x6b,0x6b,0x6b,"grey42"},
|
||||
{0x6e,0x6e,0x6e,"grey43"},
|
||||
{0x70,0x70,0x70,"grey44"},
|
||||
{0x73,0x73,0x73,"grey45"},
|
||||
{0x75,0x75,0x75,"grey46"},
|
||||
{0x78,0x78,0x78,"grey47"},
|
||||
{0x7a,0x7a,0x7a,"grey48"},
|
||||
{0x7d,0x7d,0x7d,"grey49"},
|
||||
{0x0d,0x0d,0x0d,"grey5"},
|
||||
{0x7f,0x7f,0x7f,"grey50"},
|
||||
{0x82,0x82,0x82,"grey51"},
|
||||
{0x85,0x85,0x85,"grey52"},
|
||||
{0x87,0x87,0x87,"grey53"},
|
||||
{0x8a,0x8a,0x8a,"grey54"},
|
||||
{0x8c,0x8c,0x8c,"grey55"},
|
||||
{0x8f,0x8f,0x8f,"grey56"},
|
||||
{0x91,0x91,0x91,"grey57"},
|
||||
{0x94,0x94,0x94,"grey58"},
|
||||
{0x96,0x96,0x96,"grey59"},
|
||||
{0x0f,0x0f,0x0f,"grey6"},
|
||||
{0x99,0x99,0x99,"grey60"},
|
||||
{0x9c,0x9c,0x9c,"grey61"},
|
||||
{0x9e,0x9e,0x9e,"grey62"},
|
||||
{0xa1,0xa1,0xa1,"grey63"},
|
||||
{0xa3,0xa3,0xa3,"grey64"},
|
||||
{0xa6,0xa6,0xa6,"grey65"},
|
||||
{0xa8,0xa8,0xa8,"grey66"},
|
||||
{0xab,0xab,0xab,"grey67"},
|
||||
{0xad,0xad,0xad,"grey68"},
|
||||
{0xb0,0xb0,0xb0,"grey69"},
|
||||
{0x12,0x12,0x12,"grey7"},
|
||||
{0xb3,0xb3,0xb3,"grey70"},
|
||||
{0xb5,0xb5,0xb5,"grey71"},
|
||||
{0xb8,0xb8,0xb8,"grey72"},
|
||||
{0xba,0xba,0xba,"grey73"},
|
||||
{0xbd,0xbd,0xbd,"grey74"},
|
||||
{0xbf,0xbf,0xbf,"grey75"},
|
||||
{0xc2,0xc2,0xc2,"grey76"},
|
||||
{0xc4,0xc4,0xc4,"grey77"},
|
||||
{0xc7,0xc7,0xc7,"grey78"},
|
||||
{0xc9,0xc9,0xc9,"grey79"},
|
||||
{0x14,0x14,0x14,"grey8"},
|
||||
{0xcc,0xcc,0xcc,"grey80"},
|
||||
{0xcf,0xcf,0xcf,"grey81"},
|
||||
{0xd1,0xd1,0xd1,"grey82"},
|
||||
{0xd4,0xd4,0xd4,"grey83"},
|
||||
{0xd6,0xd6,0xd6,"grey84"},
|
||||
{0xd9,0xd9,0xd9,"grey85"},
|
||||
{0xdb,0xdb,0xdb,"grey86"},
|
||||
{0xde,0xde,0xde,"grey87"},
|
||||
{0xe0,0xe0,0xe0,"grey88"},
|
||||
{0xe3,0xe3,0xe3,"grey89"},
|
||||
{0x17,0x17,0x17,"grey9"},
|
||||
{0xe5,0xe5,0xe5,"grey90"},
|
||||
{0xe8,0xe8,0xe8,"grey91"},
|
||||
{0xeb,0xeb,0xeb,"grey92"},
|
||||
{0xed,0xed,0xed,"grey93"},
|
||||
{0xf0,0xf0,0xf0,"grey94"},
|
||||
{0xf2,0xf2,0xf2,"grey95"},
|
||||
{0xf5,0xf5,0xf5,"grey96"},
|
||||
{0xf7,0xf7,0xf7,"grey97"},
|
||||
{0xfa,0xfa,0xfa,"grey98"},
|
||||
{0xfc,0xfc,0xfc,"grey99"},
|
||||
{0xf0,0xff,0xf0,"honeydew"},
|
||||
{0xf0,0xff,0xf0,"honeydew1"},
|
||||
{0xe0,0xee,0xe0,"honeydew2"},
|
||||
{0xc1,0xcd,0xc1,"honeydew3"},
|
||||
{0x83,0x8b,0x83,"honeydew4"},
|
||||
{0xff,0x69,0xb4,"hot pink"},
|
||||
{0xff,0x69,0xb4,"hotpink"},
|
||||
{0xff,0x6e,0xb4,"hotpink1"},
|
||||
{0xee,0x6a,0xa7,"hotpink2"},
|
||||
{0xcd,0x60,0x90,"hotpink3"},
|
||||
{0x8b,0x3a,0x62,"hotpink4"},
|
||||
{0xcd,0x5c,0x5c,"indian red"},
|
||||
{0xcd,0x5c,0x5c,"indianred"},
|
||||
{0xff,0x6a,0x6a,"indianred1"},
|
||||
{0xee,0x63,0x63,"indianred2"},
|
||||
{0xcd,0x55,0x55,"indianred3"},
|
||||
{0x8b,0x3a,0x3a,"indianred4"},
|
||||
{0xff,0xff,0xf0,"ivory"},
|
||||
{0xff,0xff,0xf0,"ivory1"},
|
||||
{0xee,0xee,0xe0,"ivory2"},
|
||||
{0xcd,0xcd,0xc1,"ivory3"},
|
||||
{0x8b,0x8b,0x83,"ivory4"},
|
||||
{0xf0,0xe6,0x8c,"khaki"},
|
||||
{0xff,0xf6,0x8f,"khaki1"},
|
||||
{0xee,0xe6,0x85,"khaki2"},
|
||||
{0xcd,0xc6,0x73,"khaki3"},
|
||||
{0x8b,0x86,0x4e,"khaki4"},
|
||||
{0xe6,0xe6,0xfa,"lavender"},
|
||||
{0xff,0xf0,0xf5,"lavender blush"},
|
||||
{0xff,0xf0,0xf5,"lavenderblush"},
|
||||
{0xff,0xf0,0xf5,"lavenderblush1"},
|
||||
{0xee,0xe0,0xe5,"lavenderblush2"},
|
||||
{0xcd,0xc1,0xc5,"lavenderblush3"},
|
||||
{0x8b,0x83,0x86,"lavenderblush4"},
|
||||
{0x7c,0xfc,0x00,"lawn green"},
|
||||
{0x7c,0xfc,0x00,"lawngreen"},
|
||||
{0xff,0xfa,0xcd,"lemon chiffon"},
|
||||
{0xff,0xfa,0xcd,"lemonchiffon"},
|
||||
{0xff,0xfa,0xcd,"lemonchiffon1"},
|
||||
{0xee,0xe9,0xbf,"lemonchiffon2"},
|
||||
{0xcd,0xc9,0xa5,"lemonchiffon3"},
|
||||
{0x8b,0x89,0x70,"lemonchiffon4"},
|
||||
{0xad,0xd8,0xe6,"light blue"},
|
||||
{0xf0,0x80,0x80,"light coral"},
|
||||
{0xe0,0xff,0xff,"light cyan"},
|
||||
{0xee,0xdd,0x82,"light goldenrod"},
|
||||
{0xfa,0xfa,0xd2,"light goldenrod yellow"},
|
||||
{0xd3,0xd3,0xd3,"light gray"},
|
||||
{0x90,0xee,0x90,"light green"},
|
||||
{0xd3,0xd3,0xd3,"light grey"},
|
||||
{0xff,0xb6,0xc1,"light pink"},
|
||||
{0xff,0xa0,0x7a,"light salmon"},
|
||||
{0x20,0xb2,0xaa,"light sea green"},
|
||||
{0x87,0xce,0xfa,"light sky blue"},
|
||||
{0x84,0x70,0xff,"light slate blue"},
|
||||
{0x77,0x88,0x99,"light slate gray"},
|
||||
{0x77,0x88,0x99,"light slate grey"},
|
||||
{0xb0,0xc4,0xde,"light steel blue"},
|
||||
{0xff,0xff,0xe0,"light yellow"},
|
||||
{0xad,0xd8,0xe6,"lightblue"},
|
||||
{0xbf,0xef,0xff,"lightblue1"},
|
||||
{0xb2,0xdf,0xee,"lightblue2"},
|
||||
{0x9a,0xc0,0xcd,"lightblue3"},
|
||||
{0x68,0x83,0x8b,"lightblue4"},
|
||||
{0xf0,0x80,0x80,"lightcoral"},
|
||||
{0xe0,0xff,0xff,"lightcyan"},
|
||||
{0xe0,0xff,0xff,"lightcyan1"},
|
||||
{0xd1,0xee,0xee,"lightcyan2"},
|
||||
{0xb4,0xcd,0xcd,"lightcyan3"},
|
||||
{0x7a,0x8b,0x8b,"lightcyan4"},
|
||||
{0xee,0xdd,0x82,"lightgoldenrod"},
|
||||
{0xff,0xec,0x8b,"lightgoldenrod1"},
|
||||
{0xee,0xdc,0x82,"lightgoldenrod2"},
|
||||
{0xcd,0xbe,0x70,"lightgoldenrod3"},
|
||||
{0x8b,0x81,0x4c,"lightgoldenrod4"},
|
||||
{0xfa,0xfa,0xd2,"lightgoldenrodyellow"},
|
||||
{0xd3,0xd3,0xd3,"lightgray"},
|
||||
{0x90,0xee,0x90,"lightgreen"},
|
||||
{0xd3,0xd3,0xd3,"lightgrey"},
|
||||
{0xff,0xb6,0xc1,"lightpink"},
|
||||
{0xff,0xae,0xb9,"lightpink1"},
|
||||
{0xee,0xa2,0xad,"lightpink2"},
|
||||
{0xcd,0x8c,0x95,"lightpink3"},
|
||||
{0x8b,0x5f,0x65,"lightpink4"},
|
||||
{0xff,0xa0,0x7a,"lightsalmon"},
|
||||
{0xff,0xa0,0x7a,"lightsalmon1"},
|
||||
{0xee,0x95,0x72,"lightsalmon2"},
|
||||
{0xcd,0x81,0x62,"lightsalmon3"},
|
||||
{0x8b,0x57,0x42,"lightsalmon4"},
|
||||
{0x20,0xb2,0xaa,"lightseagreen"},
|
||||
{0x87,0xce,0xfa,"lightskyblue"},
|
||||
{0xb0,0xe2,0xff,"lightskyblue1"},
|
||||
{0xa4,0xd3,0xee,"lightskyblue2"},
|
||||
{0x8d,0xb6,0xcd,"lightskyblue3"},
|
||||
{0x60,0x7b,0x8b,"lightskyblue4"},
|
||||
{0x84,0x70,0xff,"lightslateblue"},
|
||||
{0x77,0x88,0x99,"lightslategray"},
|
||||
{0x77,0x88,0x99,"lightslategrey"},
|
||||
{0xb0,0xc4,0xde,"lightsteelblue"},
|
||||
{0xca,0xe1,0xff,"lightsteelblue1"},
|
||||
{0xbc,0xd2,0xee,"lightsteelblue2"},
|
||||
{0xa2,0xb5,0xcd,"lightsteelblue3"},
|
||||
{0x6e,0x7b,0x8b,"lightsteelblue4"},
|
||||
{0xff,0xff,0xe0,"lightyellow"},
|
||||
{0xff,0xff,0xe0,"lightyellow1"},
|
||||
{0xee,0xee,0xd1,"lightyellow2"},
|
||||
{0xcd,0xcd,0xb4,"lightyellow3"},
|
||||
{0x8b,0x8b,0x7a,"lightyellow4"},
|
||||
{0x32,0xcd,0x32,"lime green"},
|
||||
{0x32,0xcd,0x32,"limegreen"},
|
||||
{0xfa,0xf0,0xe6,"linen"},
|
||||
{0xff,0x00,0xff,"magenta"},
|
||||
{0xff,0x00,0xff,"magenta1"},
|
||||
{0xee,0x00,0xee,"magenta2"},
|
||||
{0xcd,0x00,0xcd,"magenta3"},
|
||||
{0x8b,0x00,0x8b,"magenta4"},
|
||||
{0xb0,0x30,0x60,"maroon"},
|
||||
{0xff,0x34,0xb3,"maroon1"},
|
||||
{0xee,0x30,0xa7,"maroon2"},
|
||||
{0xcd,0x29,0x90,"maroon3"},
|
||||
{0x8b,0x1c,0x62,"maroon4"},
|
||||
{0x66,0xcd,0xaa,"medium aquamarine"},
|
||||
{0x00,0x00,0xcd,"medium blue"},
|
||||
{0xba,0x55,0xd3,"medium orchid"},
|
||||
{0x93,0x70,0xdb,"medium purple"},
|
||||
{0x3c,0xb3,0x71,"medium sea green"},
|
||||
{0x7b,0x68,0xee,"medium slate blue"},
|
||||
{0x00,0xfa,0x9a,"medium spring green"},
|
||||
{0x48,0xd1,0xcc,"medium turquoise"},
|
||||
{0xc7,0x15,0x85,"medium violet red"},
|
||||
{0x66,0xcd,0xaa,"mediumaquamarine"},
|
||||
{0x00,0x00,0xcd,"mediumblue"},
|
||||
{0xba,0x55,0xd3,"mediumorchid"},
|
||||
{0xe0,0x66,0xff,"mediumorchid1"},
|
||||
{0xd1,0x5f,0xee,"mediumorchid2"},
|
||||
{0xb4,0x52,0xcd,"mediumorchid3"},
|
||||
{0x7a,0x37,0x8b,"mediumorchid4"},
|
||||
{0x93,0x70,0xdb,"mediumpurple"},
|
||||
{0xab,0x82,0xff,"mediumpurple1"},
|
||||
{0x9f,0x79,0xee,"mediumpurple2"},
|
||||
{0x89,0x68,0xcd,"mediumpurple3"},
|
||||
{0x5d,0x47,0x8b,"mediumpurple4"},
|
||||
{0x3c,0xb3,0x71,"mediumseagreen"},
|
||||
{0x7b,0x68,0xee,"mediumslateblue"},
|
||||
{0x00,0xfa,0x9a,"mediumspringgreen"},
|
||||
{0x48,0xd1,0xcc,"mediumturquoise"},
|
||||
{0xc7,0x15,0x85,"mediumvioletred"},
|
||||
{0x19,0x19,0x70,"midnight blue"},
|
||||
{0x19,0x19,0x70,"midnightblue"},
|
||||
{0xf5,0xff,0xfa,"mint cream"},
|
||||
{0xf5,0xff,0xfa,"mintcream"},
|
||||
{0xff,0xe4,0xe1,"misty rose"},
|
||||
{0xff,0xe4,0xe1,"mistyrose"},
|
||||
{0xff,0xe4,0xe1,"mistyrose1"},
|
||||
{0xee,0xd5,0xd2,"mistyrose2"},
|
||||
{0xcd,0xb7,0xb5,"mistyrose3"},
|
||||
{0x8b,0x7d,0x7b,"mistyrose4"},
|
||||
{0xff,0xe4,0xb5,"moccasin"},
|
||||
{0xff,0xde,0xad,"navajo white"},
|
||||
{0xff,0xde,0xad,"navajowhite"},
|
||||
{0xff,0xde,0xad,"navajowhite1"},
|
||||
{0xee,0xcf,0xa1,"navajowhite2"},
|
||||
{0xcd,0xb3,0x8b,"navajowhite3"},
|
||||
{0x8b,0x79,0x5e,"navajowhite4"},
|
||||
{0x00,0x00,0x80,"navy"},
|
||||
{0x00,0x00,0x80,"navy blue"},
|
||||
{0x00,0x00,0x80,"navyblue"},
|
||||
{0xfd,0xf5,0xe6,"old lace"},
|
||||
{0xfd,0xf5,0xe6,"oldlace"},
|
||||
{0x6b,0x8e,0x23,"olive drab"},
|
||||
{0x6b,0x8e,0x23,"olivedrab"},
|
||||
{0xc0,0xff,0x3e,"olivedrab1"},
|
||||
{0xb3,0xee,0x3a,"olivedrab2"},
|
||||
{0x9a,0xcd,0x32,"olivedrab3"},
|
||||
{0x69,0x8b,0x22,"olivedrab4"},
|
||||
{0xff,0xa5,0x00,"orange"},
|
||||
{0xff,0x45,0x00,"orange red"},
|
||||
{0xff,0xa5,0x00,"orange1"},
|
||||
{0xee,0x9a,0x00,"orange2"},
|
||||
{0xcd,0x85,0x00,"orange3"},
|
||||
{0x8b,0x5a,0x00,"orange4"},
|
||||
{0xff,0x45,0x00,"orangered"},
|
||||
{0xff,0x45,0x00,"orangered1"},
|
||||
{0xee,0x40,0x00,"orangered2"},
|
||||
{0xcd,0x37,0x00,"orangered3"},
|
||||
{0x8b,0x25,0x00,"orangered4"},
|
||||
{0xda,0x70,0xd6,"orchid"},
|
||||
{0xff,0x83,0xfa,"orchid1"},
|
||||
{0xee,0x7a,0xe9,"orchid2"},
|
||||
{0xcd,0x69,0xc9,"orchid3"},
|
||||
{0x8b,0x47,0x89,"orchid4"},
|
||||
{0xee,0xe8,0xaa,"pale goldenrod"},
|
||||
{0x98,0xfb,0x98,"pale green"},
|
||||
{0xaf,0xee,0xee,"pale turquoise"},
|
||||
{0xdb,0x70,0x93,"pale violet red"},
|
||||
{0xee,0xe8,0xaa,"palegoldenrod"},
|
||||
{0x98,0xfb,0x98,"palegreen"},
|
||||
{0x9a,0xff,0x9a,"palegreen1"},
|
||||
{0x90,0xee,0x90,"palegreen2"},
|
||||
{0x7c,0xcd,0x7c,"palegreen3"},
|
||||
{0x54,0x8b,0x54,"palegreen4"},
|
||||
{0xaf,0xee,0xee,"paleturquoise"},
|
||||
{0xbb,0xff,0xff,"paleturquoise1"},
|
||||
{0xae,0xee,0xee,"paleturquoise2"},
|
||||
{0x96,0xcd,0xcd,"paleturquoise3"},
|
||||
{0x66,0x8b,0x8b,"paleturquoise4"},
|
||||
{0xdb,0x70,0x93,"palevioletred"},
|
||||
{0xff,0x82,0xab,"palevioletred1"},
|
||||
{0xee,0x79,0x9f,"palevioletred2"},
|
||||
{0xcd,0x68,0x89,"palevioletred3"},
|
||||
{0x8b,0x47,0x5d,"palevioletred4"},
|
||||
{0xff,0xef,0xd5,"papaya whip"},
|
||||
{0xff,0xef,0xd5,"papayawhip"},
|
||||
{0xff,0xda,0xb9,"peach puff"},
|
||||
{0xff,0xda,0xb9,"peachpuff"},
|
||||
{0xff,0xda,0xb9,"peachpuff1"},
|
||||
{0xee,0xcb,0xad,"peachpuff2"},
|
||||
{0xcd,0xaf,0x95,"peachpuff3"},
|
||||
{0x8b,0x77,0x65,"peachpuff4"},
|
||||
{0xcd,0x85,0x3f,"peru"},
|
||||
{0xff,0xc0,0xcb,"pink"},
|
||||
{0xff,0xb5,0xc5,"pink1"},
|
||||
{0xee,0xa9,0xb8,"pink2"},
|
||||
{0xcd,0x91,0x9e,"pink3"},
|
||||
{0x8b,0x63,0x6c,"pink4"},
|
||||
{0xdd,0xa0,0xdd,"plum"},
|
||||
{0xff,0xbb,0xff,"plum1"},
|
||||
{0xee,0xae,0xee,"plum2"},
|
||||
{0xcd,0x96,0xcd,"plum3"},
|
||||
{0x8b,0x66,0x8b,"plum4"},
|
||||
{0xb0,0xe0,0xe6,"powder blue"},
|
||||
{0xb0,0xe0,0xe6,"powderblue"},
|
||||
{0xa0,0x20,0xf0,"purple"},
|
||||
{0x9b,0x30,0xff,"purple1"},
|
||||
{0x91,0x2c,0xee,"purple2"},
|
||||
{0x7d,0x26,0xcd,"purple3"},
|
||||
{0x55,0x1a,0x8b,"purple4"},
|
||||
{0xff,0x00,0x00,"red"},
|
||||
{0xff,0x00,0x00,"red1"},
|
||||
{0xee,0x00,0x00,"red2"},
|
||||
{0xcd,0x00,0x00,"red3"},
|
||||
{0x8b,0x00,0x00,"red4"},
|
||||
{0xbc,0x8f,0x8f,"rosy brown"},
|
||||
{0xbc,0x8f,0x8f,"rosybrown"},
|
||||
{0xff,0xc1,0xc1,"rosybrown1"},
|
||||
{0xee,0xb4,0xb4,"rosybrown2"},
|
||||
{0xcd,0x9b,0x9b,"rosybrown3"},
|
||||
{0x8b,0x69,0x69,"rosybrown4"},
|
||||
{0x41,0x69,0xe1,"royal blue"},
|
||||
{0x41,0x69,0xe1,"royalblue"},
|
||||
{0x48,0x76,0xff,"royalblue1"},
|
||||
{0x43,0x6e,0xee,"royalblue2"},
|
||||
{0x3a,0x5f,0xcd,"royalblue3"},
|
||||
{0x27,0x40,0x8b,"royalblue4"},
|
||||
{0x8b,0x45,0x13,"saddle brown"},
|
||||
{0x8b,0x45,0x13,"saddlebrown"},
|
||||
{0xfa,0x80,0x72,"salmon"},
|
||||
{0xff,0x8c,0x69,"salmon1"},
|
||||
{0xee,0x82,0x62,"salmon2"},
|
||||
{0xcd,0x70,0x54,"salmon3"},
|
||||
{0x8b,0x4c,0x39,"salmon4"},
|
||||
{0xf4,0xa4,0x60,"sandy brown"},
|
||||
{0xf4,0xa4,0x60,"sandybrown"},
|
||||
{0x2e,0x8b,0x57,"sea green"},
|
||||
{0x2e,0x8b,0x57,"seagreen"},
|
||||
{0x54,0xff,0x9f,"seagreen1"},
|
||||
{0x4e,0xee,0x94,"seagreen2"},
|
||||
{0x43,0xcd,0x80,"seagreen3"},
|
||||
{0x2e,0x8b,0x57,"seagreen4"},
|
||||
{0xff,0xf5,0xee,"seashell"},
|
||||
{0xff,0xf5,0xee,"seashell1"},
|
||||
{0xee,0xe5,0xde,"seashell2"},
|
||||
{0xcd,0xc5,0xbf,"seashell3"},
|
||||
{0x8b,0x86,0x82,"seashell4"},
|
||||
{0xa0,0x52,0x2d,"sienna"},
|
||||
{0xff,0x82,0x47,"sienna1"},
|
||||
{0xee,0x79,0x42,"sienna2"},
|
||||
{0xcd,0x68,0x39,"sienna3"},
|
||||
{0x8b,0x47,0x26,"sienna4"},
|
||||
{0x87,0xce,0xeb,"sky blue"},
|
||||
{0x87,0xce,0xeb,"skyblue"},
|
||||
{0x87,0xce,0xff,"skyblue1"},
|
||||
{0x7e,0xc0,0xee,"skyblue2"},
|
||||
{0x6c,0xa6,0xcd,"skyblue3"},
|
||||
{0x4a,0x70,0x8b,"skyblue4"},
|
||||
{0x6a,0x5a,0xcd,"slate blue"},
|
||||
{0x70,0x80,0x90,"slate gray"},
|
||||
{0x70,0x80,0x90,"slate grey"},
|
||||
{0x6a,0x5a,0xcd,"slateblue"},
|
||||
{0x83,0x6f,0xff,"slateblue1"},
|
||||
{0x7a,0x67,0xee,"slateblue2"},
|
||||
{0x69,0x59,0xcd,"slateblue3"},
|
||||
{0x47,0x3c,0x8b,"slateblue4"},
|
||||
{0x70,0x80,0x90,"slategray"},
|
||||
{0xc6,0xe2,0xff,"slategray1"},
|
||||
{0xb9,0xd3,0xee,"slategray2"},
|
||||
{0x9f,0xb6,0xcd,"slategray3"},
|
||||
{0x6c,0x7b,0x8b,"slategray4"},
|
||||
{0x70,0x80,0x90,"slategrey"},
|
||||
{0xff,0xfa,0xfa,"snow"},
|
||||
{0xff,0xfa,0xfa,"snow1"},
|
||||
{0xee,0xe9,0xe9,"snow2"},
|
||||
{0xcd,0xc9,0xc9,"snow3"},
|
||||
{0x8b,0x89,0x89,"snow4"},
|
||||
{0x00,0xff,0x7f,"spring green"},
|
||||
{0x00,0xff,0x7f,"springgreen"},
|
||||
{0x00,0xff,0x7f,"springgreen1"},
|
||||
{0x00,0xee,0x76,"springgreen2"},
|
||||
{0x00,0xcd,0x66,"springgreen3"},
|
||||
{0x00,0x8b,0x45,"springgreen4"},
|
||||
{0x46,0x82,0xb4,"steel blue"},
|
||||
{0x46,0x82,0xb4,"steelblue"},
|
||||
{0x63,0xb8,0xff,"steelblue1"},
|
||||
{0x5c,0xac,0xee,"steelblue2"},
|
||||
{0x4f,0x94,0xcd,"steelblue3"},
|
||||
{0x36,0x64,0x8b,"steelblue4"},
|
||||
{0xd2,0xb4,0x8c,"tan"},
|
||||
{0xff,0xa5,0x4f,"tan1"},
|
||||
{0xee,0x9a,0x49,"tan2"},
|
||||
{0xcd,0x85,0x3f,"tan3"},
|
||||
{0x8b,0x5a,0x2b,"tan4"},
|
||||
{0xd8,0xbf,0xd8,"thistle"},
|
||||
{0xff,0xe1,0xff,"thistle1"},
|
||||
{0xee,0xd2,0xee,"thistle2"},
|
||||
{0xcd,0xb5,0xcd,"thistle3"},
|
||||
{0x8b,0x7b,0x8b,"thistle4"},
|
||||
{0xff,0x63,0x47,"tomato"},
|
||||
{0xff,0x63,0x47,"tomato1"},
|
||||
{0xee,0x5c,0x42,"tomato2"},
|
||||
{0xcd,0x4f,0x39,"tomato3"},
|
||||
{0x8b,0x36,0x26,"tomato4"},
|
||||
{0x40,0xe0,0xd0,"turquoise"},
|
||||
{0x00,0xf5,0xff,"turquoise1"},
|
||||
{0x00,0xe5,0xee,"turquoise2"},
|
||||
{0x00,0xc5,0xcd,"turquoise3"},
|
||||
{0x00,0x86,0x8b,"turquoise4"},
|
||||
{0xee,0x82,0xee,"violet"},
|
||||
{0xd0,0x20,0x90,"violet red"},
|
||||
{0xd0,0x20,0x90,"violetred"},
|
||||
{0xff,0x3e,0x96,"violetred1"},
|
||||
{0xee,0x3a,0x8c,"violetred2"},
|
||||
{0xcd,0x32,0x78,"violetred3"},
|
||||
{0x8b,0x22,0x52,"violetred4"},
|
||||
{0xf5,0xde,0xb3,"wheat"},
|
||||
{0xff,0xe7,0xba,"wheat1"},
|
||||
{0xee,0xd8,0xae,"wheat2"},
|
||||
{0xcd,0xba,0x96,"wheat3"},
|
||||
{0x8b,0x7e,0x66,"wheat4"},
|
||||
{0xff,0xff,0xff,"white"},
|
||||
{0xf5,0xf5,0xf5,"white smoke"},
|
||||
{0xf5,0xf5,0xf5,"whitesmoke"},
|
||||
{0xff,0xff,0x00,"yellow"},
|
||||
{0x9a,0xcd,0x32,"yellow green"},
|
||||
{0xff,0xff,0x00,"yellow1"},
|
||||
{0xee,0xee,0x00,"yellow2"},
|
||||
{0xcd,0xcd,0x00,"yellow3"},
|
||||
{0x8b,0x8b,0x00,"yellow4"},
|
||||
{0x9a,0xcd,0x32,"yellowgreen"}
|
||||
}
|
||||
;
|
||||
|
||||
static int max_rgb_names = (int)
|
||||
(sizeof(rgb_names)/sizeof(struct rgb_and_name) );
|
||||
|
||||
int rgb_color_values(char *name, unsigned char &r,
|
||||
unsigned char &g, unsigned char &b)
|
||||
{
|
||||
int lwb, upb, mid, found, c;
|
||||
|
||||
if( !isalpha(name[0])) return 0;
|
||||
|
||||
mid = 0;
|
||||
while((c = name[mid])) { name[mid] = tolower(c); ++mid; }
|
||||
lwb = 0;
|
||||
upb = max_rgb_names - 1;
|
||||
|
||||
while (lwb <= upb)
|
||||
{
|
||||
mid = (lwb + upb)>>1;
|
||||
|
||||
found = strcmp(name, rgb_names[mid].cname);
|
||||
|
||||
if(found == 0)
|
||||
{
|
||||
r = rgb_names[mid].r;
|
||||
g = rgb_names[mid].g;
|
||||
b = rgb_names[mid].b;
|
||||
return 1;
|
||||
}
|
||||
if(found < 0)
|
||||
upb = mid - 1;
|
||||
else
|
||||
lwb = mid + 1;
|
||||
}
|
||||
r = 0; g = 0; b = 0;
|
||||
return 0;
|
||||
|
||||
}// rgb_color_values()
|
|
@ -0,0 +1,7 @@
|
|||
#ifndef _FLVIEWER_RGB_COLOR_HH_
|
||||
#define _FLVIEWER_RGB_COLOR_HH_
|
||||
|
||||
extern int rgb_color_values(char *name, unsigned char &r,
|
||||
unsigned char &g, unsigned char &b);
|
||||
|
||||
#endif //_FLVIEWER_RGB_COLOR_HH_
|
|
@ -0,0 +1,184 @@
|
|||
#ifndef _FLVIEWER_TREE_HH_
|
||||
#define _FLVIEWER_TREE_HH_
|
||||
|
||||
#include <FL/Fl_Tree.H>
|
||||
|
||||
#define MAX_ITEMBUF 254
|
||||
|
||||
class UserTree : public Fl_Tree
|
||||
{
|
||||
public:
|
||||
UserTree(int xx, int yy, int ww, int hh)
|
||||
: Fl_Tree(xx, yy, ww, hh, NULL)
|
||||
{ }
|
||||
virtual int handle(int event);
|
||||
};
|
||||
|
||||
extern UserTree *tree;
|
||||
|
||||
extern unsigned char box_name[33];
|
||||
|
||||
typedef struct jp2_cdef_info
|
||||
{
|
||||
unsigned short cn, typ, asoc;
|
||||
} jp2_cdef_info_t;
|
||||
|
||||
typedef struct jp2_cdef
|
||||
{
|
||||
jp2_cdef_info_t *info;
|
||||
unsigned short n;
|
||||
} jp2_cdef_t;
|
||||
|
||||
typedef struct jp2_cmap_comp
|
||||
{
|
||||
unsigned short cmp;
|
||||
unsigned char mtyp, pcol;
|
||||
} jp2_cmap_comp_t;
|
||||
|
||||
typedef struct jp2_pclr
|
||||
{
|
||||
unsigned int *entries;
|
||||
unsigned char *channel_sign;
|
||||
unsigned char *channel_size;
|
||||
jp2_cmap_comp_t *cmap;
|
||||
unsigned short nr_entries;
|
||||
unsigned char nr_channels;
|
||||
} jp2_pclr_t;
|
||||
|
||||
typedef struct jp2_color
|
||||
{
|
||||
unsigned char *icc_profile_buf;
|
||||
unsigned int icc_profile_len;
|
||||
|
||||
jp2_cdef_t *jp2_cdef;
|
||||
jp2_pclr_t *jp2_pclr;
|
||||
unsigned short has_colr, has_cdef;
|
||||
unsigned int enumcs, meth, precedence, approx;
|
||||
} jp2_color_t;
|
||||
|
||||
typedef struct sample
|
||||
{
|
||||
int64_t pos;
|
||||
unsigned int size;
|
||||
} sample_t;
|
||||
|
||||
typedef struct track
|
||||
{
|
||||
sample_t *samples;
|
||||
int max_samples;
|
||||
int nr_tracks;
|
||||
int max_tracks;
|
||||
|
||||
unsigned int duration;
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
} track_t;
|
||||
|
||||
extern track_t *Tracks;
|
||||
|
||||
typedef struct ftyp_info
|
||||
{
|
||||
unsigned int magic_len;
|
||||
int decod_format;
|
||||
unsigned int minv;
|
||||
unsigned char is_j2k, is_jp2, is_jpx, is_jpm, is_jpt;
|
||||
|
||||
unsigned char brand_jp2, brand_jpx, brand_jpm;
|
||||
|
||||
unsigned char compat_jp2, compat_jp21;
|
||||
|
||||
unsigned char compat_jpx, compat_jpxb;
|
||||
|
||||
unsigned char compat_jpm;
|
||||
|
||||
}FTYPInfo;
|
||||
|
||||
//--- PROTOTYPES
|
||||
|
||||
extern int JPEG2000_test_ftyp(const char *fname, unsigned char *s,
|
||||
uint64_t size, FTYPInfo *info);
|
||||
extern int JPEG2000_build_tree(const char *read_idf);
|
||||
|
||||
extern int read_mj2(unsigned char *parse_start, unsigned char *dend);
|
||||
extern int read_jpx(unsigned char *src, unsigned char *parse_start,
|
||||
unsigned char *dend);
|
||||
extern int read_jpm(unsigned char *src, unsigned char *parse_start,
|
||||
unsigned char *dend);
|
||||
|
||||
extern uint64_t read_boxheader(unsigned char *box, unsigned char *dend,
|
||||
unsigned int *out_siz);
|
||||
|
||||
extern uint64_t get8(const unsigned char *b);
|
||||
extern unsigned int get4(const unsigned char *b);
|
||||
extern unsigned int get2(const unsigned char *b);
|
||||
extern unsigned int get_size(const unsigned char *b, unsigned int size);
|
||||
|
||||
extern unsigned char *read_resc(unsigned char *s, unsigned char *box_end,
|
||||
const unsigned char *name_src);
|
||||
extern unsigned char *read_resd(unsigned char *s, unsigned char *box_end,
|
||||
const unsigned char *name_src);
|
||||
extern unsigned char *read_res(unsigned char *s, unsigned char *box_end,
|
||||
unsigned char *dend, const unsigned char *name_src);
|
||||
|
||||
extern unsigned char *read_ftyp(unsigned char *s, unsigned char *box_end,
|
||||
const char *name_src);
|
||||
extern unsigned char *read_jp2h(unsigned char *s, unsigned char *box_end,
|
||||
unsigned char *dend, const char *name_src);
|
||||
|
||||
extern unsigned char *read_ihdr(unsigned char *s, unsigned char *box_end,
|
||||
const char *name_src);
|
||||
extern unsigned char *read_bpcc(unsigned char *s, unsigned char *box_end,
|
||||
const char *name_src);
|
||||
|
||||
extern unsigned char *read_pclr(unsigned char *s, unsigned char *box_end,
|
||||
unsigned int *out_channels, const char *name_src);
|
||||
extern unsigned char *read_cmap(unsigned char *s, unsigned char *box_end,
|
||||
unsigned int nr_channels, const char *name_src);
|
||||
extern unsigned char *read_colr(unsigned char *s, unsigned char *box_end,
|
||||
const char *name_src);
|
||||
|
||||
extern unsigned char *read_cdef(unsigned char *s, unsigned char *box_end,
|
||||
const char *name_src);
|
||||
extern unsigned char *read_xml(unsigned char *s, unsigned char *box_end,
|
||||
unsigned char *dend, char **out_buf);
|
||||
|
||||
extern unsigned char *read_uuid(unsigned char *s, unsigned char *box_end,
|
||||
unsigned char *dend, const char *name_src);
|
||||
extern unsigned char *read_uinf(unsigned char *s, unsigned char *box_end,
|
||||
unsigned char *dend, const char *name_src);
|
||||
extern unsigned char *read_url(unsigned char *s, unsigned char *box_end,
|
||||
unsigned char *dend, const char *name_src);
|
||||
|
||||
extern unsigned char *read_ulst(unsigned char *s, unsigned char *box_end,
|
||||
unsigned char *dend, const char *name_src);
|
||||
|
||||
|
||||
extern unsigned char *read_jp2c(unsigned char *s, unsigned char *box_end,
|
||||
unsigned char *dend, const char *name_src);
|
||||
extern unsigned char *read_jp2i(unsigned char *s, unsigned char *box_end,
|
||||
unsigned char *dend, const char *name_src);
|
||||
extern unsigned char *read_dtbl(unsigned char *s, unsigned char *box_end,
|
||||
unsigned char *dend, const char *name_src);
|
||||
|
||||
|
||||
extern void FLViewer_set_max_mj2_samples(unsigned int n);
|
||||
extern void FLViewer_set_max_components(unsigned int n);
|
||||
extern void FLViewer_set_max_layers(unsigned int n);
|
||||
|
||||
extern int FLViewer_max_mj2_samples();
|
||||
extern void FLViewer_set_max_mj2_tracks(unsigned int n);
|
||||
|
||||
extern int FLViewer_max_layers();
|
||||
extern int FLViewer_layers();
|
||||
|
||||
extern int FLViewer_max_components();
|
||||
extern int FLViewer_component();
|
||||
|
||||
extern void FLViewer_set_max_tiles(int mx_tiles);
|
||||
extern void FLViewer_set_max_reduction(int mx_reduct);
|
||||
|
||||
extern unsigned char *OPENJPEG_mj2_decode(const char *read_idf,
|
||||
unsigned char *src, uint64_t size, int *out_selected);
|
||||
|
||||
|
||||
#endif /* _FLVIEWER_TREE_HH_ */
|
|
@ -0,0 +1,72 @@
|
|||
#ifndef _FLVIEWER_DEFS_HH_
|
||||
#define _FLVIEWER_DEFS_HH_
|
||||
|
||||
//-----------------------------------------
|
||||
#define LABEL_SIZE 14
|
||||
#define BAR_SIZE 17
|
||||
|
||||
#ifdef _WIN32
|
||||
#define WIN_X 30
|
||||
#define WIN_Y 35
|
||||
#else
|
||||
#define WIN_X 80
|
||||
#define WIN_Y 130
|
||||
#endif
|
||||
|
||||
#define BORDER_SIZE 5
|
||||
#define FRAMES_W 80
|
||||
#define TRACKS_W 60
|
||||
|
||||
#define BUTTON_W 80
|
||||
#define BUTTON_H 25
|
||||
|
||||
#define STEP_GROUP_W BUTTON_W*2
|
||||
|
||||
#define HEADER_H 160
|
||||
|
||||
#define MIN_SCROLLER_W BAR_SIZE
|
||||
#define MIN_SCROLLER_H BAR_SIZE
|
||||
|
||||
// Only if(movie_runs == 0); still images only:
|
||||
//
|
||||
#define MAX_SCROLLER_W 640 //500 // 590
|
||||
#define MAX_SCROLLER_H 480
|
||||
|
||||
#define SCROLLER_X 210
|
||||
#define SCROLLER_Y HEADER_H
|
||||
|
||||
#define TREE_X BORDER_SIZE
|
||||
#define TREE_Y SCROLLER_Y
|
||||
#define TREE_W 200
|
||||
#define TREE_H MAX_SCROLLER_H
|
||||
|
||||
#define HEADER_W TREE_W + BORDER_SIZE + MAX_SCROLLER_W -130
|
||||
|
||||
#define WINDOW_MIN_W BORDER_SIZE + HEADER_W + BORDER_SIZE
|
||||
#define WINDOW_MIN_H BORDER_SIZE + HEADER_H + TREE_H + BORDER_SIZE
|
||||
//-----------------------------------------
|
||||
#define PNG_MAGIC "\x89PNG\x0d\x0a\x1a\x0a"
|
||||
|
||||
/* JPEG2000 */
|
||||
#define JP2_RFC3745_MAGIC "\x00\x00\x00\x0c\x6a\x50\x20\x20\x0d\x0a\x87\x0a"
|
||||
#define JP2_MAGIC "\x0d\x0a\x87\x0a"
|
||||
/* position 45: "\xff\x52" */
|
||||
#define J2K_CODESTREAM_MAGIC "\xff\x4f\xff\x51"
|
||||
|
||||
#define J2K_CFMT 0
|
||||
#define JP2_CFMT 1
|
||||
#define JPT_CFMT 2
|
||||
|
||||
#define PXM_DFMT 10
|
||||
#define PGX_DFMT 11
|
||||
#define BMP_DFMT 12
|
||||
#define YUV_DFMT 13
|
||||
#define TIF_DFMT 14
|
||||
#define RAW_DFMT 15
|
||||
#define TGA_DFMT 16
|
||||
#define PNG_DFMT 17
|
||||
#define RAWL_DFMT 18
|
||||
|
||||
/* PROTOTYPES */
|
||||
|
||||
#endif /* _FLVIEWER_DEFS_HH_ */
|
|
@ -1349,10 +1349,6 @@ int main(int argc, char **argv)
|
|||
/* Close the byte stream */
|
||||
opj_stream_destroy(l_stream);
|
||||
|
||||
if(image->color_space == OPJ_CLRSPC_SYCC){
|
||||
color_sycc_to_rgb(image); /* FIXME */
|
||||
}
|
||||
|
||||
if( image->color_space != OPJ_CLRSPC_SYCC
|
||||
&& image->numcomps == 3 && image->comps[0].dx == image->comps[0].dy
|
||||
&& image->comps[1].dx != 1 )
|
||||
|
@ -1360,9 +1356,30 @@ int main(int argc, char **argv)
|
|||
else if (image->numcomps <= 2)
|
||||
image->color_space = OPJ_CLRSPC_GRAY;
|
||||
|
||||
if(image->color_space == OPJ_CLRSPC_SYCC){
|
||||
color_sycc_to_rgb(image);
|
||||
}
|
||||
else
|
||||
if(image->color_space == OPJ_CLRSPC_CMYK){
|
||||
color_cmyk_to_rgb(image);
|
||||
}
|
||||
else
|
||||
if(image->color_space == OPJ_CLRSPC_EYCC){
|
||||
color_esycc_to_rgb(image);
|
||||
}
|
||||
else
|
||||
if(image->color_space == OPJ_CLRSPC_CIELAB){
|
||||
#if defined(OPJ_HAVE_LIBLCMS1) || defined(OPJ_HAVE_LIBLCMS2)
|
||||
color_cielab_to_rgb(image);
|
||||
#endif
|
||||
free(image->icc_profile_buf);
|
||||
image->icc_profile_buf = NULL; image->icc_profile_len = 0;
|
||||
}
|
||||
|
||||
if(image->icc_profile_buf) {
|
||||
#if defined(OPJ_HAVE_LIBLCMS1) || defined(OPJ_HAVE_LIBLCMS2)
|
||||
color_apply_icc_profile(image); /* FIXME */
|
||||
if(image->icc_profile_len)
|
||||
color_apply_icc_profile(image);
|
||||
#endif
|
||||
free(image->icc_profile_buf);
|
||||
image->icc_profile_buf = NULL; image->icc_profile_len = 0;
|
||||
|
|
|
@ -8084,8 +8084,9 @@ OPJ_BOOL opj_j2k_decode_tile ( opj_j2k_t * p_j2k,
|
|||
p_j2k->m_specific_param.m_decoder.m_state = 0x0100;/*FIXME J2K_DEC_STATE_EOC;*/
|
||||
}
|
||||
else if (l_current_marker != J2K_MS_SOT)
|
||||
{
|
||||
if(opj_stream_get_number_byte_left(p_stream) == 0) {
|
||||
{
|
||||
/* openjpeg-data/input/nonregression/issue226.j2k : */
|
||||
if(opj_stream_get_number_byte_left(p_stream) <= 2) {
|
||||
p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_NEOC;
|
||||
opj_event_msg(p_manager, EVT_WARNING, "Stream does not end with EOC\n");
|
||||
return OPJ_TRUE;
|
||||
|
|
|
@ -849,6 +849,8 @@ static OPJ_BOOL opj_jp2_check_color(opj_image_t *image, opj_jp2_color_t *color,
|
|||
opj_event_msg(p_manager, EVT_ERROR, "Invalid component index %d (>= %d).\n", info[i].cn, nr_channels);
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
if (info[i].asoc > 65534) continue;
|
||||
|
||||
if (info[i].asoc > 0 && (OPJ_UINT32)(info[i].asoc - 1) >= nr_channels) {
|
||||
opj_event_msg(p_manager, EVT_ERROR, "Invalid component index %d (>= %d).\n", info[i].asoc - 1, nr_channels);
|
||||
return OPJ_FALSE;
|
||||
|
@ -1312,11 +1314,11 @@ static OPJ_BOOL opj_jp2_read_cdef( opj_jp2_t * jp2,
|
|||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
cdef_info = (opj_jp2_cdef_info_t*) opj_malloc(l_value * sizeof(opj_jp2_cdef_info_t));
|
||||
cdef_info = (opj_jp2_cdef_info_t*) opj_calloc(1, l_value * sizeof(opj_jp2_cdef_info_t));
|
||||
if (!cdef_info)
|
||||
return OPJ_FALSE;
|
||||
|
||||
jp2->color.jp2_cdef = (opj_jp2_cdef_t*)opj_malloc(sizeof(opj_jp2_cdef_t));
|
||||
jp2->color.jp2_cdef = (opj_jp2_cdef_t*)opj_calloc(1, sizeof(opj_jp2_cdef_t));
|
||||
if(!jp2->color.jp2_cdef)
|
||||
{
|
||||
opj_free(cdef_info);
|
||||
|
@ -1389,7 +1391,57 @@ static OPJ_BOOL opj_jp2_read_colr( opj_jp2_t *jp2,
|
|||
}
|
||||
|
||||
opj_read_bytes(p_colr_header_data,&jp2->enumcs ,4); /* EnumCS */
|
||||
|
||||
|
||||
p_colr_header_data += 4;
|
||||
|
||||
if(jp2->enumcs == 14
|
||||
&& (p_colr_header_size == 7 || p_colr_header_size == 35))/* CIELab */
|
||||
{
|
||||
OPJ_UINT32 *cielab;
|
||||
OPJ_UINT32 rl, ol, ra, oa, rb, ob, il;
|
||||
|
||||
cielab = (OPJ_UINT32*)opj_malloc(9 * sizeof(OPJ_UINT32));
|
||||
if(cielab == NULL)
|
||||
{
|
||||
opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to handle CIELab\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
cielab[0] = 14; /* enumcs */
|
||||
|
||||
if(p_colr_header_size == 7)/* default values */
|
||||
{
|
||||
rl = ra = rb = ol = oa = ob = 0;
|
||||
il = 0x00443530; /* D50 */
|
||||
cielab[1] = 0x44454600;/* DEF */
|
||||
}
|
||||
else
|
||||
/* if(p_colr_header_size == 35) */
|
||||
{
|
||||
opj_read_bytes(p_colr_header_data, &rl, 4);
|
||||
p_colr_header_data += 4;
|
||||
opj_read_bytes(p_colr_header_data, &ol, 4);
|
||||
p_colr_header_data += 4;
|
||||
opj_read_bytes(p_colr_header_data, &ra, 4);
|
||||
p_colr_header_data += 4;
|
||||
opj_read_bytes(p_colr_header_data, &oa, 4);
|
||||
p_colr_header_data += 4;
|
||||
opj_read_bytes(p_colr_header_data, &rb, 4);
|
||||
p_colr_header_data += 4;
|
||||
opj_read_bytes(p_colr_header_data, &ob, 4);
|
||||
p_colr_header_data += 4;
|
||||
opj_read_bytes(p_colr_header_data, &il, 4);
|
||||
p_colr_header_data += 4;
|
||||
|
||||
cielab[1] = 0;
|
||||
}
|
||||
cielab[2] = rl; cielab[4] = ra; cielab[6] = rb;
|
||||
cielab[3] = ol; cielab[5] = oa; cielab[7] = ob;
|
||||
cielab[8] = il;
|
||||
|
||||
jp2->color.icc_profile_buf = (unsigned char*)cielab;
|
||||
jp2->color.icc_profile_len = 0;
|
||||
}
|
||||
|
||||
jp2->color.jp2_has_colr = 1;
|
||||
}
|
||||
else if (jp2->meth == 2) {
|
||||
|
@ -1444,7 +1496,9 @@ OPJ_BOOL opj_jp2_decode(opj_jp2_t *jp2,
|
|||
}
|
||||
|
||||
/* Set Image Color Space */
|
||||
if (jp2->enumcs == 16)
|
||||
if (jp2->enumcs == 14)
|
||||
p_image->color_space = OPJ_CLRSPC_CIELAB;
|
||||
else if (jp2->enumcs == 16)
|
||||
p_image->color_space = OPJ_CLRSPC_SRGB;
|
||||
else if (jp2->enumcs == 17)
|
||||
p_image->color_space = OPJ_CLRSPC_GRAY;
|
||||
|
@ -1452,6 +1506,9 @@ OPJ_BOOL opj_jp2_decode(opj_jp2_t *jp2,
|
|||
p_image->color_space = OPJ_CLRSPC_SYCC;
|
||||
else if (jp2->enumcs == 24)
|
||||
p_image->color_space = OPJ_CLRSPC_EYCC;
|
||||
else
|
||||
if (jp2->enumcs == 12)
|
||||
p_image->color_space = OPJ_CLRSPC_CMYK;
|
||||
else
|
||||
p_image->color_space = OPJ_CLRSPC_UNKNOWN;
|
||||
|
||||
|
@ -1840,14 +1897,14 @@ OPJ_BOOL opj_jp2_setup_encoder( opj_jp2_t *jp2,
|
|||
opj_event_msg(p_manager, EVT_WARNING, "Multiple alpha channels specified. No cdef box will be created.\n");
|
||||
}
|
||||
if (alpha_count == 1U) { /* if here, we know what we can do */
|
||||
jp2->color.jp2_cdef = (opj_jp2_cdef_t*)opj_malloc(sizeof(opj_jp2_cdef_t));
|
||||
jp2->color.jp2_cdef = (opj_jp2_cdef_t*)opj_calloc(1, sizeof(opj_jp2_cdef_t));
|
||||
if(!jp2->color.jp2_cdef) {
|
||||
opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to setup the JP2 encoder\n");
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
/* no memset needed, all values will be overwritten except if jp2->color.jp2_cdef->info allocation fails, */
|
||||
/* in which case jp2->color.jp2_cdef->info will be NULL => valid for destruction */
|
||||
jp2->color.jp2_cdef->info = (opj_jp2_cdef_info_t*) opj_malloc(image->numcomps * sizeof(opj_jp2_cdef_info_t));
|
||||
jp2->color.jp2_cdef->info = (opj_jp2_cdef_info_t*) opj_calloc(1, image->numcomps * sizeof(opj_jp2_cdef_info_t));
|
||||
if (!jp2->color.jp2_cdef->info) {
|
||||
/* memory will be freed by opj_jp2_destroy */
|
||||
opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to setup the JP2 encoder\n");
|
||||
|
@ -2761,12 +2818,20 @@ OPJ_BOOL opj_jp2_get_tile( opj_jp2_t *p_jp2,
|
|||
}
|
||||
|
||||
/* Set Image Color Space */
|
||||
if (p_jp2->enumcs == 16)
|
||||
if (p_jp2->enumcs == 14)
|
||||
p_image->color_space = OPJ_CLRSPC_CIELAB;
|
||||
else if (p_jp2->enumcs == 16)
|
||||
p_image->color_space = OPJ_CLRSPC_SRGB;
|
||||
else if (p_jp2->enumcs == 17)
|
||||
p_image->color_space = OPJ_CLRSPC_GRAY;
|
||||
else if (p_jp2->enumcs == 18)
|
||||
p_image->color_space = OPJ_CLRSPC_SYCC;
|
||||
else
|
||||
if (p_jp2->enumcs == 24)
|
||||
p_image->color_space = OPJ_CLRSPC_EYCC;
|
||||
else
|
||||
if (p_jp2->enumcs == 12)
|
||||
p_image->color_space = OPJ_CLRSPC_CMYK;
|
||||
else
|
||||
p_image->color_space = OPJ_CLRSPC_UNKNOWN;
|
||||
|
||||
|
|
|
@ -283,7 +283,8 @@ typedef enum COLOR_SPACE {
|
|||
OPJ_CLRSPC_GRAY = 2, /**< grayscale */
|
||||
OPJ_CLRSPC_SYCC = 3, /**< YUV */
|
||||
OPJ_CLRSPC_EYCC = 4, /**< e-YCC */
|
||||
OPJ_CLRSPC_CMYK = 5 /**< CMYK */
|
||||
OPJ_CLRSPC_CMYK = 5, /**< CMYK */
|
||||
OPJ_CLRSPC_CIELAB = 6 /**< CIELab */
|
||||
} OPJ_COLOR_SPACE;
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue