enable warnings and fix issues reported by that
[PyX.git] / test / functional / test_bitmap.py
blob657446c6d148188e85c355925eadc6b0fbca5d79
1 import sys; sys.path.insert(0, "../..")
2 from pyx import *
3 try:
4 from PIL.Image import open
5 except:
6 print("PIL not available, skipping palette test")
7 paletteimage = None
8 else:
9 paletteimage = open("../../www/vcss.png")
11 image_bw = bitmap.image(2, 2, "L", b"\0\377\377\0")
12 image_rgb = bitmap.image(3, 2, "RGB", b"\77\77\77\177\177\177\277\277\277"
13 b"\377\0\0\0\377\0\0\0\377")
15 bitmap_bw_stream = bitmap.bitmap(0, 1, image_bw, height=0.8)
16 bitmap_rgb_stream = bitmap.bitmap(0, 0, image_rgb, height=0.8)
18 bitmap_bw_storestring = bitmap.bitmap(2, 1, image_bw, height=0.8, PSstoreimage=1)
19 bitmap_rgb_storestring = bitmap.bitmap(2, 0, image_rgb, height=0.8, PSstoreimage=1)
21 bitmap_bw_storearray = bitmap.bitmap(4, 1, image_bw, height=0.8, PSstoreimage=1, PSmaxstrlen=2)
22 bitmap_rgb_storearray = bitmap.bitmap(4, 0, image_rgb, height=0.8, PSstoreimage=1, PSmaxstrlen=2)
24 c = canvas.canvas()
25 c.insert(bitmap_bw_stream)
26 c.insert(bitmap_rgb_stream)
27 c.insert(bitmap_bw_storestring)
28 c.insert(bitmap_rgb_storestring)
29 c.insert(bitmap_bw_storearray)
30 c.insert(bitmap_rgb_storearray)
31 if paletteimage:
32 c.insert(bitmap.bitmap(6, 0, paletteimage, height=1.8))
33 c.writeEPSfile("test_bitmap", page_paperformat=document.paperformat.A4)
34 c.writePDFfile("test_bitmap", page_paperformat=document.paperformat.A4)