Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: imaging.c
- ===================================================================
- --- imaging.c (revision 172)
- +++ imaging.c (working copy)
- @@ -17,6 +17,7 @@
- /* Include the interface definition */
- #include "imaging.h"
- +#define ARRAY_SIZE (sizeof(ARRAY_BASE_TYPE) * MAX_ARRAY_SIZE)
- /** Maximum number of pixel in img.pixels */
- #define MAX_PIXEL_COUNT ((MAX_ARRAY_SIZE*ARRAY_ELEMENT_SIZE) / BITS_PER_COLOR)
- @@ -25,7 +26,7 @@
- #define CHANNELMASK ((1 << COLORDEPTH) - 1)
- /** A Mask where every Bit belonging to a color is set */
- -#define COLORMASK ((1 << BITS_PER_COLOR) - 1)
- +#define COLORMASK ((Color) ((1 << BITS_PER_COLOR) - 1))
- /* as given by Hanno */
- #define MAX_INTENSITY 255
- @@ -155,9 +156,15 @@
- assert(x < imaging_getWidth(img));
- assert(y < imaging_getHeight(img));
- {
- + Color tempColor = 0;
- div_t divRes = div(getColorOffsetInBit(imaging_getWidth(img),x,y),
- BYTE_SIZE);
- - Color tempColor = * (Color *) ((unsigned char *)img.pixels + divRes.quot);
- + int offset = sizeof(Color) + divRes.quot - ARRAY_SIZE;
- + if (offset >= 0) {
- + divRes.quot -= offset;
- + divRes.rem += offset * 8;
- + }
- + tempColor = * (Color *) ((unsigned char *)img.pixels + divRes.quot);
- return (tempColor >> divRes.rem) & COLORMASK;
- }
- @@ -177,12 +184,16 @@
- assert(img != NULL);
- assert(x < imaging_getWidth(*img));
- assert(y < imaging_getHeight(*img));
- -
- {
- + Color * pos = NULL;
- div_t divRes = div(getColorOffsetInBit(imaging_getWidth(*img),x,y),
- BYTE_SIZE);
- - Color * pos = (Color *) ((unsigned char *)img->pixels + divRes.quot);
- -
- + int offset = sizeof(Color) + divRes.quot - ARRAY_SIZE;
- + if (offset >= 0) {
- + divRes.quot -= offset;
- + divRes.rem += offset * 8;
- + }
- + pos = (Color *) ((unsigned char *)img->pixels + divRes.quot);
- *pos &= ~(COLORMASK << divRes.rem);
- *pos |= color << divRes.rem;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement