(bytes, offset)
| 3032 | * @returns {Uint8Array} |
| 3033 | */ |
| 3034 | export function extractPNG(bytes, offset) { |
| 3035 | const stream = new Stream(bytes.slice(offset)); |
| 3036 | |
| 3037 | // Move past signature to first chunk |
| 3038 | stream.moveForwardsBy(8); |
| 3039 | |
| 3040 | let chunkSize = 0, |
| 3041 | chunkType = ""; |
| 3042 | |
| 3043 | while (chunkType !== "IEND") { |
| 3044 | chunkSize = stream.readInt(4, "be"); |
| 3045 | chunkType = stream.readString(4); |
| 3046 | |
| 3047 | // Chunk data size + CRC checksum |
| 3048 | stream.moveForwardsBy(chunkSize + 4); |
| 3049 | } |
| 3050 | |
| 3051 | |
| 3052 | return stream.carve(); |
| 3053 | } |
| 3054 | |
| 3055 | |
| 3056 | /** |
nothing calls this directly
no test coverage detected