Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Tests/CoreRasterTests/Fixtures/JPEGFixtures.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,11 @@ enum JPEGFixtures {
let b = (0..<size).map { UInt8(truncatingIfNeeded: v >> (8 * (size - 1 - $0))) }
return littleEndian ? b.reversed() : b
}
let ifd = n(1, 2) + n(0x0112, 2) + n(3, 2) + n(1, 4) + n(orientation, 2) + [0, 0] + n(0, 4)
return segment(0xE1, Array("Exif".utf8) + [0, 0] + Array((littleEndian ? "II" : "MM").utf8) + n(42, 2) + n(8, 4) + ifd)
// Built as a list of parts: one long `+` chain times out the macOS type checker.
let entry: [[UInt8]] = [n(1, 2), n(0x0112, 2), n(3, 2), n(1, 4), n(orientation, 2), [0, 0], n(0, 4)]
let order: [UInt8] = Array((littleEndian ? "II" : "MM").utf8)
let body: [[UInt8]] = [Array("Exif".utf8), [0, 0], order, n(42, 2), n(8, 4), Array(entry.joined())]
return segment(0xE1, Array(body.joined()))
}
static func dqt(_ id: Int, _ table: [Int]) -> [UInt8] { segment(0xDB, [UInt8(id)] + zigzag.map { UInt8(clamping: table[$0]) }) }
static func dht(_ tableClass: Int, _ id: Int, _ t: Huffman) -> [UInt8] {
Expand Down
3 changes: 2 additions & 1 deletion Tests/CoreRasterTests/Fixtures/PNGFixtures.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ enum PNGFixtures {
let size = (stream.count + idats - 1) / idats
let parts = stride(from: 0, to: stream.count, by: size).map { chunk("IDAT", Array(stream[$0..<min($0 + size, stream.count)])) }
let head = chunk("IHDR", ihdr(pixels.first?.count ?? 0, pixels.count, depth: depth, colorType: colorType, interlace: interlaced ? 1 : 0))
return Data(signature + head + extra.joined() + parts.joined() + chunk("IEND", []))
let bytes: [UInt8] = signature + head + Array(extra.joined()) + Array(parts.joined()) + chunk("IEND", [])
return Data(bytes)
}

/// A `width` x `height` grid whose samples run through every value a depth holds, distinct per channel.
Expand Down
Loading