You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constint N = 64;
Bitmap texture(N, N);
for (int y = 0; y < N; ++y)
for (int x = 0; x < N; ++x) {
uint32_t color = (x + y) & 1 ? 0xff000000 : 0xffffffff;
texture.SetPixel(x, y, color);
}
constint W = 3072, H = 2048;
Bitmap output(W, H);
for (int y = 0; y < H; ++y)
for (int x = 0; x < W; ++x) {
float u = (x + 0.5f) / W, v = (y + 0.5f) / H;
output.SetPixel(x, y, texture.Sample2D(u, v));
}
output.SaveFile("output.bmp");
复现代码
放大一个checker texture并输出图片:
发现checker texture比预期的位置向左、上平移了一个网格,并在图片的右、下边沿导致拖影。
可能的原因和解决办法
Bitmap::SampleBilinear
方法接收的参数值为(x = u * _w + 0.5f, y = v * _h + 0.5f)
。0.5 <= x <= _w + 0.5, 0.5 <= y <= _h + 0.5
。x1 = floor(x), y1 = floor(y), x2 = ceil(x), y2 = ceil(y)
。如果减去一个像素的偏移,把
Bitmap::SampleBilinear
开头部分的代码修改为:发现上述问题不再出现。
The text was updated successfully, but these errors were encountered: