简体   繁体   English

如何在python3中使用graphics.py获取和设置像素的颜色值

[英]How to get and set pixel's color value using graphics.py in python3

I'm implementing Boundary Fill Algorithm for polygons in python.How to get and set the color of a pixel?我正在为 python 中的多边形实现边界填充算法。如何获取和设置像素的颜色? I'm using graphics.py file.我正在使用 graphics.py 文件。

Zelle graphics provides operators to manipulate pixels of images as documented in the code: Zelle graphics 提供操作员来操作代码中记录的图像像素:

The library also provides a very simple class for pixel-based image manipulation, Pixmap.该库还为基于像素的图像处理提供了一个非常简单的类 Pixmap。 A pixmap can be loaded from a file and displayed using an Image object.像素图可以从文件加载并使用 Image 对象显示。 Both getPixel and setPixel methods are provided for manipulating the image.提供了 getPixel 和 setPixel 方法来操作图像。

But not higher level objects like polygons.但不是像多边形这样的更高级别的对象。

This answer to Get color of coordinate of figure drawn with Python Zelle graphics shows how to get the fill color of an object like a polygon located at a given (x, y) coordinate using the tkinter underpinnings of Zelle graphics.获取使用 Python Zelle 图形绘制的图形坐标颜色的答案显示了如何使用 Zelle 图形的 tkinter 基础获取位于给定 (x, y) 坐标处的多边形等对象的填充颜色。 I doubt this technique can be used to set the color of a pixel of a polygon, however.然而,我怀疑这种技术可用于设置多边形像素的颜色。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM