【发布时间】:2021-03-15 14:56:01
【问题描述】:
我正在使用 processing.py 并且我正在尝试加载像素艺术图像,但是当我尝试使图像变大时它变得模糊。我该如何避免这种情况?我正在使用 loadImage() 和 image() 函数,并且我将比照片的实际宽度和高度更高的宽度和高度放入 image() 函数中。
【问题讨论】:
标签: image processing
我正在使用 processing.py 并且我正在尝试加载像素艺术图像,但是当我尝试使图像变大时它变得模糊。我该如何避免这种情况?我正在使用 loadImage() 和 image() 函数,并且我将比照片的实际宽度和高度更高的宽度和高度放入 image() 函数中。
【问题讨论】:
标签: image processing
您可以通过在setup() 中调用noSmooth() 来禁用别名。
如果您使用P2D 或P3D,则需要将纹理采样设置为线性:g.textureSampling(2)
这是Processing > Examples > Image > LoadDisplayImage的修改版本:
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, 0, 0, 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,0)
image(img, 0, 0, width, height)
【讨论】: