112 #include <config_auto.h>
117 #include "allheaders.h"
119 extern l_float32 AlphaMaskBorderVals[2];
153 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
155 return (
PIX *)ERROR_PTR(
"ptas not defined", __func__, NULL);
157 return (
PIX *)ERROR_PTR(
"ptad not defined", __func__, NULL);
159 return (
PIX *)ERROR_PTR(
"invalid incolor", __func__, NULL);
161 return (
PIX *)ERROR_PTR(
"ptas count not 4", __func__, NULL);
163 return (
PIX *)ERROR_PTR(
"ptad count not 4", __func__, NULL);
196 l_int32 i, j, w, h, d, x, y, wpls, wpld, color, cmapindex;
198 l_uint32 *datas, *datad, *lines, *lined;
203 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
205 return (
PIX *)ERROR_PTR(
"vc not defined", __func__, NULL);
207 return (
PIX *)ERROR_PTR(
"invalid incolor", __func__, NULL);
209 if (d != 1 && d != 2 && d != 4 && d != 8 && d != 32)
210 return (
PIX *)ERROR_PTR(
"depth not 1, 2, 4, 8 or 16", __func__, NULL);
214 if ((cmap = pixGetColormap(pixs)) != NULL) {
232 wpls = pixGetWpl(pixs);
234 wpld = pixGetWpl(pixd);
235 for (i = 0; i < h; i++) {
236 lined = datad + i * wpld;
237 for (j = 0; j < w; j++) {
239 if (x < 0 || y < 0 || x >=w || y >= h)
241 lines = datas + y * wpls;
248 }
else if (d == 32) {
290 PIX *pixt1, *pixt2, *pixd;
293 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
295 return (
PIX *)ERROR_PTR(
"ptas not defined", __func__, NULL);
297 return (
PIX *)ERROR_PTR(
"ptad not defined", __func__, NULL);
299 return (
PIX *)ERROR_PTR(
"invalid incolor", __func__, NULL);
301 return (
PIX *)ERROR_PTR(
"ptas count not 4", __func__, NULL);
303 return (
PIX *)ERROR_PTR(
"ptad count not 4", __func__, NULL);
305 if (pixGetDepth(pixs) == 1)
310 d = pixGetDepth(pixt1);
315 d = pixGetDepth(pixt2);
323 colorval = 0xffffff00;
357 PIX *pixt1, *pixt2, *pixd;
360 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
362 return (
PIX *)ERROR_PTR(
"vc not defined", __func__, NULL);
364 if (pixGetDepth(pixs) == 1)
369 d = pixGetDepth(pixt1);
374 d = pixGetDepth(pixt2);
382 colorval = 0xffffff00;
414 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
416 return (
PIX *)ERROR_PTR(
"ptas not defined", __func__, NULL);
418 return (
PIX *)ERROR_PTR(
"ptad not defined", __func__, NULL);
419 if (pixGetDepth(pixs) != 32)
420 return (
PIX *)ERROR_PTR(
"pixs must be 32 bpp", __func__, NULL);
422 return (
PIX *)ERROR_PTR(
"ptas count not 4", __func__, NULL);
424 return (
PIX *)ERROR_PTR(
"ptad count not 4", __func__, NULL);
448 l_int32 i, j, w, h, d, wpls, wpld;
450 l_uint32 *datas, *datad, *lined;
452 PIX *pix1, *pix2, *pixd;
455 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
458 return (
PIX *)ERROR_PTR(
"pixs must be 32 bpp", __func__, NULL);
460 return (
PIX *)ERROR_PTR(
"vc not defined", __func__, NULL);
463 wpls = pixGetWpl(pixs);
467 wpld = pixGetWpl(pixd);
470 for (i = 0; i < h; i++) {
471 lined = datad + i * wpld;
472 for (j = 0; j < w; j++) {
482 if (pixGetSpp(pixs) == 4) {
513 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
515 return (
PIX *)ERROR_PTR(
"ptas not defined", __func__, NULL);
517 return (
PIX *)ERROR_PTR(
"ptad not defined", __func__, NULL);
518 if (pixGetDepth(pixs) != 8)
519 return (
PIX *)ERROR_PTR(
"pixs must be 8 bpp", __func__, NULL);
521 return (
PIX *)ERROR_PTR(
"ptas count not 4", __func__, NULL);
523 return (
PIX *)ERROR_PTR(
"ptad count not 4", __func__, NULL);
548 l_int32 i, j, w, h, wpls, wpld, val;
549 l_uint32 *datas, *datad, *lined;
554 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
556 if (pixGetDepth(pixs) != 8)
557 return (
PIX *)ERROR_PTR(
"pixs must be 8 bpp", __func__, NULL);
559 return (
PIX *)ERROR_PTR(
"vc not defined", __func__, NULL);
562 wpls = pixGetWpl(pixs);
566 wpld = pixGetWpl(pixd);
569 for (i = 0; i < h; i++) {
570 lined = datad + i * wpld;
571 for (j = 0; j < w; j++) {
639 PIX *pixd, *pixb1, *pixb2, *pixg2, *pixga;
643 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
645 if (d != 32 && pixGetColormap(pixs) == NULL)
646 return (
PIX *)ERROR_PTR(
"pixs not cmapped or 32 bpp", __func__, NULL);
647 if (pixg && pixGetDepth(pixg) != 8) {
648 L_WARNING(
"pixg not 8 bpp; using 'fract' transparent alpha\n",
652 if (!pixg && (fract < 0.0 || fract > 1.0)) {
653 L_WARNING(
"invalid fract; using 1.0 (fully transparent)\n", __func__);
656 if (!pixg && fract == 0.0)
657 L_WARNING(
"fully opaque alpha; image will not be blended\n", __func__);
659 return (
PIX *)ERROR_PTR(
"ptad not defined", __func__, NULL);
661 return (
PIX *)ERROR_PTR(
"ptas not defined", __func__, NULL);
682 if (ws > 10 && hs > 10) {
684 (l_int32)(255.0 * fract * AlphaMaskBorderVals[0]));
686 (l_int32)(255.0 * fract * AlphaMaskBorderVals[1]));
765 l_float32 x1, y1, x2, y2, x3, y3, x4, y4;
770 return ERROR_INT(
"ptas not defined", __func__, 1);
772 return ERROR_INT(
"ptad not defined", __func__, 1);
774 return ERROR_INT(
"&vc not defined", __func__, 1);
776 b = (l_float32 *)LEPT_CALLOC(8,
sizeof(l_float32));
787 for (i = 0; i < 8; i++)
788 a[i] = (l_float32 *)LEPT_CALLOC(8,
sizeof(l_float32));
792 a[0][6] = -x1 * b[0];
793 a[0][7] = -y1 * b[0];
797 a[1][6] = -x1 * b[1];
798 a[1][7] = -y1 * b[1];
802 a[2][6] = -x2 * b[2];
803 a[2][7] = -y2 * b[2];
807 a[3][6] = -x2 * b[3];
808 a[3][7] = -y2 * b[3];
812 a[4][6] = -x3 * b[4];
813 a[4][7] = -y3 * b[4];
817 a[5][6] = -x3 * b[5];
818 a[5][7] = -y3 * b[5];
822 a[6][6] = -x4 * b[6];
823 a[6][7] = -y4 * b[6];
827 a[7][6] = -x4 * b[7];
828 a[7][7] = -y4 * b[7];
832 for (i = 0; i < 8; i++)
864 return ERROR_INT(
"vc not defined", __func__, 1);
866 if ((denom = vc[6] * x + vc[7] * y + 1.0) == 0.0)
867 return ERROR_INT(
"denom = 0.0", __func__, 1);
868 factor = 1.0 / denom;
869 *pxp = (l_int32)(factor * (vc[0] * x + vc[1] * y + vc[2]) + 0.5);
870 *pyp = (l_int32)(factor * (vc[3] * x + vc[4] * y + vc[5]) + 0.5);
900 return ERROR_INT(
"vc not defined", __func__, 1);
902 if ((denom = vc[6] * x + vc[7] * y + 1.0) == 0.0)
903 return ERROR_INT(
"denom = 0.0", __func__, 1);
904 factor = 1.0 / denom;
905 *pxp = factor * (vc[0] * x + vc[1] * y + vc[2]);
906 *pyp = factor * (vc[3] * x + vc[4] * y + vc[5]);
l_ok linearInterpolatePixelColor(l_uint32 *datas, l_int32 wpls, l_int32 w, l_int32 h, l_float32 x, l_float32 y, l_uint32 colorval, l_uint32 *pval)
linearInterpolatePixelColor()
l_int32 gaussjordan(l_float32 **a, l_float32 *b, l_int32 n)
gaussjordan()
l_ok linearInterpolatePixelGray(l_uint32 *datas, l_int32 wpls, l_int32 w, l_int32 h, l_float32 x, l_float32 y, l_int32 grayval, l_int32 *pval)
linearInterpolatePixelGray()
#define GET_DATA_QBIT(pdata, n)
#define SET_DATA_DIBIT(pdata, n, val)
#define SET_DATA_BIT_VAL(pdata, n, val)
#define GET_DATA_BYTE(pdata, n)
#define GET_DATA_DIBIT(pdata, n)
#define SET_DATA_BYTE(pdata, n, val)
#define GET_DATA_BIT(pdata, n)
#define SET_DATA_QBIT(pdata, n, val)
l_ok pixcmapAddBlackOrWhite(PIXCMAP *cmap, l_int32 color, l_int32 *pindex)
pixcmapAddBlackOrWhite()
l_uint32 * pixGetData(PIX *pix)
pixGetData()
void pixDestroy(PIX **ppix)
pixDestroy()
l_ok pixGetDimensions(const PIX *pix, l_int32 *pw, l_int32 *ph, l_int32 *pd)
pixGetDimensions()
PIX * pixCreateTemplate(const PIX *pixs)
pixCreateTemplate()
PIX * pixCreate(l_int32 width, l_int32 height, l_int32 depth)
pixCreate()
PIX * pixClone(PIX *pixs)
pixClone()
l_ok pixSetBorderRingVal(PIX *pixs, l_int32 dist, l_uint32 val)
pixSetBorderRingVal()
PIX * pixGetRGBComponent(PIX *pixs, l_int32 comp)
pixGetRGBComponent()
l_ok pixClearAll(PIX *pix)
pixClearAll()
PIX * pixAddBorder(PIX *pixs, l_int32 npix, l_uint32 val)
pixAddBorder()
l_ok pixSetAll(PIX *pix)
pixSetAll()
l_ok pixSetRGBComponent(PIX *pixd, PIX *pixs, l_int32 comp)
pixSetRGBComponent()
l_ok pixSetAllArbitrary(PIX *pix, l_uint32 val)
pixSetAllArbitrary()
PIX * pixResizeToMatch(PIX *pixs, PIX *pixt, l_int32 w, l_int32 h)
pixResizeToMatch()
@ REMOVE_CMAP_BASED_ON_SRC
PIX * pixRemoveColormap(PIX *pixs, l_int32 type)
pixRemoveColormap()
PIX * pixConvertTo8(PIX *pixs, l_int32 cmapflag)
pixConvertTo8()
PIX * pixProjectivePtaGray(PIX *pixs, PTA *ptad, PTA *ptas, l_uint8 grayval)
pixProjectivePtaGray()
PIX * pixProjective(PIX *pixs, l_float32 *vc, l_int32 incolor)
pixProjective()
l_ok getProjectiveXformCoeffs(PTA *ptas, PTA *ptad, l_float32 **pvc)
getProjectiveXformCoeffs()
PIX * pixProjectiveGray(PIX *pixs, l_float32 *vc, l_uint8 grayval)
pixProjectiveGray()
PIX * pixProjectiveColor(PIX *pixs, l_float32 *vc, l_uint32 colorval)
pixProjectiveColor()
PIX * pixProjectiveSampled(PIX *pixs, l_float32 *vc, l_int32 incolor)
pixProjectiveSampled()
l_ok projectiveXformSampledPt(l_float32 *vc, l_int32 x, l_int32 y, l_int32 *pxp, l_int32 *pyp)
projectiveXformSampledPt()
PIX * pixProjectivePta(PIX *pixs, PTA *ptad, PTA *ptas, l_int32 incolor)
pixProjectivePta()
PIX * pixProjectivePtaWithAlpha(PIX *pixs, PTA *ptad, PTA *ptas, PIX *pixg, l_float32 fract, l_int32 border)
pixProjectivePtaWithAlpha()
l_ok projectiveXformPt(l_float32 *vc, l_int32 x, l_int32 y, l_float32 *pxp, l_float32 *pyp)
projectiveXformPt()
PIX * pixProjectivePtaColor(PIX *pixs, PTA *ptad, PTA *ptas, l_uint32 colorval)
pixProjectivePtaColor()
PIX * pixProjectiveSampledPta(PIX *pixs, PTA *ptad, PTA *ptas, l_int32 incolor)
pixProjectiveSampledPta()
l_ok ptaGetPt(PTA *pta, l_int32 index, l_float32 *px, l_float32 *py)
ptaGetPt()
l_int32 ptaGetCount(PTA *pta)
ptaGetCount()
void ptaDestroy(PTA **ppta)
ptaDestroy()
PTA * ptaTransform(PTA *ptas, l_int32 shiftx, l_int32 shifty, l_float32 scalex, l_float32 scaley)
ptaTransform()