Merge pull request #2737 from uploadcare/imaging-copy-palette-info

Rename ImagingCopyInfo to ImagingCopyPalette
This commit is contained in:
Alexander Karpinsky 2017-09-19 21:43:37 +03:00 committed by GitHub
commit e11b47858c
13 changed files with 27 additions and 30 deletions

View File

@ -47,8 +47,6 @@ ImagingAlphaComposite(Imaging imDst, Imaging imSrc)
if (!imOut) if (!imOut)
return NULL; return NULL;
ImagingCopyInfo(imOut, imDst);
for (y = 0; y < imDst->ysize; y++) { for (y = 0; y < imDst->ysize; y++) {
rgba8* dst = (rgba8*) imDst->image[y]; rgba8* dst = (rgba8*) imDst->image[y];
rgba8* src = (rgba8*) imSrc->image[y]; rgba8* src = (rgba8*) imSrc->image[y];

View File

@ -26,8 +26,11 @@ ImagingBlend(Imaging imIn1, Imaging imIn2, float alpha)
int x, y; int x, y;
/* Check arguments */ /* Check arguments */
if (!imIn1 || !imIn2 || imIn1->type != IMAGING_TYPE_UINT8) if (!imIn1 || !imIn2 || imIn1->type != IMAGING_TYPE_UINT8
return ImagingError_ModeError(); || imIn1->palette || strcmp(imIn1->mode, "1") == 0
|| imIn2->palette || strcmp(imIn2->mode, "1") == 0)
return ImagingError_ModeError();
if (imIn1->type != imIn2->type || if (imIn1->type != imIn2->type ||
imIn1->bands != imIn2->bands || imIn1->bands != imIn2->bands ||
imIn1->xsize != imIn2->xsize || imIn1->xsize != imIn2->xsize ||
@ -44,8 +47,6 @@ ImagingBlend(Imaging imIn1, Imaging imIn2, float alpha)
if (!imOut) if (!imOut)
return NULL; return NULL;
ImagingCopyInfo(imOut, imIn1);
if (alpha >= 0 && alpha <= 1.0) { if (alpha >= 0 && alpha <= 1.0) {
/* Interpolate between bands */ /* Interpolate between bands */
for (y = 0; y < imIn1->ysize; y++) { for (y = 0; y < imIn1->ysize; y++) {

View File

@ -32,7 +32,7 @@ _copy(Imaging imOut, Imaging imIn)
if (!imOut) if (!imOut)
return NULL; return NULL;
ImagingCopyInfo(imOut, imIn); ImagingCopyPalette(imOut, imIn);
ImagingSectionEnter(&cookie); ImagingSectionEnter(&cookie);
if (imIn->block != NULL && imOut->block != NULL) if (imIn->block != NULL && imOut->block != NULL)

View File

@ -41,7 +41,7 @@ ImagingCrop(Imaging imIn, int sx0, int sy0, int sx1, int sy1)
if (!imOut) if (!imOut)
return NULL; return NULL;
ImagingCopyInfo(imOut, imIn); ImagingCopyPalette(imOut, imIn);
if (sx0 < 0 || sy0 < 0 || sx1 > imIn->xsize || sy1 > imIn->ysize) if (sx0 < 0 || sy0 < 0 || sx1 > imIn->xsize || sy1 > imIn->ysize)
(void) ImagingFill(imOut, &zero); (void) ImagingFill(imOut, &zero);

View File

@ -144,7 +144,7 @@ ImagingEffectSpread(Imaging imIn, int distance)
SPREAD(INT32, image32); SPREAD(INT32, image32);
} }
ImagingCopyInfo(imOut, imIn); ImagingCopyPalette(imOut, imIn);
return imOut; return imOut;
} }

View File

@ -78,7 +78,7 @@ ImagingExpand(Imaging imIn, int xmargin, int ymargin, int mode)
} }
ImagingSectionLeave(&cookie); ImagingSectionLeave(&cookie);
ImagingCopyInfo(imOut, imIn); ImagingCopyPalette(imOut, imIn);
return imOut; return imOut;
} }

View File

