本文整理汇总了Python中java.awt.image.BufferedImage.getRaster方法的典型用法代码示例。如果您正苦于以下问题:Python BufferedImage.getRaster方法的具体用法?Python BufferedImage.getRaster怎么用?Python BufferedImage.getRaster使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.image.BufferedImage
的用法示例。
在下文中一共展示了BufferedImage.getRaster方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: image
# 需要导入模块: from java.awt.image import BufferedImage [as 别名]
# 或者: from java.awt.image.BufferedImage import getRaster [as 别名]
def image(self):
w = self.getWidth();
h = self.getHeight();
non_black_withe_image = BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB)
self.paint(non_black_withe_image.getGraphics())
raster=non_black_withe_image.getRaster()
bi = BufferedImage(w, h, BufferedImage.TYPE_BYTE_BINARY)
write_raster = bi.getRaster()
c = array.zeros('i', 4)
on=wc = array.zeros('i', 1)
off=array.zeros('i', 1)
off[0]=1
for x in range(w):
for y in range(h):
c = raster.getPixel(x,y,c)
if sum(c)!=1020:
write_raster.setPixel(x,y, on)
else:
write_raster.setPixel(x,y, off)
return bi;
示例2: main
# 需要导入模块: from java.awt.image import BufferedImage [as 别名]
# 或者: from java.awt.image.BufferedImage import getRaster [as 别名]
def main(self, args):
width = 400;
height = 400;
im = BufferedImage(width,height,BufferedImage.TYPE_BYTE_BINARY);
raster = im.getRaster();
for h in range(height):
for w in range(width):
if (h / 50 + w / 50) % 2 == 0:
raster.setSample(w,h,0,0);
else:
raster.setSample(w,h,0,1);
try:
ImageIO.write(im,"PNG", File("checkboard.png"));
except IOException:
print "can not open the file"