问题描述
我正在使用 processing.py 并且我正在尝试加载像素艺术图像,但是当我尝试使图像变大时,它变得模糊。我如何避免这种情况?我正在使用 loadImage() 和 image() 函数,并将比照片实际宽度和高度更高的宽度和高度放入 image() 函数中。
解决方法
您可以通过在 setup()
中调用 noSmooth()
来禁用别名。
如果您使用 P2D
或 P3D
,则需要将纹理采样设置为线性:g.textureSampling(2)
这是处理>示例>图像>加载显示图像的修改版本:
def setup():
size(640,360)
global img
img = loadImage("moonwalk.jpg") # Load the image into the program
# make the image really small
img.resize(32,18)
noLoop()
# disable smoothing
noSmooth()
def draw():
# Displays the image scaled up at point (0,0)
image(img,width,height)
对于 OpenGL 渲染器(P2D、P3D)也是如此:
def setup():
size(640,360,P2D)
global img
img = loadImage("moonwalk.jpg") # Load the image into the program
# make the image really small
img.resize(32,18)
noLoop()
# disable smoothing
g.textureSampling(2)
def draw():
# Displays the image scaled up at point (0,height)