2
源始終爲320x240,dest始終爲640x480。嘗試SDL_Surface的雙倍大小失敗可怕
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));
}
}
}
輸出如下:(一定要查看完整大小)。本質上,每隔一個像素就會丟失。我嘗試了各種各樣的可能性,並且找不到我要去哪裏的錯誤。
GetPixel
and SetPixel
只需設置/接收表面的顏色,給定X和Y [和顏色]。
如果您將寬度和高度都加倍,則可以將面積乘以4來實現。因此,對於每個源像素,您需要編寫4個目標像素。 – pmg
哦,廢話。確實是的。解決了。抱歉。 – Dataflashsabot