当前位置: 首页>>代码示例>>Python>>正文


Python Picture.setPixelColor方法代码示例

本文整理汇总了Python中picture.Picture.setPixelColor方法的典型用法代码示例。如果您正苦于以下问题:Python Picture.setPixelColor方法的具体用法?Python Picture.setPixelColor怎么用?Python Picture.setPixelColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在picture.Picture的用法示例。


在下文中一共展示了Picture.setPixelColor方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: flipHoriz

# 需要导入模块: from picture import Picture [as 别名]
# 或者: from picture.Picture import setPixelColor [as 别名]
def flipHoriz(canvas):
    n = Picture((canvas.getWidth(),canvas.getHeight()))
    for x in range(canvas.getWidth()):
        for y in range(canvas.getHeight()):
            r, g, b = canvas.getPixelColor(x,y)
            n.setPixelColor(canvas.getWidth()-x-1,y,r,g,b)
    canvas.close()
    n.display()
    return n
开发者ID:acheney,项目名称:python-labs,代码行数:11,代码来源:imageedit.py

示例2: scrollHoriz

# 需要导入模块: from picture import Picture [as 别名]
# 或者: from picture.Picture import setPixelColor [as 别名]
def scrollHoriz(canvas) :
    m = eval(input("Scroll by how many pixels: "))
    n = Picture((canvas.getWidth(),canvas.getHeight()))
    for x in range(canvas.getWidth()):
        for y in range(canvas.getHeight()):
            r, g, b = canvas.getPixelColor(x,y)
            n.setPixelColor((x+m)%canvas.getWidth(),y,r,g,b)
    canvas.close()
    n.display()
    return n
开发者ID:acheney,项目名称:python-labs,代码行数:12,代码来源:imageedit.py

示例3: rotate180

# 需要导入模块: from picture import Picture [as 别名]
# 或者: from picture.Picture import setPixelColor [as 别名]
def rotate180(canvas) :
    w, h = canvas.getWidth(), canvas.getHeight()
    n = Picture((w,h))
    for x in range(w):
        for y in range(h):
            r, g, b = canvas.getPixelColor(x,y)
            n.setPixelColor(w-x-1,h-y-1,r,g,b)
    canvas.close()
    n.display()
    return n
开发者ID:acheney,项目名称:python-labs,代码行数:12,代码来源:imageedit.py

示例4: blur

# 需要导入模块: from picture import Picture [as 别名]
# 或者: from picture.Picture import setPixelColor [as 别名]
def blur(canvas) :
    w, h = canvas.getWidth(), canvas.getHeight()
    n = Picture((w,h))
    for x in range(w):
        for y in range(h):
            r, g, b = getAdjAvg(canvas,x,y)
            n.setPixelColor(x,y,r,g,b)
    canvas.close()
    n.display()
    return canvas
开发者ID:acheney,项目名称:python-labs,代码行数:12,代码来源:imageedit.py

示例5: rotate180

# 需要导入模块: from picture import Picture [as 别名]
# 或者: from picture.Picture import setPixelColor [as 别名]
def rotate180(canvas):
    w = canvas.getWidth()
    h = canvas.getHeight()
    new_canvas = Picture((w,h))
    canvas.close()
    for i in range(0,w):
        for j in range(0,h):
            r = canvas.getPixelRed(w-1-i,h-1-j)            
            g = canvas.getPixelGreen(w-1-i,h-1-j)
            b = canvas.getPixelBlue(w-1-i,h-1-j)
            new_canvas.setPixelColor(i,j,r,g,b)
    return new_canvas
开发者ID:Ash927,项目名称:python-labs,代码行数:14,代码来源:imageedit.py

示例6: zoom

# 需要导入模块: from picture import Picture [as 别名]
# 或者: from picture.Picture import setPixelColor [as 别名]
def zoom(canvas):
    w = canvas.getWidth()
    h = canvas.getHeight()
    new_canvas = Picture((w,h))
    canvas.close()
    for i in range(0,w):
        for j in range(0,h):
            r = canvas.getPixelRed(w//4+i//2,h//4+j//2)            
            g = canvas.getPixelGreen(w//4+i//2,h//4+j//2)
            b = canvas.getPixelBlue(w//4+i//2,h//4+j//2)
            new_canvas.setPixelColor(i,j,r,g,b)
    return new_canvas
开发者ID:Ash927,项目名称:python-labs,代码行数:14,代码来源:imageedit.py

示例7: scrollHorizontally

# 需要导入模块: from picture import Picture [as 别名]
# 或者: from picture.Picture import setPixelColor [as 别名]
def scrollHorizontally(canvas):
    n = eval(input("How many pixels would you like to scroll? "))
    w = canvas.getWidth()
    h = canvas.getHeight()
    new_canvas = Picture((w,h))
    canvas.close()
    for i in range(0,w):
        for j in range(0,h):
            r = canvas.getPixelRed(i,j)            
            g = canvas.getPixelGreen(i,j)
            b = canvas.getPixelBlue(i,j)
            new_canvas.setPixelColor((i+n)%w,j,r,g,b)
    return new_canvas
开发者ID:Ash927,项目名称:python-labs,代码行数:15,代码来源:imageedit.py

示例8: flipHorizontally

# 需要导入模块: from picture import Picture [as 别名]
# 或者: from picture.Picture import setPixelColor [as 别名]
def flipHorizontally(canvas):
    w = canvas.getWidth()
    h = canvas.getHeight()
    new_canvas = Picture((w,h))
    canvas.close()
    for i in range(0,w):
        for j in range(0,h):
            r = canvas.getPixelRed(w-1-i,j)            
            g = canvas.getPixelGreen(w-1-i,j)
            b = canvas.getPixelBlue(w-1-i,j)
            new_canvas.setPixelColor(i,j,r,g,b)
    for i in range(0,w):
        for j in range(0,h):
            r = new_canvas.getPixelRed(i,j)            
            g = new_canvas.getPixelGreen(i,j)
            b = new_canvas.getPixelBlue(i,j)
            canvas.setPixelColor(i,j,r,g,b)
    return canvas
开发者ID:Ash927,项目名称:python-labs,代码行数:20,代码来源:imageedit.py

示例9: zoom

# 需要导入模块: from picture import Picture [as 别名]
# 或者: from picture.Picture import setPixelColor [as 别名]
def zoom(canvas) :
    w, h = canvas.getWidth(), canvas.getHeight()
    n = Picture((w,h))
    for x in range(w//4,w-(w//4)):
        for y in range(h//4,h-(h//4)):
            r, g, b = canvas.getPixelColor(x,y)
            c,d = x-(w//4),y-(h//4)
            n.setPixelColor(c*2,d*2,r,g,b)
            n.setPixelColor((c*2)+1,d*2,r,g,b)
            n.setPixelColor(c*2,(d*2)+1,r,g,b)
            n.setPixelColor((c*2)+1,(d*2)+1,r,g,b)
    canvas.close()
    n.display()
    return n
开发者ID:acheney,项目名称:python-labs,代码行数:16,代码来源:imageedit.py

示例10: tiled

# 需要导入模块: from picture import Picture [as 别名]
# 或者: from picture.Picture import setPixelColor [as 别名]
def tiled(canvas) :
    w, h = canvas.getWidth(), canvas.getHeight()
    n = Picture((w,h))
    for x in range(0,w,3):
        for y in range(0,h,3):
            r, g, b = canvas.getPixelColor(x,y)
            #first row
            n.setPixelColor(x//3,y//3,r,g,b)
            n.setPixelColor(x//3 + w//3,y//3,r,g,b)
            n.setPixelColor(x//3 + 2*(w//3),y//3,r,g,b)
            #second
            n.setPixelColor(x//3,y//3 + h//3,r,g,b)
            n.setPixelColor(x//3 + w//3,y//3 + h//3,r,g,b)
            n.setPixelColor(x//3 + 2*(w//3),y//3 + h//3,r,g,b)
            #third row
            n.setPixelColor(x//3,y//3 + 2*(h//3),r,g,b)
            n.setPixelColor(x//3 + w//3,y//3 + 2*(h//3),r,g,b)
            n.setPixelColor(x//3 + 2*(w//3),y//3 + 2*(h//3),r,g,b)
    canvas.close()
    n.display()
    return n
开发者ID:acheney,项目名称:python-labs,代码行数:23,代码来源:imageedit.py

示例11: blur

# 需要导入模块: from picture import Picture [as 别名]
# 或者: from picture.Picture import setPixelColor [as 别名]
def blur(canvas):
    w = canvas.getWidth()
    h = canvas.getHeight()
    new_canvas = Picture((w,h))
    canvas.close()
    #dealing with the corners
    r = (canvas.getPixelRed(0,0)+canvas.getPixelRed(1,0)+canvas.getPixelRed(0,1)+canvas.getPixelRed(1,1))//4
    g = (canvas.getPixelGreen(0,0)+canvas.getPixelGreen(1,0)+canvas.getPixelGreen(0,1)+canvas.getPixelGreen(1,1))//4
    b = (canvas.getPixelBlue(0,0)+canvas.getPixelBlue(1,0)+canvas.getPixelBlue(0,1)+canvas.getPixelBlue(1,1))//4
    new_canvas.setPixelColor(0,0,r,g,b)
    
    r = (canvas.getPixelRed(w-1,0)+canvas.getPixelRed(w-2,0)+canvas.getPixelRed(w-1,1)+canvas.getPixelRed(w-2,1))//4
    g = (canvas.getPixelGreen(w-1,0)+canvas.getPixelGreen(w-2,0)+canvas.getPixelGreen(w-1,1)+canvas.getPixelGreen(w-2,1))//4
    b = (canvas.getPixelBlue(w-1,0)+canvas.getPixelBlue(w-2,0)+canvas.getPixelBlue(w-1,1)+canvas.getPixelBlue(w-2,1))//4
    new_canvas.setPixelColor(w-1,0,r,g,b)
    
    r = (canvas.getPixelRed(w-1,h-1)+canvas.getPixelRed(w-2,h-1)+canvas.getPixelRed(w-1,h-2)+canvas.getPixelRed(w-2,h-2))//4
    g = (canvas.getPixelGreen(w-1,h-1)+canvas.getPixelGreen(w-2,h-1)+canvas.getPixelGreen(w-1,h-2)+canvas.getPixelGreen(w-2,h-2))//4
    b = (canvas.getPixelBlue(w-1,h-1)+canvas.getPixelBlue(w-2,h-1)+canvas.getPixelBlue(w-1,h-2)+canvas.getPixelBlue(w-2,h-2))//4
    new_canvas.setPixelColor(w-1,h-1,r,g,b)
    
    r = (canvas.getPixelRed(0,h-1)+canvas.getPixelRed(1,h-1)+canvas.getPixelRed(0,h-2)+canvas.getPixelRed(1,h-2))//4
    g = (canvas.getPixelGreen(0,h-1)+canvas.getPixelGreen(1,h-1)+canvas.getPixelGreen(0,h-2)+canvas.getPixelGreen(1,h-2))//4
    b = (canvas.getPixelBlue(0,h-1)+canvas.getPixelBlue(1,h-1)+canvas.getPixelBlue(0,h-2)+canvas.getPixelBlue(1,h-2))//4
    new_canvas.setPixelColor(0,h-1,r,g,b)
    #top row
    for i in range(1,w-1):
        r = (canvas.getPixelRed(i,0)+canvas.getPixelRed(i-1,0)+canvas.getPixelRed(i+1,0)+canvas.getPixelRed(i,1)+canvas.getPixelRed(i-1,1)+canvas.getPixelRed(i+1,1))//6
        g = (canvas.getPixelGreen(i,0)+canvas.getPixelGreen(i-1,0)+canvas.getPixelGreen(i+1,0)+canvas.getPixelGreen(i,1)+canvas.getPixelGreen(i-1,1)+canvas.getPixelGreen(i+1,1))//6
        b = (canvas.getPixelBlue(i,0)+canvas.getPixelBlue(i-1,0)+canvas.getPixelBlue(i+1,0)+canvas.getPixelBlue(i,1)+canvas.getPixelBlue(i-1,1)+canvas.getPixelBlue(i+1,1))//6
        new_canvas.setPixelColor(i,0,r,g,b)
    #bottom row
    for i in range(1,w-1):
        r = (canvas.getPixelRed(i,h-1)+canvas.getPixelRed(i-1,h-1)+canvas.getPixelRed(i+1,h-1)+canvas.getPixelRed(i,h-2)+canvas.getPixelRed(i-1,h-2)+canvas.getPixelRed(i+1,h-2))//6
        g = (canvas.getPixelGreen(i,h-1)+canvas.getPixelGreen(i-1,h-1)+canvas.getPixelGreen(i+1,h-1)+canvas.getPixelGreen(i,h-2)+canvas.getPixelGreen(i-1,h-2)+canvas.getPixelGreen(i+1,h-2))//6
        b = (canvas.getPixelBlue(i,h-1)+canvas.getPixelBlue(i-1,h-1)+canvas.getPixelBlue(i+1,h-1)+canvas.getPixelBlue(i,h-2)+canvas.getPixelBlue(i-1,h-2)+canvas.getPixelBlue(i+1,h-2))//6
        new_canvas.setPixelColor(i,h-1,r,g,b)
    #left most column
    for i in range(1,h-1):
        r = (canvas.getPixelRed(0,i)+canvas.getPixelRed(0,i-1)+canvas.getPixelRed(0,i+1)+canvas.getPixelRed(1,i)+canvas.getPixelRed(1,i-1)+canvas.getPixelRed(1,i+1))//6
        g = (canvas.getPixelGreen(0,i)+canvas.getPixelGreen(0,i-1)+canvas.getPixelGreen(0,i+1)+canvas.getPixelGreen(1,i)+canvas.getPixelGreen(1,i-1)+canvas.getPixelGreen(1,i+1))//6
        b = (canvas.getPixelBlue(0,i)+canvas.getPixelBlue(0,i-1)+canvas.getPixelBlue(0,i+1)+canvas.getPixelBlue(1,i)+canvas.getPixelBlue(1,i-1)+canvas.getPixelBlue(1,i+1))//6
        new_canvas.setPixelColor(0,i,r,g,b)
    #right most column
    for i in range(1,h-1):
        r = (canvas.getPixelRed(w-1,i)+canvas.getPixelRed(w-1,i-1)+canvas.getPixelRed(w-1,i+1)+canvas.getPixelRed(w-2,i)+canvas.getPixelRed(w-2,i-1)+canvas.getPixelRed(w-2,i+1))//6
        g = (canvas.getPixelGreen(w-1,i)+canvas.getPixelGreen(w-1,i-1)+canvas.getPixelGreen(w-1,i+1)+canvas.getPixelGreen(w-2,i)+canvas.getPixelGreen(w-2,i-1)+canvas.getPixelGreen(w-2,i+1))//6
        b = (canvas.getPixelBlue(w-1,i)+canvas.getPixelBlue(w-1,i-1)+canvas.getPixelBlue(w-1,i+1)+canvas.getPixelBlue(w-2,i)+canvas.getPixelBlue(w-2,i-1)+canvas.getPixelBlue(w-2,i+1))//6
        new_canvas.setPixelColor(w-1,i,r,g,b)
    #The middle (finally)
    for i in range(1,w-1):
        for j in range(1,h-1):
            r = (canvas.getPixelRed(i-1,j-1)+canvas.getPixelRed(i-1,j)+canvas.getPixelRed(i-1,j+1)+canvas.getPixelRed(i,j-1)+canvas.getPixelRed(i,j)+canvas.getPixelRed(i,j+1)+canvas.getPixelRed(i+1,j-1)+canvas.getPixelRed(i+1,j)+canvas.getPixelRed(i+1,j+1))//9
            g = (canvas.getPixelGreen(i-1,j-1)+canvas.getPixelGreen(i-1,j)+canvas.getPixelGreen(i-1,j+1)+canvas.getPixelGreen(i,j-1)+canvas.getPixelGreen(i,j)+canvas.getPixelGreen(i,j+1)+canvas.getPixelGreen(i+1,j-1)+canvas.getPixelGreen(i+1,j)+canvas.getPixelGreen(i+1,j+1))//9
            b = (canvas.getPixelBlue(i-1,j-1)+canvas.getPixelBlue(i-1,j)+canvas.getPixelBlue(i-1,j+1)+canvas.getPixelBlue(i,j-1)+canvas.getPixelBlue(i,j)+canvas.getPixelBlue(i,j+1)+canvas.getPixelBlue(i+1,j-1)+canvas.getPixelBlue(i+1,j)+canvas.getPixelBlue(i+1,j+1))//9
            new_canvas.setPixelColor(i,j,r,g,b)
    return new_canvas
开发者ID:Ash927,项目名称:python-labs,代码行数:59,代码来源:imageedit.py


注:本文中的picture.Picture.setPixelColor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。