113 #include <config_auto.h>
118 #include "allheaders.h"
120 extern l_float32 AlphaMaskBorderVals[2];
153 PROCNAME(
"pixBilinearSampledPta");
156 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
158 return (
PIX *)ERROR_PTR(
"ptas not defined", procName, NULL);
160 return (
PIX *)ERROR_PTR(
"ptad not defined", procName, NULL);
162 return (
PIX *)ERROR_PTR(
"invalid incolor", procName, NULL);
164 return (
PIX *)ERROR_PTR(
"ptas count not 4", procName, NULL);
166 return (
PIX *)ERROR_PTR(
"ptad count not 4", procName, NULL);
199 l_int32 i, j, w, h, d, x, y, wpls, wpld, color, cmapindex;
201 l_uint32 *datas, *datad, *lines, *lined;
205 PROCNAME(
"pixBilinearSampled");
208 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
210 return (
PIX *)ERROR_PTR(
"vc not defined", procName, NULL);
212 return (
PIX *)ERROR_PTR(
"invalid incolor", procName, NULL);
214 if (d != 1 && d != 2 && d != 4 && d != 8 && d != 32)
215 return (
PIX *)ERROR_PTR(
"depth not 1, 2, 4, 8 or 16", procName, NULL);
219 if ((cmap = pixGetColormap(pixs)) != NULL) {
237 wpls = pixGetWpl(pixs);
239 wpld = pixGetWpl(pixd);
240 for (i = 0; i < h; i++) {
241 lined = datad + i * wpld;
242 for (j = 0; j < w; j++) {
244 if (x < 0 || y < 0 || x >=w || y >= h)
246 lines = datas + y * wpls;
253 }
else if (d == 32) {
295 PIX *pixt1, *pixt2, *pixd;
297 PROCNAME(
"pixBilinearPta");
300 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
302 return (
PIX *)ERROR_PTR(
"ptas not defined", procName, NULL);
304 return (
PIX *)ERROR_PTR(
"ptad not defined", procName, NULL);
306 return (
PIX *)ERROR_PTR(
"invalid incolor", procName, NULL);
308 return (
PIX *)ERROR_PTR(
"ptas count not 4", procName, NULL);
310 return (
PIX *)ERROR_PTR(
"ptad count not 4", procName, NULL);
312 if (pixGetDepth(pixs) == 1)
317 d = pixGetDepth(pixt1);
322 d = pixGetDepth(pixt2);
330 colorval = 0xffffff00;
364 PIX *pixt1, *pixt2, *pixd;
366 PROCNAME(
"pixBilinear");
369 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
371 return (
PIX *)ERROR_PTR(
"vc not defined", procName, NULL);
373 if (pixGetDepth(pixs) == 1)
378 d = pixGetDepth(pixt1);
383 d = pixGetDepth(pixt2);
391 colorval = 0xffffff00;
422 PROCNAME(
"pixBilinearPtaColor");
425 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
427 return (
PIX *)ERROR_PTR(
"ptas not defined", procName, NULL);
429 return (
PIX *)ERROR_PTR(
"ptad not defined", procName, NULL);
430 if (pixGetDepth(pixs) != 32)
431 return (
PIX *)ERROR_PTR(
"pixs must be 32 bpp", procName, NULL);
433 return (
PIX *)ERROR_PTR(
"ptas count not 4", procName, NULL);
435 return (
PIX *)ERROR_PTR(
"ptad count not 4", procName, NULL);
459 l_int32 i, j, w, h, d, wpls, wpld;
461 l_uint32 *datas, *datad, *lined;
463 PIX *pix1, *pix2, *pixd;
465 PROCNAME(
"pixBilinearColor");
468 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
471 return (
PIX *)ERROR_PTR(
"pixs must be 32 bpp", procName, NULL);
473 return (
PIX *)ERROR_PTR(
"vc not defined", procName, NULL);
476 wpls = pixGetWpl(pixs);
480 wpld = pixGetWpl(pixd);
483 for (i = 0; i < h; i++) {
484 lined = datad + i * wpld;
485 for (j = 0; j < w; j++) {
495 if (pixGetSpp(pixs) == 4) {
525 PROCNAME(
"pixBilinearPtaGray");
528 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
530 return (
PIX *)ERROR_PTR(
"ptas not defined", procName, NULL);
532 return (
PIX *)ERROR_PTR(
"ptad not defined", procName, NULL);
533 if (pixGetDepth(pixs) != 8)
534 return (
PIX *)ERROR_PTR(
"pixs must be 8 bpp", procName, NULL);
536 return (
PIX *)ERROR_PTR(
"ptas count not 4", procName, NULL);
538 return (
PIX *)ERROR_PTR(
"ptad count not 4", procName, NULL);
562 l_int32 i, j, w, h, wpls, wpld, val;
563 l_uint32 *datas, *datad, *lined;
567 PROCNAME(
"pixBilinearGray");
570 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
572 if (pixGetDepth(pixs) != 8)
573 return (
PIX *)ERROR_PTR(
"pixs must be 8 bpp", procName, NULL);
575 return (
PIX *)ERROR_PTR(
"vc not defined", procName, NULL);
578 wpls = pixGetWpl(pixs);
582 wpld = pixGetWpl(pixd);
585 for (i = 0; i < h; i++) {
586 lined = datad + i * wpld;
587 for (j = 0; j < w; j++) {
654 PIX *pixd, *pixb1, *pixb2, *pixg2, *pixga;
657 PROCNAME(
"pixBilinearPtaWithAlpha");
660 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
662 if (d != 32 && pixGetColormap(pixs) == NULL)
663 return (
PIX *)ERROR_PTR(
"pixs not cmapped or 32 bpp", procName, NULL);
664 if (pixg && pixGetDepth(pixg) != 8) {
665 L_WARNING(
"pixg not 8 bpp; using 'fract' transparent alpha\n",
669 if (!pixg && (fract < 0.0 || fract > 1.0)) {
670 L_WARNING(
"invalid fract; using 1.0 (fully transparent)\n", procName);
673 if (!pixg && fract == 0.0)
674 L_WARNING(
"fully opaque alpha; image cannot be blended\n", procName);
676 return (
PIX *)ERROR_PTR(
"ptad not defined", procName, NULL);
678 return (
PIX *)ERROR_PTR(
"ptas not defined", procName, NULL);
698 if (ws > 10 && hs > 10) {
700 (l_int32)(255.0 * fract * AlphaMaskBorderVals[0]));
702 (l_int32)(255.0 * fract * AlphaMaskBorderVals[1]));
783 l_float32 x1, y1, x2, y2, x3, y3, x4, y4;
787 PROCNAME(
"getBilinearXformCoeffs");
790 return ERROR_INT(
"ptas not defined", procName, 1);
792 return ERROR_INT(
"ptad not defined", procName, 1);
794 return ERROR_INT(
"&vc not defined", procName, 1);
796 b = (l_float32 *)LEPT_CALLOC(8,
sizeof(l_float32));
807 for (i = 0; i < 8; i++)
808 a[i] = (l_float32 *)LEPT_CALLOC(8,
sizeof(l_float32));
844 for (i = 0; i < 8; i++)
872 PROCNAME(
"bilinearXformSampledPt");
875 return ERROR_INT(
"vc not defined", procName, 1);
877 *pxp = (l_int32)(vc[0] * x + vc[1] * y + vc[2] * x * y + vc[3] + 0.5);
878 *pyp = (l_int32)(vc[4] * x + vc[5] * y + vc[6] * x * y + vc[7] + 0.5);
904 PROCNAME(
"bilinearXformPt");
907 return ERROR_INT(
"vc not defined", procName, 1);
909 *pxp = vc[0] * x + vc[1] * y + vc[2] * x * y + vc[3];
910 *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 * 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 * pixBilinear(PIX *pixs, l_float32 *vc, l_int32 incolor)
pixBilinear()
PIX * pixBilinearSampledPta(PIX *pixs, PTA *ptad, PTA *ptas, l_int32 incolor)
pixBilinearSampledPta()
PIX * pixBilinearPtaWithAlpha(PIX *pixs, PTA *ptad, PTA *ptas, PIX *pixg, l_float32 fract, l_int32 border)
pixBilinearPtaWithAlpha()
PIX * pixBilinearPtaGray(PIX *pixs, PTA *ptad, PTA *ptas, l_uint8 grayval)
pixBilinearPtaGray()
l_ok bilinearXformSampledPt(l_float32 *vc, l_int32 x, l_int32 y, l_int32 *pxp, l_int32 *pyp)
bilinearXformSampledPt()
PIX * pixBilinearGray(PIX *pixs, l_float32 *vc, l_uint8 grayval)
pixBilinearGray()
PIX * pixBilinearPta(PIX *pixs, PTA *ptad, PTA *ptas, l_int32 incolor)
pixBilinearPta()
PIX * pixBilinearColor(PIX *pixs, l_float32 *vc, l_uint32 colorval)
pixBilinearColor()
PIX * pixBilinearPtaColor(PIX *pixs, PTA *ptad, PTA *ptas, l_uint32 colorval)
pixBilinearPtaColor()
l_ok getBilinearXformCoeffs(PTA *ptas, PTA *ptad, l_float32 **pvc)
getBilinearXformCoeffs()
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()
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()