Ejemplo n.º 1
0
def png_invalid_bad_palette_reference():
    """Leave out the palette on a paletted image."""
    return (pngforge.sig() +
            pngforge.ihdr(width=1, height=1,
                          color_type=pngforge.COLOR_INDEXED) +
            pngforge.idat(pngforge.scanline(0, chr(0))) +
            pngforge.iend())
Ejemplo n.º 2
0
def png_invalid_bad_palette_reference():
    """Refer to a nonexistent palette entry."""
    palette = ''.join([pngforge.rgb(i,i,i) for i in range(64)])
    return (pngforge.sig() +
            pngforge.ihdr(width=1, height=1,
                          color_type=pngforge.COLOR_INDEXED) +
            pngforge.chunk('PLTE', palette) +
            pngforge.idat(pngforge.scanline(0, chr(64))) +
            pngforge.iend())
Ejemplo n.º 3
0
def png_invalid_short_palette():
    """Construct a palette that isn't a multiple of 3 bytes long."""
    palette = ''.join([pngforge.rgb(i,i,i) for i in range(2)])[0:5]
    return (pngforge.sig() +
            pngforge.ihdr(width=1, height=1,
                          color_type=pngforge.COLOR_INDEXED) +
            pngforge.chunk('PLTE', palette) +
            pngforge.idat(pngforge.scanline(0, '\0')) +
            pngforge.iend())
Ejemplo n.º 4
0
def png_valid_tiny():
    """Create a valid, though tiny, image."""
    return (pngforge.sig() + pngforge.ihdr(width=1, height=1) +
            pngforge.idat(pngforge.scanline(0, '\1\2\3')) +
            pngforge.iend())
Ejemplo n.º 5
0
def png_invalid_missing_iend():
    """A valid image, just missing the IEND."""
    return (pngforge.sig() + pngforge.ihdr(width=1, height=1) +
            pngforge.idat(pngforge.scanline(0, '\1\2\3')))
Ejemplo n.º 6
0
def png_invalid_long_idat():
    """Create a image with an overlong IDAT."""
    return (pngforge.sig() + pngforge.ihdr(1, 1) +
            pngforge.idat(pngforge.scanline(0, '\0' * 20)) +
            pngforge.iend())