()
| 86 | |
| 87 | |
| 88 | def test_setalpha(): |
| 89 | # pixmap from JPEG file, then add an alpha channel |
| 90 | # with 30% transparency |
| 91 | pix1 = pymupdf.Pixmap(imgfile) |
| 92 | opa = int(255 * 0.3) # corresponding to 30% transparency |
| 93 | alphas = [opa] * (pix1.width * pix1.height) |
| 94 | alphas = bytearray(alphas) |
| 95 | pix2 = pymupdf.Pixmap(pix1, 1) # add alpha channel |
| 96 | pix2.set_alpha(alphas) # make image 30% transparent |
| 97 | samples = pix2.samples # copy of samples |
| 98 | # confirm correct the alpha bytes |
| 99 | t = bytearray([samples[i] for i in range(3, len(samples), 4)]) |
| 100 | assert t == alphas |
| 101 | |
| 102 | def test_color_count(): |
| 103 | ''' |
nothing calls this directly
no test coverage detected
searching dependent graphs…