-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
Hi.
When trying to decode the TestImage.png from the demo application directory, I get an EXC_BAD_ACCESS error.
The problem appears to be an incorrect calculation of the data size (dataCount). The qoi_decode function returns a pointer to a buffer containing only raw pixel data, not the entire QOI file structure, including the header or padding.
Fix:
--- a/Sources/Swift-QOI/QOICoder.swift
+++ b/Sources/Swift-QOI/QOICoder.swift
@@ -50,8 +50,7 @@ final public class QOICoder {
let height = Int(desc.height)
let width = Int(desc.width)
- let pixelCount = height * width
- let dataCount = pixelCount * (Int(channels) + 1) + Mirror(reflecting: SQOI.qoi_padding).children.count + Int(SQOI.QOI_HEADER_SIZE)
+ let dataCount = height * width * Int(channels) // fix for EXC_BAD_ACCESS
let qoiData = Data(bytes: pixelData, count: dataCount)
return qoiDataMetadata
Metadata
Assignees
Labels
No labels