source is always 320×240, dest is always 640×480.
void DoDoubleScaling(SDL_Surface* dest, SDL_Surface* source)
{
assert(dest->w == source->w*2);
assert(dest->h == source->h*2);
for (int y = 0; y < source->h; ++y)
{
for (int x = 0; x < source->w; ++x)
{
SetPixel(dest, x*2, y*2, GetPixel(source, x, y));
SetPixel(dest, x*2+1, y*2+1, GetPixel(source, x, y));
}
}
}
The output looks like this:
(be sure to view at full size). Essentially, every second pixel is missing. I’ve tried all sorts of possibilities and I can’t find where I’m going wrong.
GetPixeland SetPixel simply set/recieve a surface’s colour, given an X and Y [and color].
Use:
Instead of:
And for speed up: Store return value of GetPixel(source, x, y), so you don’t need to call it 4 times per each round.