【问题标题】:How do I make a crisp pixel art image in processing?如何在处理中制作清晰的像素艺术图像?
【发布时间】:2021-03-15 14:56:01
【问题描述】:

我正在使用 processing.py 并且我正在尝试加载像素艺术图像,但是当我尝试使图像变大时它变得模糊。我该如何避免这种情况?我正在使用 loadImage() 和 image() 函数,并且我将比照片的实际宽度和高度更高的宽度和高度放入 image() 函数中。

【问题讨论】:

    标签: image processing


    【解决方案1】:

    您可以通过在setup() 中调用noSmooth() 来禁用别名。

    如果您使用P2DP3D,则需要将纹理采样设置为线性: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)
    

    【讨论】:

    • 非常感谢您的回答!那行得通。
    • 我勾选了复选框。我是堆栈溢出的新手,所以我没有足够的声誉来支持你,对不起。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-26
    • 1970-01-01
    • 1970-01-01
    • 2022-08-23
    • 1970-01-01
    相关资源
    最近更新 更多