package rle func decompress4(output *[]uint8, width, height int, input []uint8, size int) bool { var ( code int onceBytes, total int ) code = CVAL(&input) rle := code&0x10 != 0 noAlpha := code&0x20 != 0 if !rle { return false } total = 1 out := *output if noAlpha { // No alpha plane in the stream; fill alpha channel with 0xFF. for i := 3; i < len(out); i += 4 { out[i] = 0xFF } } else { var ok bool onceBytes, ok = processPlane(&input, width, height, output, 3) if !ok { return false } total += onceBytes } var ok bool onceBytes, ok = processPlane(&input, width, height, output, 2) if !ok { return false } total += onceBytes onceBytes, ok = processPlane(&input, width, height, output, 1) if !ok { return false } total += onceBytes onceBytes, ok = processPlane(&input, width, height, output, 0) if !ok { return false } total += onceBytes return true } // DecompressInto decompresses bitmap data into dst, reusing dst if it has // sufficient capacity (size = width*height*bpp). If dst is nil or too small // a new slice is allocated. Returns the (re)used output slice.