108 #include <config_auto.h>
113 #include "allheaders.h"
131 if (depth != 1 && depth != 2 && depth !=4 && depth != 8)
132 return (
PIXCMAP *)ERROR_PTR(
"depth not in {1,2,4,8}", __func__, NULL);
136 cmap->
nalloc = 1 << depth;
176 l_int32 red[256], green[256], blue[256];
179 if (depth != 2 && depth != 4 && depth != 8)
180 return (
PIXCMAP *)ERROR_PTR(
"depth not in {2, 4, 8}", __func__, NULL);
181 if (hasblack != 0) hasblack = 1;
182 if (haswhite != 0) haswhite = 1;
185 ncolors = 1 << depth;
188 for (i = hasblack; i < ncolors - haswhite; i++) {
189 red[i] = (l_uint32)rand() & 0xff;
190 green[i] = (l_uint32)rand() & 0xff;
191 blue[i] = (l_uint32)rand() & 0xff;
218 l_int32 maxlevels, i, val;
221 if (d != 1 && d != 2 && d !=4 && d != 8)
222 return (
PIXCMAP *)ERROR_PTR(
"d not in {1, 2, 4, 8}", __func__, NULL);
224 if (nlevels < 2 || nlevels > maxlevels)
225 return (
PIXCMAP *)ERROR_PTR(
"invalid nlevels", __func__, NULL);
228 for (i = 0; i < nlevels; i++) {
229 val = (255 * i) / (nlevels - 1);
245 l_int32 nbytes, valid;
249 return (
PIXCMAP *)ERROR_PTR(
"cmaps not defined", __func__, NULL);
252 return (
PIXCMAP *)ERROR_PTR(
"invalid cmap", __func__, NULL);
256 cmapd->
array = (
void *)LEPT_CALLOC(1, nbytes);
277 L_WARNING(
"ptr address is null!\n", __func__);
281 if ((cmap = *pcmap) == NULL)
284 LEPT_FREE(cmap->
array);
312 l_int32 d, depth, nalloc, maxindex, maxcolors;
315 return ERROR_INT(
"&valid not defined", __func__, 1);
318 return ERROR_INT(
"cmap not defined", __func__, 1);
320 return ERROR_INT(
"cmap array not defined", __func__, 1);
322 if (d != 1 && d != 2 && d != 4 && d != 8) {
323 L_ERROR(
"invalid cmap depth: %d\n", __func__, d);
327 if (nalloc != (1 << d)) {
328 L_ERROR(
"invalid cmap nalloc = %d; d = %d\n", __func__, nalloc, d);
331 if (cmap->
n < 0 || cmap->
n > nalloc) {
332 L_ERROR(
"invalid cmap n: %d; nalloc = %d\n", __func__, cmap->
n, nalloc);
338 depth = pixGetDepth(pix);
340 L_ERROR(
"pix depth %d > 8\n", __func__, depth);
343 maxcolors = 1 << depth;
350 if (pix && (depth > d)) {
351 L_ERROR(
"(pix depth = %d) > (cmap depth = %d)\n", __func__, depth, d);
354 if (pix && cmap->
n < 1) {
355 L_ERROR(
"cmap array is empty; invalid with any pix\n", __func__);
364 if (pix && (cmap->
n > maxcolors)) {
365 L_ERROR(
"cmap entries = %d > max colors for pix = %d\n", __func__,
376 if (maxindex >= cmap->
n) {
377 L_ERROR(
"(max index = %d) >= (num colors = %d)\n", __func__,
411 return ERROR_INT(
"cmap not defined", __func__, 1);
413 return ERROR_INT(
"no free color entries", __func__, 1);
416 cta[cmap->
n].
red = rval;
417 cta[cmap->
n].
green = gval;
418 cta[cmap->
n].
blue = bval;
448 return ERROR_INT(
"cmap not defined", __func__, 1);
450 return ERROR_INT(
"no free color entries", __func__, 1);
453 cta[cmap->
n].
red = rval;
454 cta[cmap->
n].
green = gval;
455 cta[cmap->
n].
blue = bval;
456 cta[cmap->
n].
alpha = aval;
488 return ERROR_INT(
"&index not defined", __func__, 1);
491 return ERROR_INT(
"cmap not defined", __func__, 1);
499 L_WARNING(
"no free color entries\n", __func__);
535 return ERROR_INT(
"&index not defined", __func__, 1);
538 return ERROR_INT(
"cmap not defined", __func__, 1);
582 return ERROR_INT(
"&usable not defined", __func__, 1);
585 return ERROR_INT(
"cmap not defined", __func__, 1);
624 if (pindex) *pindex = 0;
626 return ERROR_INT(
"cmap not defined", __func__, 1);
662 return ERROR_INT(
"cmap not defined", __func__, 1);
686 return ERROR_INT(
"cmap not defined", __func__, 0);
701 return ERROR_INT(
"cmap not defined", __func__, 0);
702 return (cmap->
nalloc - cmap->
n);
716 return ERROR_INT(
"cmap not defined", __func__, 0);
740 return ERROR_INT(
"&mindepth not defined", __func__, 1);
743 return ERROR_INT(
"cmap not defined", __func__, 1);
748 else if (ncolors <= 16)
771 return ERROR_INT(
"cmap not defined", __func__, 1);
797 if (!prval || !pgval || !pbval)
798 return ERROR_INT(
"&rval, &gval, &bval not all defined", __func__, 1);
799 *prval = *pgval = *pbval = 0;
801 return ERROR_INT(
"cmap not defined", __func__, 1);
802 if (index < 0 || index >= cmap->
n)
803 return ERROR_INT(
"index out of bounds", __func__, 1);
806 *prval = cta[index].
red;
807 *pgval = cta[index].
green;
808 *pbval = cta[index].
blue;
831 l_int32 rval, gval, bval;
834 return ERROR_INT(
"&val32 not defined", __func__, 1);
838 return ERROR_INT(
"rgb values not found", __func__, 1);
862 if (!prval || !pgval || !pbval || !paval)
863 return ERROR_INT(
"&rval, &gval, &bval, &aval not all defined",
865 *prval = *pgval = *pbval = *paval = 0;
867 return ERROR_INT(
"cmap not defined", __func__, 1);
868 if (index < 0 || index >= cmap->
n)
869 return ERROR_INT(
"index out of bounds", __func__, 1);
872 *prval = cta[index].
red;
873 *pgval = cta[index].
green;
874 *pbval = cta[index].
blue;
875 *paval = cta[index].
alpha;
893 l_int32 rval, gval, bval, aval;
896 return ERROR_INT(
"&val32 not defined", __func__, 1);
900 return ERROR_INT(
"rgba values not found", __func__, 1);
932 return ERROR_INT(
"cmap not defined", __func__, 1);
933 if (index < 0 || index >= cmap->
n)
934 return ERROR_INT(
"index out of bounds", __func__, 1);
937 cta[index].
red = rval;
938 cta[index].
green = gval;
939 cta[index].
blue = bval;
940 cta[index].
alpha = 255;
969 return ERROR_INT(
"cmap not defined", __func__, 1);
970 if (index < 0 || index >= cmap->
n)
971 return ERROR_INT(
"index out of bounds", __func__, 1);
974 cta[index].
alpha = aval;
999 return ERROR_INT(
"&index not defined", __func__, 1);
1002 return ERROR_INT(
"cmap not defined", __func__, 1);
1006 for (i = 0; i < n; i++) {
1007 if (rval == cta[i].red &&
1008 gval == cta[i].green &&
1009 bval == cta[i].blue) {
1030 l_int32 *rmap, *gmap, *bmap;
1033 return ERROR_INT(
"&color not defined", __func__, 1);
1036 return ERROR_INT(
"cmap not defined", __func__, 1);
1039 return ERROR_INT(
"colormap arrays not made", __func__, 1);
1041 for (i = 0; i < n; i++) {
1042 if ((rmap[i] != gmap[i]) || (rmap[i] != bmap[i])) {
1070 return ERROR_INT(
"&opaque not defined", __func__, 1);
1073 return ERROR_INT(
"cmap not defined", __func__, 1);
1077 for (i = 0; i < n; i++) {
1078 if (cta[i].alpha != 255) {
1122 l_int32 *pmax_trans,
1123 l_int32 *pmin_opaque)
1125 l_int32 i, n, ntrans, max_trans, min_opaque, opaque_found;
1128 if (pntrans) *pntrans = 0;
1129 if (pmax_trans) *pmax_trans = -1;
1130 if (pmin_opaque) *pmin_opaque = 256;
1132 return ERROR_INT(
"cmap not defined", __func__, 1);
1139 opaque_found = FALSE;
1140 for (i = 0; i < n; i++) {
1141 if (cta[i].alpha != 255) {
1144 }
else if (opaque_found == FALSE) {
1145 opaque_found = TRUE;
1149 if (pntrans) *pntrans = ntrans;
1150 if (pmax_trans) *pmax_trans = max_trans;
1151 if (pmin_opaque) *pmin_opaque = min_opaque;
1166 l_int32 *pblackwhite)
1168 l_int32 val0, val1, hascolor;
1172 return ERROR_INT(
"&blackwhite not defined", __func__, 1);
1173 *pblackwhite = FALSE;
1175 return ERROR_INT(
"cmap not defined", __func__, 1);
1180 if (hascolor)
return 0;
1185 if ((val0 == 0 && val1 == 255) || (val0 == 255 && val1 == 0))
1186 *pblackwhite = TRUE;
1207 l_int32 n, i, rval, gval, bval, count;
1211 return ERROR_INT(
"&ngray not defined", __func__, 1);
1214 return ERROR_INT(
"cmap not defined", __func__, 1);
1216 array = (l_int32 *)LEPT_CALLOC(256,
sizeof(l_int32));
1219 for (i = 0; i < n; i++) {
1221 if ((rval == gval) && (rval == bval) && (array[rval] == 0)) {
1247 l_int32 n, i, rval, gval, bval, rankindex;
1251 return ERROR_INT(
"&index not defined", __func__, 1);
1254 return ERROR_INT(
"cmap not defined", __func__, 1);
1255 if (rankval < 0.0 || rankval > 1.0)
1256 return ERROR_INT(
"rankval not in [0.0 ... 1.0]", __func__, 1);
1260 for (i = 0; i < n; i++) {
1265 rankindex = (l_int32)(rankval * (n - 1) + 0.5);
1298 l_int32 i, n, delta, dist, mindist;
1302 return ERROR_INT(
"&index not defined", __func__, 1);
1305 return ERROR_INT(
"cmap not defined", __func__, 1);
1308 return ERROR_INT(
"cta not defined(!)", __func__, 1);
1311 mindist = 3 * 255 * 255 + 1;
1312 for (i = 0; i < n; i++) {
1313 delta = cta[i].
red - rval;
1314 dist = delta * delta;
1315 delta = cta[i].
green - gval;
1316 dist += delta * delta;
1317 delta = cta[i].
blue - bval;
1318 dist += delta * delta;
1319 if (dist < mindist) {
1352 l_int32 i, n, dist, mindist;
1356 return ERROR_INT(
"&index not defined", __func__, 1);
1359 return ERROR_INT(
"cmap not defined", __func__, 1);
1360 if (val < 0 || val > 255)
1361 return ERROR_INT(
"val not in [0 ... 255]", __func__, 1);
1364 return ERROR_INT(
"cta not defined(!)", __func__, 1);
1368 for (i = 0; i < n; i++) {
1369 dist = cta[i].
green - val;
1371 if (dist < mindist) {
1406 l_int32 n, delta, dist;
1410 return ERROR_INT(
"&dist not defined", __func__, 1);
1413 return ERROR_INT(
"cmap not defined", __func__, 1);
1416 return ERROR_INT(
"invalid index", __func__, 1);
1419 return ERROR_INT(
"cta not defined(!)", __func__, 1);
1421 delta = cta[index].
red - rval;
1422 dist = delta * delta;
1423 delta = cta[index].
green - gval;
1424 dist += delta * delta;
1425 delta = cta[index].
blue - bval;
1426 dist += delta * delta;
1460 l_int32 i, n, imin, imax, minval, maxval, rval, gval, bval, aveval;
1462 if (pminval) *pminval = UNDEF;
1463 if (pmaxval) *pmaxval = UNDEF;
1464 if (pminindex) *pminindex = UNDEF;
1465 if (pmaxindex) *pmaxindex = UNDEF;
1466 if (!pminval && !pmaxval && !pminindex && !pmaxindex)
1467 return ERROR_INT(
"no result requested", __func__, 1);
1469 return ERROR_INT(
"cmap not defined", __func__, 1);
1476 for (i = 0; i < n; i++) {
1479 if (rval < minval) {
1483 if (rval > maxval) {
1488 if (gval < minval) {
1492 if (gval > maxval) {
1497 if (bval < minval) {
1501 if (bval > maxval) {
1506 aveval = (rval + gval + bval) / 3;
1507 if (aveval < minval) {
1511 if (aveval > maxval) {
1516 return ERROR_INT(
"invalid selection", __func__, 1);
1520 if (pminval) *pminval = minval;
1521 if (pmaxval) *pmaxval = maxval;
1522 if (pminindex) *pminindex = imin;
1523 if (pmaxindex) *pmaxindex = imax;
1547 l_int32 i, rval, gval, bval;
1549 l_float32 invgamma, x;
1552 if (gamma <= 0.0) gamma = 1.0;
1555 curve = (l_int32 *)LEPT_CALLOC(64,
sizeof(l_int32));
1556 invgamma = 1. / gamma;
1557 for (i = 0; i < 64; i++) {
1558 x = (l_float32)i / 64.;
1559 curve[i] = (l_int32)(255. * powf(x, invgamma) + 0.5);
1563 for (i = 0; i < 256; i++) {
1567 bval = curve[i + 32];
1568 }
else if (i < 96) {
1570 gval = curve[i - 32];
1572 }
else if (i < 160) {
1573 rval = curve[i - 96];
1575 bval = curve[159 - i];
1576 }
else if (i < 224) {
1578 gval = curve[223 - i];
1581 rval = curve[287 - i];
1611 l_int32 i, rval, gval, bval;
1616 for (i = 0; i < 256; i++) {
1618 gval + (i * (255 - gval)) / 255,
1619 bval + (i * (255 - bval)) / 255);
1646 l_int32 i, n, rval, gval, bval, val;
1651 return (
PIXCMAP *)ERROR_PTR(
"cmaps not defined", __func__, NULL);
1652 if (rwt < 0.0 || gwt < 0.0 || bwt < 0.0)
1653 return (
PIXCMAP *)ERROR_PTR(
"weights not all >= 0.0", __func__, NULL);
1657 sum = rwt + gwt + bwt;
1659 L_WARNING(
"all weights zero; setting equal to 1/3\n", __func__);
1660 rwt = gwt = bwt = 0.33333;
1663 if (L_ABS(sum - 1.0) > 0.0001) {
1664 L_WARNING(
"weights don't sum to 1; maintaining ratios\n", __func__);
1671 return (
PIXCMAP *)ERROR_PTR(
"cmapd not made", __func__, NULL);
1673 for (i = 0; i < n; i++) {
1675 val = (l_int32)(rwt * rval + gwt * gval + bwt * bval + 0.5);
1698 l_int32 i, n, rval, gval, bval;
1702 return (
PIXCMAP *)ERROR_PTR(
"cmaps not defined", __func__, NULL);
1704 return (
PIXCMAP *)ERROR_PTR(
"cmaps not for 2 bpp pix", __func__, NULL);
1708 for (i = 0; i < n; i++) {
1731 l_int32 i, n, depth, rval, gval, bval;
1735 return (
PIXCMAP *)ERROR_PTR(
"cmaps not defined", __func__, NULL);
1738 if (depth != 2 && depth != 4)
1739 return (
PIXCMAP *)ERROR_PTR(
"cmaps not 2 or 4 bpp", __func__, NULL);
1743 for (i = 0; i < n; i++) {
1767 return (
PIXCMAP *)ERROR_PTR(
"filename not defined", __func__, NULL);
1770 return (
PIXCMAP *)ERROR_PTR(
"stream not opened", __func__, NULL);
1774 return (
PIXCMAP *)ERROR_PTR(
"cmap not read", __func__, NULL);
1788 l_int32 rval, gval, bval, aval, ignore;
1789 l_int32 i, index, ret, depth, ncolors;
1793 return (
PIXCMAP *)ERROR_PTR(
"stream not defined", __func__, NULL);
1795 ret = fscanf(fp,
"\nPixcmap: depth = %d bpp; %d colors\n",
1798 (depth != 1 && depth != 2 && depth != 4 && depth != 8) ||
1799 (ncolors < 2 || ncolors > 256))
1800 return (
PIXCMAP *)ERROR_PTR(
"invalid cmap size", __func__, NULL);
1801 ignore = fscanf(fp,
"Color R-val G-val B-val Alpha\n");
1802 ignore = fscanf(fp,
"----------------------------------------\n");
1805 return (
PIXCMAP *)ERROR_PTR(
"cmap not made", __func__, NULL);
1806 for (i = 0; i < ncolors; i++) {
1807 if (fscanf(fp,
"%3d %3d %3d %3d %3d\n",
1808 &index, &rval, &gval, &bval, &aval) != 5) {
1810 return (
PIXCMAP *)ERROR_PTR(
"invalid entry", __func__, NULL);
1833 return (
PIXCMAP *)ERROR_PTR(
"data not defined", __func__, NULL);
1835 return (
PIXCMAP *)ERROR_PTR(
"stream not opened", __func__, NULL);
1839 if (!cmap) L_ERROR(
"cmap not read\n", __func__);
1859 return ERROR_INT(
"filename not defined", __func__, 1);
1861 return ERROR_INT(
"cmap not defined", __func__, 1);
1864 return ERROR_INT(
"stream not opened", __func__, 1);
1868 return ERROR_INT(
"cmap not written to stream", __func__, 1);
1885 l_int32 *rmap, *gmap, *bmap, *amap;
1889 return ERROR_INT(
"stream not defined", __func__, 1);
1891 return ERROR_INT(
"cmap not defined", __func__, 1);
1894 return ERROR_INT(
"colormap arrays not made", __func__, 1);
1896 fprintf(fp,
"\nPixcmap: depth = %d bpp; %d colors\n", cmap->
depth, cmap->
n);
1897 fprintf(fp,
"Color R-val G-val B-val Alpha\n");
1898 fprintf(fp,
"----------------------------------------\n");
1899 for (i = 0; i < cmap->
n; i++)
1900 fprintf(fp,
"%3d %3d %3d %3d %3d\n",
1901 i, rmap[i], gmap[i], bmap[i], amap[i]);
1933 if (pdata) *pdata = NULL;
1934 if (psize) *psize = 0;
1936 return ERROR_INT(
"&data not defined", __func__, 1);
1938 return ERROR_INT(
"&size not defined", __func__, 1);
1940 return ERROR_INT(
"cmap not defined", __func__, 1);
1943 if ((fp = open_memstream((
char **)pdata, psize)) == NULL)
1944 return ERROR_INT(
"stream not opened", __func__, 1);
1948 *psize = *psize - 1;
1950 L_INFO(
"work-around: writing to a temp file\n", __func__);
1953 return ERROR_INT(
"tmpfile stream not opened", __func__, 1);
1955 if ((fp = tmpfile()) == NULL)
1956 return ERROR_INT(
"tmpfile stream not opened", __func__, 1);
1987 l_int32 *rmap, *gmap, *bmap, *amap;
1991 if (!prmap || !pgmap || !pbmap)
1992 return ERROR_INT(
"&rmap, &gmap, &bmap not all defined", __func__, 1);
1993 *prmap = *pgmap = *pbmap = NULL;
1994 if (pamap) *pamap = NULL;
1996 return ERROR_INT(
"cmap not defined", __func__, 1);
1999 rmap = (l_int32 *)LEPT_CALLOC(ncolors,
sizeof(l_int32));
2000 gmap = (l_int32 *)LEPT_CALLOC(ncolors,
sizeof(l_int32));
2001 bmap = (l_int32 *)LEPT_CALLOC(ncolors,
sizeof(l_int32));
2006 amap = (l_int32 *)LEPT_CALLOC(ncolors,
sizeof(l_int32));
2011 for (i = 0; i < ncolors; i++) {
2012 rmap[i] = cta[i].
red;
2013 gmap[i] = cta[i].
green;
2014 bmap[i] = cta[i].
blue;
2016 amap[i] = cta[i].
alpha;
2036 l_int32 i, ncolors, rval, gval, bval, aval;
2040 return ERROR_INT(
"&tab not defined", __func__, 1);
2043 return ERROR_INT(
"cmap not defined", __func__, 1);
2046 if (pncolors) *pncolors = ncolors;
2047 tab = (l_uint32 *)LEPT_CALLOC(ncolors,
sizeof(l_uint32));
2050 for (i = 0; i < ncolors; i++) {
2078 l_int32 i, ncolors, rval, gval, bval, aval;
2082 return ERROR_INT(
"&data not defined", __func__, 1);
2085 return ERROR_INT(
"&ncolors not defined", __func__, 1);
2088 return ERROR_INT(
"cmap not defined", __func__, 1);
2089 if (cpc != 3 && cpc != 4)
2090 return ERROR_INT(
"cpc not 3 or 4", __func__, 1);
2093 *pncolors = ncolors;
2094 data = (l_uint8 *)LEPT_CALLOC((
size_t)cpc * ncolors,
sizeof(l_uint8));
2097 for (i = 0; i < ncolors; i++) {
2099 data[cpc * i] = rval;
2100 data[cpc * i + 1] = gval;
2101 data[cpc * i + 2] = bval;
2103 data[cpc * i + 3] = aval;
2122 l_int32 i, d, rval, gval, bval, aval;
2126 return (
PIXCMAP *)ERROR_PTR(
"data not defined", __func__, NULL);
2127 if (cpc != 3 && cpc != 4)
2128 return (
PIXCMAP *)ERROR_PTR(
"cpc not 3 or 4", __func__, NULL);
2130 return (
PIXCMAP *)ERROR_PTR(
"no entries", __func__, NULL);
2132 return (
PIXCMAP *)ERROR_PTR(
"ncolors > 256", __func__, NULL);
2136 else if (ncolors > 4)
2138 else if (ncolors > 2)
2143 for (i = 0; i < ncolors; i++) {
2144 rval = data[cpc * i];
2145 gval = data[cpc * i + 1];
2146 bval = data[cpc * i + 2];
2148 aval = data[cpc * i + 3];
2180 l_int32 i, j, hexbytes;
2181 char *hexdata = NULL;
2185 return (
char *)ERROR_PTR(
"data not defined", __func__, NULL);
2187 return (
char *)ERROR_PTR(
"no colors", __func__, NULL);
2189 hexbytes = 2 + (2 * 3 + 1) * ncolors + 2;
2190 hexdata = (
char *)LEPT_CALLOC(hexbytes,
sizeof(
char));
2194 for (i = 0; i < ncolors; i++) {
2195 j = 2 + (2 * 3 + 1) * i;
2196 snprintf(buf,
sizeof(buf),
"%02x", data[3 * i]);
2197 hexdata[j] = buf[0];
2198 hexdata[j + 1] = buf[1];
2199 snprintf(buf,
sizeof(buf),
"%02x", data[3 * i + 1]);
2200 hexdata[j + 2] = buf[0];
2201 hexdata[j + 3] = buf[1];
2202 snprintf(buf,
sizeof(buf),
"%02x", data[3 * i + 2]);
2203 hexdata[j + 4] = buf[0];
2204 hexdata[j + 5] = buf[1];
2205 hexdata[j + 6] =
' ';
2207 hexdata[j + 7] =
'>';
2208 hexdata[j + 8] =
'\0';
2238 l_int32 rval, gval, bval, trval, tgval, tbval, i, ncolors;
2242 return ERROR_INT(
"cmap not defined", __func__, 1);
2244 L_WARNING(
"gamma must be > 0.0; setting to 1.0\n", __func__);
2247 if (minval >= maxval)
2248 return ERROR_INT(
"minval not < maxval", __func__, 1);
2250 if (gamma == 1.0 && minval == 0 && maxval == 255)
2253 if ((nag =
numaGammaTRC(gamma, minval, maxval)) == NULL)
2254 return ERROR_INT(
"nag not made", __func__, 1);
2257 for (i = 0; i < ncolors; i++) {
2289 l_int32 i, ncolors, rval, gval, bval, trval, tgval, tbval;
2293 return ERROR_INT(
"cmap not defined", __func__, 1);
2295 L_WARNING(
"factor must be >= 0.0; setting to 0.0\n", __func__);
2300 return ERROR_INT(
"nac not made", __func__, 1);
2303 for (i = 0; i < ncolors; i++) {
2339 l_int32 i, ncolors, rval, gval, bval;
2342 return ERROR_INT(
"cmap not defined", __func__, 1);
2343 if (fraction < -1.0 || fraction > 1.0)
2344 return ERROR_INT(
"fraction not in [-1.0, 1.0]", __func__, 1);
2347 for (i = 0; i < ncolors; i++) {
2351 (l_int32)((1.0 + fraction) * rval),
2352 (l_int32)((1.0 + fraction) * gval),
2353 (l_int32)((1.0 + fraction) * bval));
2356 rval + (l_int32)(fraction * (255 - rval)),
2357 gval + (l_int32)(fraction * (255 - gval)),
2358 bval + (l_int32)(fraction * (255 - bval)));
2388 l_int32 i, ncolors, rval, gval, bval;
2392 return ERROR_INT(
"cmap not defined", __func__, 1);
2395 for (i = 0; i < ncolors; i++) {
l_ok pixelShiftByComponent(l_int32 rval, l_int32 gval, l_int32 bval, l_uint32 srcval, l_uint32 dstval, l_uint32 *ppixel)
pixelShiftByComponent()
l_ok pixcmapSetAlpha(PIXCMAP *cmap, l_int32 index, l_int32 aval)
pixcmapSetAlpha()
void pixcmapDestroy(PIXCMAP **pcmap)
pixcmapDestroy()
PIXCMAP * pixcmapCreateRandom(l_int32 depth, l_int32 hasblack, l_int32 haswhite)
pixcmapCreateRandom()
l_ok pixcmapContrastTRC(PIXCMAP *cmap, l_float32 factor)
pixcmapContrastTRC()
l_ok pixcmapHasColor(PIXCMAP *cmap, l_int32 *pcolor)
pixcmapHasColor()
l_int32 pixcmapGetCount(const PIXCMAP *cmap)
pixcmapGetCount()
l_ok pixcmapGetDistanceToColor(PIXCMAP *cmap, l_int32 index, l_int32 rval, l_int32 gval, l_int32 bval, l_int32 *pdist)
pixcmapGetDistanceToColor()
PIXCMAP * pixcmapDeserializeFromMemory(l_uint8 *data, l_int32 cpc, l_int32 ncolors)
pixcmapDeserializeFromMemory()
l_ok pixcmapSetBlackAndWhite(PIXCMAP *cmap, l_int32 setblack, l_int32 setwhite)
pixcmapSetBlackAndWhite()
PIXCMAP * pixcmapReadStream(FILE *fp)
pixcmapReadStream()
l_ok pixcmapIsValid(const PIXCMAP *cmap, PIX *pix, l_int32 *pvalid)
pixcmapIsValid()
PIXCMAP * pixcmapConvertTo8(PIXCMAP *cmaps)
pixcmapConvertTo8()
l_ok pixcmapWriteStream(FILE *fp, const PIXCMAP *cmap)
pixcmapWriteStream()
PIXCMAP * pixcmapCreate(l_int32 depth)
pixcmapCreate()
l_ok pixcmapAddNewColor(PIXCMAP *cmap, l_int32 rval, l_int32 gval, l_int32 bval, l_int32 *pindex)
pixcmapAddNewColor()
l_ok pixcmapGetNearestIndex(PIXCMAP *cmap, l_int32 rval, l_int32 gval, l_int32 bval, l_int32 *pindex)
pixcmapGetNearestIndex()
l_ok pixcmapGetColor32(PIXCMAP *cmap, l_int32 index, l_uint32 *pval32)
pixcmapGetColor32()
l_ok pixcmapSerializeToMemory(PIXCMAP *cmap, l_int32 cpc, l_int32 *pncolors, l_uint8 **pdata)
pixcmapSerializeToMemory()
l_ok pixcmapWrite(const char *filename, const PIXCMAP *cmap)
pixcmapWrite()
l_ok pixcmapWriteMem(l_uint8 **pdata, size_t *psize, const PIXCMAP *cmap)
pixcmapWriteMem()
l_ok pixcmapAddRGBA(PIXCMAP *cmap, l_int32 rval, l_int32 gval, l_int32 bval, l_int32 aval)
pixcmapAddRGBA()
PIXCMAP * pixcmapGrayToFalseColor(l_float32 gamma)
pixcmapGrayToFalseColor()
PIXCMAP * pixcmapColorToGray(PIXCMAP *cmaps, l_float32 rwt, l_float32 gwt, l_float32 bwt)
pixcmapColorToGray()
PIXCMAP * pixcmapConvertTo4(PIXCMAP *cmaps)
pixcmapConvertTo4()
l_ok pixcmapAddBlackOrWhite(PIXCMAP *cmap, l_int32 color, l_int32 *pindex)
pixcmapAddBlackOrWhite()
l_ok pixcmapAddNearestColor(PIXCMAP *cmap, l_int32 rval, l_int32 gval, l_int32 bval, l_int32 *pindex)
pixcmapAddNearestColor()
l_ok pixcmapResetColor(PIXCMAP *cmap, l_int32 index, l_int32 rval, l_int32 gval, l_int32 bval)
pixcmapResetColor()
l_ok pixcmapGammaTRC(PIXCMAP *cmap, l_float32 gamma, l_int32 minval, l_int32 maxval)
pixcmapGammaTRC()
l_int32 pixcmapGetIndex(PIXCMAP *cmap, l_int32 rval, l_int32 gval, l_int32 bval, l_int32 *pindex)
pixcmapGetIndex()
char * pixcmapConvertToHex(l_uint8 *data, l_int32 ncolors)
pixcmapConvertToHex()
l_ok pixcmapCountGrayColors(PIXCMAP *cmap, l_int32 *pngray)
pixcmapCountGrayColors()
l_int32 pixcmapGetDepth(PIXCMAP *cmap)
pixcmapGetDepth()
l_ok pixcmapNonOpaqueColorsInfo(PIXCMAP *cmap, l_int32 *pntrans, l_int32 *pmax_trans, l_int32 *pmin_opaque)
pixcmapNonOpaqueColorsInfo()
l_ok pixcmapUsableColor(PIXCMAP *cmap, l_int32 rval, l_int32 gval, l_int32 bval, l_int32 *pusable)
pixcmapUsableColor()
l_ok pixcmapShiftIntensity(PIXCMAP *cmap, l_float32 fraction)
pixcmapShiftIntensity()
l_ok pixcmapGetColor(PIXCMAP *cmap, l_int32 index, l_int32 *prval, l_int32 *pgval, l_int32 *pbval)
pixcmapGetColor()
l_ok pixcmapIsOpaque(PIXCMAP *cmap, l_int32 *popaque)
pixcmapIsOpaque()
l_ok pixcmapGetMinDepth(PIXCMAP *cmap, l_int32 *pmindepth)
pixcmapGetMinDepth()
PIXCMAP * pixcmapGrayToColor(l_uint32 color)
pixcmapGrayToColor()
l_int32 pixcmapGetFreeCount(PIXCMAP *cmap)
pixcmapGetFreeCount()
l_ok pixcmapGetRangeValues(PIXCMAP *cmap, l_int32 select, l_int32 *pminval, l_int32 *pmaxval, l_int32 *pminindex, l_int32 *pmaxindex)
pixcmapGetRangeValues()
l_ok pixcmapClear(PIXCMAP *cmap)
pixcmapClear()
l_ok pixcmapGetRankIntensity(PIXCMAP *cmap, l_float32 rankval, l_int32 *pindex)
pixcmapGetRankIntensity()
PIXCMAP * pixcmapCreateLinear(l_int32 d, l_int32 nlevels)
pixcmapCreateLinear()
l_ok pixcmapGetRGBA(PIXCMAP *cmap, l_int32 index, l_int32 *prval, l_int32 *pgval, l_int32 *pbval, l_int32 *paval)
pixcmapGetRGBA()
l_ok pixcmapToArrays(const PIXCMAP *cmap, l_int32 **prmap, l_int32 **pgmap, l_int32 **pbmap, l_int32 **pamap)
pixcmapToArrays()
PIXCMAP * pixcmapReadMem(const l_uint8 *data, size_t size)
pixcmapReadMem()
l_ok pixcmapShiftByComponent(PIXCMAP *cmap, l_uint32 srcval, l_uint32 dstval)
pixcmapShiftByComponent()
l_ok pixcmapIsBlackAndWhite(PIXCMAP *cmap, l_int32 *pblackwhite)
pixcmapIsBlackAndWhite()
PIXCMAP * pixcmapCopy(const PIXCMAP *cmaps)
pixcmapCopy()
l_ok pixcmapAddColor(PIXCMAP *cmap, l_int32 rval, l_int32 gval, l_int32 bval)
pixcmapAddColor()
PIXCMAP * pixcmapRead(const char *filename)
pixcmapRead()
l_ok pixcmapGetNearestGrayIndex(PIXCMAP *cmap, l_int32 val, l_int32 *pindex)
pixcmapGetNearestGrayIndex()
l_ok pixcmapToRGBTable(PIXCMAP *cmap, l_uint32 **ptab, l_int32 *pncolors)
pixcmapToRGBTable()
l_ok pixcmapGetRGBA32(PIXCMAP *cmap, l_int32 index, l_uint32 *pval32)
pixcmapGetRGBA32()
NUMA * numaContrastTRC(l_float32 factor)
numaContrastTRC()
NUMA * numaGammaTRC(l_float32 gamma, l_int32 minval, l_int32 maxval)
numaGammaTRC()
l_ok numaAddNumber(NUMA *na, l_float32 val)
numaAddNumber()
NUMA * numaCreate(l_int32 n)
numaCreate()
void numaDestroy(NUMA **pna)
numaDestroy()
l_ok numaGetIValue(NUMA *na, l_int32 index, l_int32 *pival)
numaGetIValue()
NUMA * numaGetSortIndex(NUMA *na, l_int32 sortorder)
numaGetSortIndex()
l_ok composeRGBAPixel(l_int32 rval, l_int32 gval, l_int32 bval, l_int32 aval, l_uint32 *ppixel)
composeRGBAPixel()
void extractRGBValues(l_uint32 pixel, l_int32 *prval, l_int32 *pgval, l_int32 *pbval)
extractRGBValues()
l_ok pixGetMaxColorIndex(PIX *pixs, l_int32 *pmaxindex)
pixGetMaxColorIndex()
struct RGBA_Quad RGBA_QUAD
l_uint8 * l_binaryReadStream(FILE *fp, size_t *pnbytes)
l_binaryReadStream()
FILE * fopenReadFromMemory(const l_uint8 *data, size_t size)
fopenReadFromMemory()
FILE * fopenWriteStream(const char *filename, const char *modestring)
fopenWriteStream()
FILE * fopenWriteWinTempfile(void)
fopenWriteWinTempfile()
FILE * fopenReadStream(const char *filename)
fopenReadStream()