use mode structs in Histo.c

This commit is contained in:
Yay295 2024-04-21 19:38:07 -05:00
parent b7c3c3e2b9
commit baa95d6f44

View File

@ -43,10 +43,10 @@ ImagingHistogramNew(Imaging im) {
if (!h) { if (!h) {
return (ImagingHistogram)ImagingError_MemoryError(); return (ImagingHistogram)ImagingError_MemoryError();
} }
strncpy(h->mode, im->mode, IMAGING_MODE_LENGTH - 1);
h->mode[IMAGING_MODE_LENGTH - 1] = 0;
h->mode = im->mode;
h->bands = im->bands; h->bands = im->bands;
h->histogram = calloc(im->pixelsize, 256 * sizeof(long)); h->histogram = calloc(im->pixelsize, 256 * sizeof(long));
if (!h->histogram) { if (!h->histogram) {
free(h); free(h);
@ -73,7 +73,7 @@ ImagingGetHistogram(Imaging im, Imaging imMask, void *minmax) {
if (im->xsize != imMask->xsize || im->ysize != imMask->ysize) { if (im->xsize != imMask->xsize || im->ysize != imMask->ysize) {
return ImagingError_Mismatch(); return ImagingError_Mismatch();
} }
if (strcmp(imMask->mode, "1") != 0 && strcmp(imMask->mode, "L") != 0) { if (imMask->mode != IMAGING_MODE_1 && imMask->mode != IMAGING_MODE_L) {
return ImagingError_ValueError("bad transparency mask"); return ImagingError_ValueError("bad transparency mask");
} }
} }