如何在处理中制作清晰的像素艺术图像?
How do I make a crisp pixel art image in processing?
我正在使用 processing.py 并且我正在尝试加载像素艺术图像,但是当我尝试使图像变大时它变得模糊。我该如何避免这种情况?我正在使用 loadImage() 和 image() 函数,并且我将比照片的实际宽度和高度更高的宽度和高度放入 image() 函数中。
您可以通过在 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)
我正在使用 processing.py 并且我正在尝试加载像素艺术图像,但是当我尝试使图像变大时它变得模糊。我该如何避免这种情况?我正在使用 loadImage() 和 image() 函数,并且我将比照片的实际宽度和高度更高的宽度和高度放入 image() 函数中。
您可以通过在 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)