113#include <config_auto.h>
118#include "allheaders.h"
120extern l_float32 AlphaMaskBorderVals[2];
154 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
156 return (
PIX *)ERROR_PTR(
"ptas not defined", __func__, NULL);
158 return (
PIX *)ERROR_PTR(
"ptad not defined", __func__, NULL);
160 return (
PIX *)ERROR_PTR(
"invalid incolor", __func__, NULL);
161 if (ptaGetCount(ptas) != 4)
162 return (
PIX *)ERROR_PTR(
"ptas count not 4", __func__, NULL);
163 if (ptaGetCount(ptad) != 4)
164 return (
PIX *)ERROR_PTR(
"ptad count not 4", __func__, NULL);
197l_int32 i, j, w, h, d, x, y, wpls, wpld, color, cmapindex;
199l_uint32 *datas, *datad, *lines, *lined;
204 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
206 return (
PIX *)ERROR_PTR(
"vc not defined", __func__, NULL);
208 return (
PIX *)ERROR_PTR(
"invalid incolor", __func__, NULL);
209 pixGetDimensions(pixs, &w, &h, &d);
210 if (d != 1 && d != 2 && d != 4 && d != 8 && d != 32)
211 return (
PIX *)ERROR_PTR(
"depth not 1, 2, 4, 8 or 16", __func__, NULL);
214 pixd = pixCreateTemplate(pixs);
215 if ((cmap = pixGetColormap(pixs)) != NULL) {
220 pixcmapAddBlackOrWhite(cmap, color, &cmapindex);
221 pixSetAllArbitrary(pixd, cmapindex);
232 datas = pixGetData(pixs);
233 wpls = pixGetWpl(pixs);
234 datad = pixGetData(pixd);
235 wpld = pixGetWpl(pixd);
236 for (i = 0; i < h; i++) {
237 lined = datad + i * wpld;
238 for (j = 0; j < w; j++) {
240 if (x < 0 || y < 0 || x >=w || y >= h)
242 lines = datas + y * wpls;
249 }
else if (d == 32) {
291PIX *pixt1, *pixt2, *pixd;
294 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
296 return (
PIX *)ERROR_PTR(
"ptas not defined", __func__, NULL);
298 return (
PIX *)ERROR_PTR(
"ptad not defined", __func__, NULL);
300 return (
PIX *)ERROR_PTR(
"invalid incolor", __func__, NULL);
301 if (ptaGetCount(ptas) != 4)
302 return (
PIX *)ERROR_PTR(
"ptas count not 4", __func__, NULL);
303 if (ptaGetCount(ptad) != 4)
304 return (
PIX *)ERROR_PTR(
"ptad count not 4", __func__, NULL);
306 if (pixGetDepth(pixs) == 1)
311 d = pixGetDepth(pixt1);
313 pixt2 = pixConvertTo8(pixt1, FALSE);
315 pixt2 = pixClone(pixt1);
316 d = pixGetDepth(pixt2);
324 colorval = 0xffffff00;
358PIX *pixt1, *pixt2, *pixd;
361 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
363 return (
PIX *)ERROR_PTR(
"vc not defined", __func__, NULL);
365 if (pixGetDepth(pixs) == 1)
370 d = pixGetDepth(pixt1);
372 pixt2 = pixConvertTo8(pixt1, FALSE);
374 pixt2 = pixClone(pixt1);
375 d = pixGetDepth(pixt2);
383 colorval = 0xffffff00;
415 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
417 return (
PIX *)ERROR_PTR(
"ptas not defined", __func__, NULL);
419 return (
PIX *)ERROR_PTR(
"ptad not defined", __func__, NULL);
420 if (pixGetDepth(pixs) != 32)
421 return (
PIX *)ERROR_PTR(
"pixs must be 32 bpp", __func__, NULL);
422 if (ptaGetCount(ptas) != 4)
423 return (
PIX *)ERROR_PTR(
"ptas count not 4", __func__, NULL);
424 if (ptaGetCount(ptad) != 4)
425 return (
PIX *)ERROR_PTR(
"ptad count not 4", __func__, NULL);
449l_int32 i, j, w, h, d, wpls, wpld;
451l_uint32 *datas, *datad, *lined;
453PIX *pix1, *pix2, *pixd;
456 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
457 pixGetDimensions(pixs, &w, &h, &d);
459 return (
PIX *)ERROR_PTR(
"pixs must be 32 bpp", __func__, NULL);
461 return (
PIX *)ERROR_PTR(
"vc not defined", __func__, NULL);
463 datas = pixGetData(pixs);
464 wpls = pixGetWpl(pixs);
465 pixd = pixCreateTemplate(pixs);
466 pixSetAllArbitrary(pixd, colorval);
467 datad = pixGetData(pixd);
468 wpld = pixGetWpl(pixd);
471 for (i = 0; i < h; i++) {
472 lined = datad + i * wpld;
473 for (j = 0; j < w; j++) {
483 if (pixGetSpp(pixs) == 4) {
514 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
516 return (
PIX *)ERROR_PTR(
"ptas not defined", __func__, NULL);
518 return (
PIX *)ERROR_PTR(
"ptad not defined", __func__, NULL);
519 if (pixGetDepth(pixs) != 8)
520 return (
PIX *)ERROR_PTR(
"pixs must be 8 bpp", __func__, NULL);
521 if (ptaGetCount(ptas) != 4)
522 return (
PIX *)ERROR_PTR(
"ptas count not 4", __func__, NULL);
523 if (ptaGetCount(ptad) != 4)
524 return (
PIX *)ERROR_PTR(
"ptad count not 4", __func__, NULL);
548l_int32 i, j, w, h, wpls, wpld, val;
549l_uint32 *datas, *datad, *lined;
554 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
555 pixGetDimensions(pixs, &w, &h, 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);
561 datas = pixGetData(pixs);
562 wpls = pixGetWpl(pixs);
563 pixd = pixCreateTemplate(pixs);
564 pixSetAllArbitrary(pixd, grayval);
565 datad = pixGetData(pixd);
566 wpld = pixGetWpl(pixd);
569 for (i = 0; i < h; i++) {
570 lined = datad + i * wpld;
571 for (j = 0; j < w; j++) {
638PIX *pixd, *pixb1, *pixb2, *pixg2, *pixga;
642 return (
PIX *)ERROR_PTR(
"pixs not defined", __func__, NULL);
643 pixGetDimensions(pixs, &ws, &hs, &d);
644 if (d != 32 && pixGetColormap(pixs) == NULL)
645 return (
PIX *)ERROR_PTR(
"pixs not cmapped or 32 bpp", __func__, NULL);
646 if (pixg && pixGetDepth(pixg) != 8) {
647 L_WARNING(
"pixg not 8 bpp; using 'fract' transparent alpha\n",
651 if (!pixg && (fract < 0.0 || fract > 1.0)) {
652 L_WARNING(
"invalid fract; using 1.0 (fully transparent)\n", __func__);
655 if (!pixg && fract == 0.0)
656 L_WARNING(
"fully opaque alpha; image cannot be blended\n", __func__);
658 return (
PIX *)ERROR_PTR(
"ptad not defined", __func__, NULL);
660 return (
PIX *)ERROR_PTR(
"ptas not defined", __func__, NULL);
663 pixb1 = pixAddBorder(pixs, border, 0);
666 ptad2 = ptaTransform(ptad, border, border, 1.0, 1.0);
667 ptas2 = ptaTransform(ptas, border, border, 1.0, 1.0);
672 pixg2 = pixCreate(ws, hs, 8);
676 pixSetAllArbitrary(pixg2, (l_int32)(255.0 * fract));
678 pixg2 = pixResizeToMatch(pixg, NULL, ws, hs);
680 if (ws > 10 && hs > 10) {
681 pixSetBorderRingVal(pixg2, 1,
682 (l_int32)(255.0 * fract * AlphaMaskBorderVals[0]));
683 pixSetBorderRingVal(pixg2, 2,
684 (l_int32)(255.0 * fract * AlphaMaskBorderVals[1]));
687 pixb2 = pixAddBorder(pixg2, border, 0);
765l_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));
778 ptaGetPt(ptas, 0, &x1, &y1);
779 ptaGetPt(ptas, 1, &x2, &y2);
780 ptaGetPt(ptas, 2, &x3, &y3);
781 ptaGetPt(ptas, 3, &x4, &y4);
782 ptaGetPt(ptad, 0, &b[0], &b[1]);
783 ptaGetPt(ptad, 1, &b[2], &b[3]);
784 ptaGetPt(ptad, 2, &b[4], &b[5]);
785 ptaGetPt(ptad, 3, &b[6], &b[7]);
787 for (i = 0; i < 8; i++)
788 a[i] = (l_float32 *)LEPT_CALLOC(8,
sizeof(l_float32));
824 for (i = 0; i < 8; i++)
853 return ERROR_INT(
"vc not defined", __func__, 1);
855 *pxp = (l_int32)(vc[0] * x + vc[1] * y + vc[2] * x * y + vc[3] + 0.5);
856 *pyp = (l_int32)(vc[4] * x + vc[5] * y + vc[6] * x * y + vc[7] + 0.5);
883 return ERROR_INT(
"vc not defined", __func__, 1);
885 *pxp = vc[0] * x + vc[1] * y + vc[2] * x * y + vc[3];
886 *pyp = vc[4] * x + vc[5] * y + vc[6] * x * y + vc[7];
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)
PIX * pixBilinearPtaWithAlpha(PIX *pixs, PTA *ptad, PTA *ptas, PIX *pixg, l_float32 fract, l_int32 border)
pixBilinearPtaWithAlpha()
PIX * pixBilinearColor(PIX *pixs, l_float32 *vc, l_uint32 colorval)
pixBilinearColor()
PIX * pixBilinearSampled(PIX *pixs, l_float32 *vc, l_int32 incolor)
pixBilinearSampled()
l_ok bilinearXformPt(l_float32 *vc, l_int32 x, l_int32 y, l_float32 *pxp, l_float32 *pyp)
bilinearXformPt()
PIX * pixBilinearPta(PIX *pixs, PTA *ptad, PTA *ptas, l_int32 incolor)
pixBilinearPta()
PIX * pixBilinear(PIX *pixs, l_float32 *vc, l_int32 incolor)
pixBilinear()
l_ok bilinearXformSampledPt(l_float32 *vc, l_int32 x, l_int32 y, l_int32 *pxp, l_int32 *pyp)
bilinearXformSampledPt()
PIX * pixBilinearSampledPta(PIX *pixs, PTA *ptad, PTA *ptas, l_int32 incolor)
pixBilinearSampledPta()
PIX * pixBilinearPtaGray(PIX *pixs, PTA *ptad, PTA *ptas, l_uint8 grayval)
pixBilinearPtaGray()
PIX * pixBilinearPtaColor(PIX *pixs, PTA *ptad, PTA *ptas, l_uint32 colorval)
pixBilinearPtaColor()
PIX * pixBilinearGray(PIX *pixs, l_float32 *vc, l_uint8 grayval)
pixBilinearGray()
l_ok getBilinearXformCoeffs(PTA *ptas, PTA *ptad, l_float32 **pvc)
getBilinearXformCoeffs()
@ REMOVE_CMAP_BASED_ON_SRC