Skip to content

Commit

Permalink
Cleanup + Transparency
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacMarovitz committed Sep 10, 2023
1 parent 393522a commit 827ecac
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions Whisky/Models/BitmapInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,22 +101,22 @@ struct BitmapInfoHeader: Hashable {
let red = data.extract(UInt8.self, offset: offset) ?? 0
offset += 1
pixelRow.append(ColorQuad(red: red,
green: green,
blue: blue,
alpha: 1))
green: green,
blue: blue,
alpha: 1))
case .sampled32:
let blue = data.extract(UInt8.self, offset: offset) ?? 0
offset += 1
let green = data.extract(UInt8.self, offset: offset) ?? 0
offset += 1
let red = data.extract(UInt8.self, offset: offset) ?? 0
offset += 1
// let alpha = data.extract(UInt8.self, offset: offset) ?? 0
let alpha = data.extract(UInt8.self, offset: offset) ?? 0
offset += 1
pixelRow.append(ColorQuad(red: red,
green: green,
blue: blue,
alpha: 1))
green: green,
blue: blue,
alpha: alpha))
case .unknown:
break
}
Expand All @@ -141,14 +141,12 @@ struct BitmapInfoHeader: Hashable {
let green = data.extract(UInt8.self, offset: offset) ?? 0
offset += 1
let red = data.extract(UInt8.self, offset: offset) ?? 0
offset += 1
// var alpha = data.extract(UInt8.self, offset: offset) ?? 0
offset += 1
offset += 2

colorTable.append(ColorQuad(red: red,
green: green,
blue: blue,
alpha: 1))
alpha: Int(red) + Int(green) + Int(blue) == 0 ? 0 : 255))
}

return colorTable
Expand All @@ -158,7 +156,7 @@ struct BitmapInfoHeader: Hashable {
var pixels = pixels

if pixels.count > 0 {
let bitmapInfo = CGBitmapInfo(rawValue: CGImageAlphaInfo.noneSkipLast.rawValue)
let bitmapInfo = CGBitmapInfo(rawValue: CGImageAlphaInfo.last.rawValue)
let quadStride = MemoryLayout<ColorQuad>.stride

if let providerRef = CGDataProvider(data: Data(bytes: &pixels,
Expand Down

0 comments on commit 827ecac

Please sign in to comment.