Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Scales an Image
- *
- * @pre image != NULL
- * @param image - the input image
- * @returns the scaled image
- * @param sW - the scale width factor
- * @param sH - the scale height factor
- */
- extern Image *scaleImage(Image *image, float sW, float sH);
- Image *scaleImage(Image *image, float sW, float sH)
- {
- Image *out = (Image*)malloc(sizeof(Image));
- if (!out) return NULL;
- out->imageWidth = image->imageWidth*sW;
- out->imageHeight = image->imageHeight*sH;
- out->textureWidth = getNextPower2(out->imageWidth);
- out->textureHeight = getNextPower2(out->imageHeight);
- out->data = (Color*) memalign(16, out->textureWidth * out->textureHeight * sizeof(Color));
- if (!image->data) {free(out); return NULL;}
- memset(out->data, 0, out->textureWidth * out->textureHeight * sizeof(Color));
- int x, y;
- for (y = 0; y < image->imageHeight; y++) {
- for (x = 0; x < image->imageWidth; x++) {
- out->data[(x*sW) + (y*sH) * out->textureWidth] |= image->data[x + y * image->textureWidth];
- }
- }
- return out;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement