Scaling
Downscaling
Implementation
void deimos_apply_scaling(Image * img, int factorX, int factorY) {
int newWidth = img->width / factorX,
newHeight = img->height / factorY;
/* ... */
for (int i = 0; i < newHeight; i++) {
for (int j = 0; j < newWidth; j++) {
for (int c = 0; c < img->channels; c++) {
int original_x = j * factorX;
int original_y = i * factorY;
scaled_img->bytes[(i * newWidth + j) * img->channels + c] = img->bytes[(original_y * img->width + original_x) * img->channels + c];
}
}
}
/* ... */
}Result


Upscaling
Implementation
Result


Last updated