115 #include "allheaders.h" 117 extern l_float32 AlphaMaskBorderVals[2];
151 PROCNAME(
"pixBilinearSampledPta");
154 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
156 return (
PIX *)ERROR_PTR(
"ptas not defined", procName, NULL);
158 return (
PIX *)ERROR_PTR(
"ptad not defined", procName, NULL);
160 return (
PIX *)ERROR_PTR(
"invalid incolor", procName, NULL);
162 return (
PIX *)ERROR_PTR(
"ptas count not 4", procName, NULL);
164 return (
PIX *)ERROR_PTR(
"ptad count not 4", procName, NULL);
197 l_int32 i, j, w, h, d, x, y, wpls, wpld, color, cmapindex;
199 l_uint32 *datas, *datad, *lines, *lined;
203 PROCNAME(
"pixBilinearSampled");
206 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
208 return (
PIX *)ERROR_PTR(
"vc not defined", procName, NULL);
210 return (
PIX *)ERROR_PTR(
"invalid incolor", procName, NULL);
212 if (d != 1 && d != 2 && d != 4 && d != 8 && d != 32)
213 return (
PIX *)ERROR_PTR(
"depth not 1, 2, 4, 8 or 16", procName, NULL);
217 if ((cmap = pixGetColormap(
pixs)) != NULL) {
235 wpls = pixGetWpl(
pixs);
237 wpld = pixGetWpl(pixd);
238 for (i = 0; i < h; i++) {
239 lined = datad + i * wpld;
240 for (j = 0; j < w; j++) {
242 if (x < 0 || y < 0 || x >=w || y >= h)
244 lines = datas + y * wpls;
251 }
else if (d == 32) {
293 PIX *pixt1, *pixt2, *pixd;
295 PROCNAME(
"pixBilinearPta");
298 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
300 return (
PIX *)ERROR_PTR(
"ptas not defined", procName, NULL);
302 return (
PIX *)ERROR_PTR(
"ptad not defined", procName, NULL);
304 return (
PIX *)ERROR_PTR(
"invalid incolor", procName, NULL);
306 return (
PIX *)ERROR_PTR(
"ptas count not 4", procName, NULL);
308 return (
PIX *)ERROR_PTR(
"ptad count not 4", procName, NULL);
310 if (pixGetDepth(
pixs) == 1)
315 d = pixGetDepth(pixt1);
320 d = pixGetDepth(pixt2);
328 colorval = 0xffffff00;
362 PIX *pixt1, *pixt2, *pixd;
364 PROCNAME(
"pixBilinear");
367 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
369 return (
PIX *)ERROR_PTR(
"vc not defined", procName, NULL);
371 if (pixGetDepth(
pixs) == 1)
376 d = pixGetDepth(pixt1);
381 d = pixGetDepth(pixt2);
389 colorval = 0xffffff00;
420 PROCNAME(
"pixBilinearPtaColor");
423 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
425 return (
PIX *)ERROR_PTR(
"ptas not defined", procName, NULL);
427 return (
PIX *)ERROR_PTR(
"ptad not defined", procName, NULL);
428 if (pixGetDepth(
pixs) != 32)
429 return (
PIX *)ERROR_PTR(
"pixs must be 32 bpp", procName, NULL);
431 return (
PIX *)ERROR_PTR(
"ptas count not 4", procName, NULL);
433 return (
PIX *)ERROR_PTR(
"ptad count not 4", procName, NULL);
457 l_int32 i, j, w, h, d, wpls, wpld;
459 l_uint32 *datas, *datad, *lined;
461 PIX *pix1, *pix2, *pixd;
463 PROCNAME(
"pixBilinearColor");
466 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
469 return (
PIX *)ERROR_PTR(
"pixs must be 32 bpp", procName, NULL);
471 return (
PIX *)ERROR_PTR(
"vc not defined", procName, NULL);
474 wpls = pixGetWpl(
pixs);
478 wpld = pixGetWpl(pixd);
481 for (i = 0; i < h; i++) {
482 lined = datad + i * wpld;
483 for (j = 0; j < w; j++) {
493 if (pixGetSpp(
pixs) == 4) {
523 PROCNAME(
"pixBilinearPtaGray");
526 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
528 return (
PIX *)ERROR_PTR(
"ptas not defined", procName, NULL);
530 return (
PIX *)ERROR_PTR(
"ptad not defined", procName, NULL);
531 if (pixGetDepth(
pixs) != 8)
532 return (
PIX *)ERROR_PTR(
"pixs must be 8 bpp", procName, NULL);
534 return (
PIX *)ERROR_PTR(
"ptas count not 4", procName, NULL);
536 return (
PIX *)ERROR_PTR(
"ptad count not 4", procName, NULL);
560 l_int32 i, j, w, h, wpls, wpld, val;
561 l_uint32 *datas, *datad, *lined;
565 PROCNAME(
"pixBilinearGray");
568 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
570 if (pixGetDepth(
pixs) != 8)
571 return (
PIX *)ERROR_PTR(
"pixs must be 8 bpp", procName, NULL);
573 return (
PIX *)ERROR_PTR(
"vc not defined", procName, NULL);
576 wpls = pixGetWpl(
pixs);
580 wpld = pixGetWpl(pixd);
583 for (i = 0; i < h; i++) {
584 lined = datad + i * wpld;
585 for (j = 0; j < w; j++) {
652 PIX *pixd, *pixb1, *pixb2, *pixg2, *pixga;
655 PROCNAME(
"pixBilinearPtaWithAlpha");
658 return (
PIX *)ERROR_PTR(
"pixs not defined", procName, NULL);
660 if (d != 32 && pixGetColormap(
pixs) == NULL)
661 return (
PIX *)ERROR_PTR(
"pixs not cmapped or 32 bpp", procName, NULL);
662 if (pixg && pixGetDepth(pixg) != 8) {
663 L_WARNING(
"pixg not 8 bpp; using 'fract' transparent alpha\n",
667 if (!pixg && (fract < 0.0 || fract > 1.0)) {
668 L_WARNING(
"invalid fract; using 1.0 (fully transparent)\n", procName);
671 if (!pixg && fract == 0.0)
672 L_WARNING(
"fully opaque alpha; image cannot be blended\n", procName);
674 return (
PIX *)ERROR_PTR(
"ptad not defined", procName, NULL);
676 return (
PIX *)ERROR_PTR(
"ptas not defined", procName, NULL);
696 if (ws > 10 && hs > 10) {
698 (l_int32)(255.0 * fract * AlphaMaskBorderVals[0]));
700 (l_int32)(255.0 * fract * AlphaMaskBorderVals[1]));
781 l_float32 x1, y1, x2, y2, x3, y3, x4, y4;
785 PROCNAME(
"getBilinearXformCoeffs");
788 return ERROR_INT(
"ptas not defined", procName, 1);
790 return ERROR_INT(
"ptad not defined", procName, 1);
792 return ERROR_INT(
"&vc not defined", procName, 1);
794 if ((b = (l_float32 *)LEPT_CALLOC(8,
sizeof(l_float32))) == NULL)
795 return ERROR_INT(
"b not made", procName, 1);
807 for (i = 0; i < 8; i++) {
808 if ((a[i] = (l_float32 *)LEPT_CALLOC(8,
sizeof(l_float32))) == NULL)
809 return ERROR_INT(
"a[i] not made", procName, 1);
847 for (i = 0; i < 8; i++)
876 PROCNAME(
"bilinearXformSampledPt");
879 return ERROR_INT(
"vc not defined", procName, 1);
881 *pxp = (l_int32)(vc[0] * x + vc[1] * y + vc[2] * x * y + vc[3] + 0.5);
882 *pyp = (l_int32)(vc[4] * x + vc[5] * y + vc[6] * x * y + vc[7] + 0.5);
908 PROCNAME(
"bilinearXformPt");
911 return ERROR_INT(
"vc not defined", procName, 1);
913 *pxp = vc[0] * x + vc[1] * y + vc[2] * x * y + vc[3];
914 *pyp = vc[4] * x + vc[5] * y + vc[6] * x * y + vc[7];
l_int32 gaussjordan(l_float32 **a, l_float32 *b, l_int32 n)
gaussjordan()
PIX * pixRemoveColormap(PIX *pixs, l_int32 type)
pixRemoveColormap()
PIX * pixBilinearColor(PIX *pixs, l_float32 *vc, l_uint32 colorval)
pixBilinearColor()
l_ok pixSetRGBComponent(PIX *pixd, PIX *pixs, l_int32 comp)
pixSetRGBComponent()
PIX * pixBilinearPta(PIX *pixs, PTA *ptad, PTA *ptas, l_int32 incolor)
pixBilinearPta()
PIX * pixConvertTo8(PIX *pixs, l_int32 cmapflag)
pixConvertTo8()
PIX * pixCreate(l_int32 width, l_int32 height, l_int32 depth)
pixCreate()
l_ok pixSetAll(PIX *pix)
pixSetAll()
#define SET_DATA_QBIT(pdata, n, val)
l_int32 ptaGetCount(PTA *pta)
ptaGetCount()
l_uint32 * pixGetData(PIX *pix)
pixGetData()
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_BIT(pdata, n)
PIX * pixCreateTemplate(PIX *pixs)
pixCreateTemplate()
PIX * pixGetRGBComponent(PIX *pixs, l_int32 comp)
pixGetRGBComponent()
PIX * pixAddBorder(PIX *pixs, l_int32 npix, l_uint32 val)
pixAddBorder()
#define SET_DATA_DIBIT(pdata, n, val)
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_ok pixSetAllArbitrary(PIX *pix, l_uint32 val)
pixSetAllArbitrary()
PIX * pixBilinearPtaGray(PIX *pixs, PTA *ptad, PTA *ptas, l_uint8 grayval)
pixBilinearPtaGray()
PIX * pixBilinear(PIX *pixs, l_float32 *vc, l_int32 incolor)
pixBilinear()
PIX * pixBilinearPtaWithAlpha(PIX *pixs, PTA *ptad, PTA *ptas, PIX *pixg, l_float32 fract, l_int32 border)
pixBilinearPtaWithAlpha()
l_ok pixClearAll(PIX *pix)
pixClearAll()
l_ok pixSetBorderRingVal(PIX *pixs, l_int32 dist, l_uint32 val)
pixSetBorderRingVal()
l_ok ptaGetPt(PTA *pta, l_int32 index, l_float32 *px, l_float32 *py)
ptaGetPt()
#define SET_DATA_BYTE(pdata, n, val)
#define GET_DATA_QBIT(pdata, n)
#define GET_DATA_BYTE(pdata, n)
#define SET_DATA_BIT_VAL(pdata, n, val)
PIX * pixClone(PIX *pixs)
pixClone()
l_ok getBilinearXformCoeffs(PTA *ptas, PTA *ptad, l_float32 **pvc)
getBilinearXformCoeffs()
void pixDestroy(PIX **ppix)
pixDestroy()
PIX * pixBilinearSampled(PIX *pixs, l_float32 *vc, l_int32 incolor)
pixBilinearSampled()
l_ok pixGetDimensions(const PIX *pix, l_int32 *pw, l_int32 *ph, l_int32 *pd)
pixGetDimensions()
PIX * pixBilinearPtaColor(PIX *pixs, PTA *ptad, PTA *ptas, l_uint32 colorval)
pixBilinearPtaColor()
l_ok pixcmapAddBlackOrWhite(PIXCMAP *cmap, l_int32 color, l_int32 *pindex)
pixcmapAddBlackOrWhite()
#define GET_DATA_DIBIT(pdata, n)
l_ok bilinearXformPt(l_float32 *vc, l_int32 x, l_int32 y, l_float32 *pxp, l_float32 *pyp)
bilinearXformPt()
void ptaDestroy(PTA **ppta)
ptaDestroy()
PIX * pixBilinearSampledPta(PIX *pixs, PTA *ptad, PTA *ptas, l_int32 incolor)
pixBilinearSampledPta()
PIX * pixResizeToMatch(PIX *pixs, PIX *pixt, l_int32 w, l_int32 h)
pixResizeToMatch()
PTA * ptaTransform(PTA *ptas, l_int32 shiftx, l_int32 shifty, l_float32 scalex, l_float32 scaley)
ptaTransform()
PIX * pixBilinearGray(PIX *pixs, l_float32 *vc, l_uint8 grayval)
pixBilinearGray()
l_ok bilinearXformSampledPt(l_float32 *vc, l_int32 x, l_int32 y, l_int32 *pxp, l_int32 *pyp)
bilinearXformSampledPt()