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


Python ImageDraw.ImageDraw方法代码示例

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


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

示例1: test_shape1

# 需要导入模块: from PIL import ImageDraw [as 别名]
# 或者: from PIL.ImageDraw import ImageDraw [as 别名]
def test_shape1(self):
        # Arrange
        im = Image.new("RGB", (100, 100), "white")
        draw = ImageDraw.Draw(im)
        x0, y0 = 5, 5
        x1, y1 = 5, 50
        x2, y2 = 95, 50
        x3, y3 = 95, 5

        # Act
        s = ImageDraw.Outline()
        s.move(x0, y0)
        s.curve(x1, y1, x2, y2, x3, y3)
        s.line(x0, y0)

        draw.shape(s, fill=1)

        # Assert
        self.assert_image_equal(
            im, Image.open("Tests/images/imagedraw_shape1.png")) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:22,代码来源:test_imagedraw.py

示例2: test_shape2

# 需要导入模块: from PIL import ImageDraw [as 别名]
# 或者: from PIL.ImageDraw import ImageDraw [as 别名]
def test_shape2(self):
        # Arrange
        im = Image.new("RGB", (100, 100), "white")
        draw = ImageDraw.Draw(im)
        x0, y0 = 95, 95
        x1, y1 = 95, 50
        x2, y2 = 5, 50
        x3, y3 = 5, 95

        # Act
        s = ImageDraw.Outline()
        s.move(x0, y0)
        s.curve(x1, y1, x2, y2, x3, y3)
        s.line(x0, y0)

        draw.shape(s, outline="blue")

        # Assert
        self.assert_image_equal(
            im, Image.open("Tests/images/imagedraw_shape2.png")) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:22,代码来源:test_imagedraw.py

示例3: test_floodfill_border

# 需要导入模块: from PIL import ImageDraw [as 别名]
# 或者: from PIL.ImageDraw import ImageDraw [as 别名]
def test_floodfill_border(self):
        # floodfill() is experimental

        # Arrange
        im = Image.new("RGB", (W, H))
        draw = ImageDraw.Draw(im)
        draw.rectangle(BBOX2, outline="yellow", fill="green")
        centre_point = (int(W/2), int(H/2))

        # Act
        ImageDraw.floodfill(
            im, centre_point, ImageColor.getrgb("red"),
            border=ImageColor.getrgb("black"))

        # Assert
        self.assert_image_equal(
            im, Image.open("Tests/images/imagedraw_floodfill2.png")) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:19,代码来源:test_imagedraw.py

示例4: test_floodfill_thresh

# 需要导入模块: from PIL import ImageDraw [as 别名]
# 或者: from PIL.ImageDraw import ImageDraw [as 别名]
def test_floodfill_thresh(self):
        # floodfill() is experimental

        # Arrange
        im = Image.new("RGB", (W, H))
        draw = ImageDraw.Draw(im)
        draw.rectangle(BBOX2, outline="darkgreen", fill="green")
        centre_point = (int(W/2), int(H/2))

        # Act
        ImageDraw.floodfill(
            im, centre_point, ImageColor.getrgb("red"),
            thresh=30)

        # Assert
        self.assert_image_equal(
            im, Image.open("Tests/images/imagedraw_floodfill2.png")) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:19,代码来源:test_imagedraw.py

示例5: _test_font

# 需要导入模块: from PIL import ImageDraw [as 别名]
# 或者: from PIL.ImageDraw import ImageDraw [as 别名]
def _test_font(self, font):
        im = Image.new('RGB', (255, 255), 'white')
        draw = ImageDraw.ImageDraw(im)
        self._test_leak(lambda: draw.text((0, 0), "some text "*1024,  # ~10k
                                          font=font, fill="black")) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:7,代码来源:test_font_leaks.py

示例6: test_sanity

# 需要导入模块: from PIL import ImageDraw [as 别名]
# 或者: from PIL.ImageDraw import ImageDraw [as 别名]
def test_sanity(self):
        im = hopper("RGB").copy()

        draw = ImageDraw.ImageDraw(im)
        draw = ImageDraw.Draw(im)

        draw.ellipse(list(range(4)))
        draw.line(list(range(10)))
        draw.polygon(list(range(100)))
        draw.rectangle(list(range(4))) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:12,代码来源:test_imagedraw.py

示例7: test_valueerror

# 需要导入模块: from PIL import ImageDraw [as 别名]
# 或者: from PIL.ImageDraw import ImageDraw [as 别名]
def test_valueerror(self):
        im = Image.open("Tests/images/chi.gif")

        draw = ImageDraw.Draw(im)
        draw.line((0, 0), fill=(0, 0, 0)) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:7,代码来源:test_imagedraw.py

示例8: test_mode_mismatch

# 需要导入模块: from PIL import ImageDraw [as 别名]
# 或者: from PIL.ImageDraw import ImageDraw [as 别名]
def test_mode_mismatch(self):
        im = hopper("RGB").copy()

        self.assertRaises(ValueError, ImageDraw.ImageDraw, im, mode="L") 
开发者ID:holzschu,项目名称:python3_ios,代码行数:6,代码来源:test_imagedraw.py

示例9: helper_arc

# 需要导入模块: from PIL import ImageDraw [as 别名]
# 或者: from PIL.ImageDraw import ImageDraw [as 别名]
def helper_arc(self, bbox, start, end):
        # Arrange
        im = Image.new("RGB", (W, H))
        draw = ImageDraw.Draw(im)

        # Act
        draw.arc(bbox, start, end)

        # Assert
        self.assert_image_similar(
            im, Image.open("Tests/images/imagedraw_arc.png"), 1) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:13,代码来源:test_imagedraw.py

示例10: test_arc_no_loops

# 需要导入模块: from PIL import ImageDraw [as 别名]
# 或者: from PIL.ImageDraw import ImageDraw [as 别名]
def test_arc_no_loops(self):
        # No need to go in loops
        # Arrange
        im = Image.new("RGB", (W, H))
        draw = ImageDraw.Draw(im)
        start = 5
        end = 370

        # Act
        draw.arc(BBOX1, start=start, end=end)

        # Assert
        self.assert_image_similar(
            im, Image.open("Tests/images/imagedraw_arc_no_loops.png"), 1) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:16,代码来源:test_imagedraw.py

示例11: test_arc_width

# 需要导入模块: from PIL import ImageDraw [as 别名]
# 或者: from PIL.ImageDraw import ImageDraw [as 别名]
def test_arc_width(self):
        # Arrange
        im = Image.new("RGB", (W, H))
        draw = ImageDraw.Draw(im)
        expected = "Tests/images/imagedraw_arc_width.png"

        # Act
        draw.arc(BBOX1, 10, 260, width=5)

        # Assert
        self.assert_image_similar(im, Image.open(expected), 1) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:13,代码来源:test_imagedraw.py

示例12: test_arc_width_fill

# 需要导入模块: from PIL import ImageDraw [as 别名]
# 或者: from PIL.ImageDraw import ImageDraw [as 别名]
def test_arc_width_fill(self):
        # Arrange
        im = Image.new("RGB", (W, H))
        draw = ImageDraw.Draw(im)
        expected = "Tests/images/imagedraw_arc_width_fill.png"

        # Act
        draw.arc(BBOX1, 10, 260, fill="yellow", width=5)

        # Assert
        self.assert_image_similar(im, Image.open(expected), 1) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:13,代码来源:test_imagedraw.py

示例13: test_bitmap

# 需要导入模块: from PIL import ImageDraw [as 别名]
# 或者: from PIL.ImageDraw import ImageDraw [as 别名]
def test_bitmap(self):
        # Arrange
        small = Image.open("Tests/images/pil123rgba.png").resize((50, 50))
        im = Image.new("RGB", (W, H))
        draw = ImageDraw.Draw(im)

        # Act
        draw.bitmap((10, 10), small)

        # Assert
        self.assert_image_equal(
            im, Image.open("Tests/images/imagedraw_bitmap.png")) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:14,代码来源:test_imagedraw.py

示例14: helper_chord

# 需要导入模块: from PIL import ImageDraw [as 别名]
# 或者: from PIL.ImageDraw import ImageDraw [as 别名]
def helper_chord(self, mode, bbox, start, end):
        # Arrange
        im = Image.new(mode, (W, H))
        draw = ImageDraw.Draw(im)
        expected = "Tests/images/imagedraw_chord_{}.png".format(mode)

        # Act
        draw.chord(bbox, start, end, fill="red", outline="yellow")

        # Assert
        self.assert_image_similar(im, Image.open(expected), 1) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:13,代码来源:test_imagedraw.py

示例15: test_chord_width_fill

# 需要导入模块: from PIL import ImageDraw [as 别名]
# 或者: from PIL.ImageDraw import ImageDraw [as 别名]
def test_chord_width_fill(self):
        # Arrange
        im = Image.new("RGB", (W, H))
        draw = ImageDraw.Draw(im)
        expected = "Tests/images/imagedraw_chord_width_fill.png"

        # Act
        draw.chord(BBOX1, 10, 260, fill="red", outline="yellow", width=5)

        # Assert
        self.assert_image_similar(im, Image.open(expected), 1) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:13,代码来源:test_imagedraw.py


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