G
G
gd1xza2021-06-04 08:41:34
PNG
gd1xza, 2021-06-04 08:41:34

How does this png filter sub work?

image file png 3x3 with all different colors
encoded in idat block 3 scan lines 1st line has filter 1 (sub)
colors encoded in png through photoshop rgb (0,162,232) (185,122,87) (34,177,76)
here is a description of the filter
code

def Raw(i,d):
    if i < 0:
        return 0
    else:
        return d[i]
def unsub(d):    
    dd = b""
    for i,b in enumerate(d):
        bpp = 4
        dd += bytes([b + Raw(i - bpp,d)])
    return dd

where d is a byte string scan line without specifying a filter
d is equal to 00a2e8ffb9d86f006937f500 (in hex) is
12
3 pixels long with 4 channels p g b and
on byte 2 2 pixels this error occurs:
dd += bytes([b + Raw(i - bpp,d)])
ValueError: bytes must be in range(0, 256)

that is, there the number turned out to be more, but as if I did everything according to the specs, but how is it

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question