@ -25,7 +25,7 @@ ImagingFlipLeftRight(Imaging imOut, Imaging imIn)
if (imIn->xsize != imOut->xsize || imIn->ysize != imOut->ysize) if (imIn->xsize != imOut->xsize || imIn->ysize != imOut->ysize)
return (Imaging) ImagingError_Mismatch(); return (Imaging) ImagingError_Mismatch();
ImagingCopyInfo(imOut, imIn); ImagingCopyPalette(imOut, imIn);
#define FLIP_LEFT_RIGHT(INT, image) \ #define FLIP_LEFT_RIGHT(INT, image) \
for (y = 0; y < imIn->ysize; y++) { \ for (y = 0; y < imIn->ysize; y++) { \
@ -63,7 +63,7 @@ ImagingFlipTopBottom(Imaging imOut, Imaging imIn)
if (imIn->xsize != imOut->xsize || imIn->ysize != imOut->ysize) if (imIn->xsize != imOut->xsize || imIn->ysize != imOut->ysize)
return (Imaging) ImagingError_Mismatch(); return (Imaging) ImagingError_Mismatch();
ImagingCopyInfo(imOut, imIn); ImagingCopyPalette(imOut, imIn);
ImagingSectionEnter(&cookie); ImagingSectionEnter(&cookie);
@ -89,7 +89,7 @@ ImagingRotate90(Imaging imOut, Imaging imIn)
if (imIn->xsize != imOut->ysize || imIn->ysize != imOut->xsize) if (imIn->xsize != imOut->ysize || imIn->ysize != imOut->xsize)
return (Imaging) ImagingError_Mismatch(); return (Imaging) ImagingError_Mismatch();
ImagingCopyInfo(imOut, imIn); ImagingCopyPalette(imOut, imIn);
#define ROTATE_90(INT, image) \ #define ROTATE_90(INT, image) \
for (y = 0; y < imIn->ysize; y += ROTATE_CHUNK) { \ for (y = 0; y < imIn->ysize; y += ROTATE_CHUNK) { \
@ -139,7 +139,7 @@ ImagingTranspose(Imaging imOut, Imaging imIn)
if (imIn->xsize != imOut->ysize || imIn->ysize != imOut->xsize) if (imIn->xsize != imOut->ysize || imIn->ysize != imOut->xsize)
return (Imaging) ImagingError_Mismatch(); return (Imaging) ImagingError_Mismatch();
ImagingCopyInfo(imOut, imIn); ImagingCopyPalette(imOut, imIn);
#define TRANSPOSE(INT, image) \ #define TRANSPOSE(INT, image) \
for (y = 0; y < imIn->ysize; y += ROTATE_CHUNK) { \ for (y = 0; y < imIn->ysize; y += ROTATE_CHUNK) { \
@ -188,7 +188,7 @@ ImagingTransverse(Imaging imOut, Imaging imIn)
if (imIn->xsize != imOut->ysize || imIn->ysize != imOut->xsize) if (imIn->xsize != imOut->ysize || imIn->ysize != imOut->xsize)
return (Imaging) ImagingError_Mismatch(); return (Imaging) ImagingError_Mismatch();
ImagingCopyInfo(imOut, imIn); ImagingCopyPalette(imOut, imIn);
#define TRANSVERSE(INT, image) \ #define TRANSVERSE(INT, image) \
for (y = 0; y < imIn->ysize; y += ROTATE_CHUNK) { \ for (y = 0; y < imIn->ysize; y += ROTATE_CHUNK) { \
@ -238,7 +238,7 @@ ImagingRotate180(Imaging imOut, Imaging imIn)
if (imIn->xsize != imOut->xsize || imIn->ysize != imOut->ysize) if (imIn->xsize != imOut->xsize || imIn->ysize != imOut->ysize)
return (Imaging) ImagingError_Mismatch(); return (Imaging) ImagingError_Mismatch();
ImagingCopyInfo(imOut, imIn); ImagingCopyPalette(imOut, imIn);
#define ROTATE_180(INT, image) \ #define ROTATE_180(INT, image) \
for (y = 0; y < imIn->ysize; y++, yr--) { \ for (y = 0; y < imIn->ysize; y++, yr--) { \
@ -278,7 +278,7 @@ ImagingRotate270(Imaging imOut, Imaging imIn)
if (imIn->xsize != imOut->ysize || imIn->ysize != imOut->xsize) if (imIn->xsize != imOut->ysize || imIn->ysize != imOut->xsize)
return (Imaging) ImagingError_Mismatch(); return (Imaging) ImagingError_Mismatch();
ImagingCopyInfo(imOut, imIn); ImagingCopyPalette(imOut, imIn);
#define ROTATE_270(INT, image) \ #define ROTATE_270(INT, image) \
for (y = 0; y < imIn->ysize; y += ROTATE_CHUNK) { \ for (y = 0; y < imIn->ysize; y += ROTATE_CHUNK) { \
@ -717,7 +717,7 @@ ImagingGenericTransform(
if (!imOut || !imIn || strcmp(imIn->mode, imOut->mode) != 0) if (!imOut || !imIn || strcmp(imIn->mode, imOut->mode) != 0)
return (Imaging) ImagingError_ModeError(); return (Imaging) ImagingError_ModeError();
ImagingCopyInfo(imOut, imIn); ImagingCopyPalette(imOut, imIn);
ImagingSectionEnter(&cookie); ImagingSectionEnter(&cookie);
@ -764,7 +764,7 @@ ImagingScaleAffine(Imaging imOut, Imaging imIn,
if (!imOut || !imIn || strcmp(imIn->mode, imOut->mode) != 0) if (!imOut || !imIn || strcmp(imIn->mode, imOut->mode) != 0)
return (Imaging) ImagingError_ModeError(); return (Imaging) ImagingError_ModeError();
ImagingCopyInfo(imOut, imIn); ImagingCopyPalette(imOut, imIn);
if (x0 < 0) if (x0 < 0)
x0 = 0; x0 = 0;
@ -854,7 +854,7 @@ affine_fixed(Imaging imOut, Imaging imIn,
int xx, yy; int xx, yy;
int a0, a1, a2, a3, a4, a5; int a0, a1, a2, a3, a4, a5;
ImagingCopyInfo(imOut, imIn); ImagingCopyPalette(imOut, imIn);
xsize = (int) imIn->xsize; xsize = (int) imIn->xsize;
ysize = (int) imIn->ysize; ysize = (int) imIn->ysize;
@ -956,7 +956,7 @@ ImagingTransformAffine(Imaging imOut, Imaging imIn,
following code is used. maybe we should fall back on the slow following code is used. maybe we should fall back on the slow
generic transform engine in this case? */ generic transform engine in this case? */
ImagingCopyInfo(imOut, imIn); ImagingCopyPalette(imOut, imIn);
xsize = (int) imIn->xsize; xsize = (int) imIn->xsize;
ysize = (int) imIn->ysize; ysize = (int) imIn->ysize;

View File

@ -173,7 +173,7 @@ extern Imaging ImagingNewPrologueSubtype(const char *mode,
int xsize, int ysize, int xsize, int ysize,
int structure_size); int structure_size);
extern void ImagingCopyInfo(Imaging destination, Imaging source); extern void ImagingCopyPalette(Imaging destination, Imaging source);
extern void ImagingHistogramDelete(ImagingHistogram histogram); extern void ImagingHistogramDelete(ImagingHistogram histogram);

View File

@ -72,7 +72,7 @@ ImagingModeFilter(Imaging im, int size)
} }
ImagingCopyInfo(imOut, im); ImagingCopyPalette(imOut, im);
return imOut; return imOut;
} }

View File

@ -31,7 +31,7 @@ ImagingOffset(Imaging im, int xoffset, int yoffset)
if (!imOut) if (!imOut)
return NULL; return NULL;
ImagingCopyInfo(imOut, im); ImagingCopyPalette(imOut, im);
/* make offsets positive to avoid negative coordinates */ /* make offsets positive to avoid negative coordinates */
xoffset %= im->xsize; xoffset %= im->xsize;

View File

@ -180,7 +180,7 @@ ImagingPoint(Imaging imIn, const char* mode, const void* table)
} else } else
point = im_point_32_8; point = im_point_32_8;
ImagingCopyInfo(imOut, imIn); ImagingCopyPalette(imOut, imIn);
ImagingSectionEnter(&cookie); ImagingSectionEnter(&cookie);
@ -216,8 +216,6 @@ ImagingPointTransform(Imaging imIn, double scale, double offset)
if (!imOut) if (!imOut)
return NULL; return NULL;
ImagingCopyInfo(imOut, imIn);
switch (imIn->type) { switch (imIn->type) {
case IMAGING_TYPE_INT32: case IMAGING_TYPE_INT32:
ImagingSectionEnter(&cookie); ImagingSectionEnter(&cookie);

View File

@ -103,7 +103,7 @@ ImagingRankFilter(Imaging im, int size, int rank)
return (Imaging) ImagingError_ModeError(); return (Imaging) ImagingError_ModeError();
} }
ImagingCopyInfo(imOut, im); ImagingCopyPalette(imOut, im);
return imOut; return imOut;

View File

@ -24,7 +24,7 @@
* 1998-10-26 fl Added "I;16" and "I;16B" storage modes (experimental) * 1998-10-26 fl Added "I;16" and "I;16B" storage modes (experimental)
* 1998-12-29 fl Fixed allocation bug caused by previous fix * 1998-12-29 fl Fixed allocation bug caused by previous fix
* 1999-02-03 fl Added "RGBa" and "BGR" modes (experimental) * 1999-02-03 fl Added "RGBa" and "BGR" modes (experimental)
* 2001-04-22 fl Fixed potential memory leak in ImagingCopyInfo * 2001-04-22 fl Fixed potential memory leak in ImagingCopyPalette
* 2003-09-26 fl Added "LA" and "PA" modes (experimental) * 2003-09-26 fl Added "LA" and "PA" modes (experimental)
* 2005-10-02 fl Added image counter * 2005-10-02 fl Added image counter
* *
@ -458,7 +458,7 @@ ImagingNew2Dirty(const char* mode, Imaging imOut, Imaging imIn)
} }
void void
ImagingCopyInfo(Imaging destination, Imaging source) ImagingCopyPalette(Imaging destination, Imaging source)
{ {
if (source->palette) { if (source->palette) {
if (destination->palette) if (destination->palette)