/*
* This file is part of the Atomiks project.
* Copyright (C) Mateusz Viste 2013
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <SDL/SDL.h>
/* this requires a destination surface already setup to be twice as large as the source. And formats must match too. this will just blindly assume you didn't flounder. */
void scale2x(SDL_Surface *src, SDL_Surface *dst) {
int x, y, z, xx, yy, scale = 2;
uint8_t *srcpix = src->pixels;
uint8_t *dstpix = dst->pixels;
for (y = 0; y < src->h; y++) {
for (x = 0; x < src->w; x++) {
for (z = 0; z < src->format->BytesPerPixel; z++) {
for (yy = y * scale; yy < (y + 1) * scale; yy++) {
for (xx = x * scale; xx < (x + 1) * scale; xx++) {
dstpix[(yy * dst->pitch) + z + (xx * src->format->BytesPerPixel)] = srcpix[(y * src->pitch) + z + (x * src->format->BytesPerPixel)];
}
}
}
}
}
return;
}