mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Fix warning
This commit is contained in:
parent
c44260bdff
commit
c5cf2e88be
@ -29,17 +29,31 @@ private func generateHistogram(cgImage: CGImage) -> ([[vImagePixelCount]], Int)?
|
|||||||
}
|
}
|
||||||
assert(error == kvImageNoError)
|
assert(error == kvImageNoError)
|
||||||
|
|
||||||
let histogramBins: [[vImagePixelCount]] = (0...3).map { _ in
|
var histogramBinZero = [vImagePixelCount](repeating: 0, count: 256)
|
||||||
return [vImagePixelCount](repeating: 0, count: 256)
|
var histogramBinOne = [vImagePixelCount](repeating: 0, count: 256)
|
||||||
}
|
var histogramBinTwo = [vImagePixelCount](repeating: 0, count: 256)
|
||||||
var mutableHistogram: [UnsafeMutablePointer<vImagePixelCount>?] = histogramBins.map {
|
var histogramBinThree = [vImagePixelCount](repeating: 0, count: 256)
|
||||||
return UnsafeMutablePointer<vImagePixelCount>(mutating: $0)
|
|
||||||
}
|
histogramBinZero.withUnsafeMutableBufferPointer { zeroPtr in
|
||||||
error = vImageHistogramCalculation_ARGB8888(&sourceBuffer, &mutableHistogram, noFlags)
|
histogramBinOne.withUnsafeMutableBufferPointer { onePtr in
|
||||||
|
histogramBinTwo.withUnsafeMutableBufferPointer { twoPtr in
|
||||||
|
histogramBinThree.withUnsafeMutableBufferPointer { threePtr in
|
||||||
|
var histogramBins = [zeroPtr.baseAddress, onePtr.baseAddress, twoPtr.baseAddress, threePtr.baseAddress]
|
||||||
|
histogramBins.withUnsafeMutableBufferPointer { histogramBinsPtr in
|
||||||
|
let error = vImageHistogramCalculation_ARGB8888(
|
||||||
|
&sourceBuffer,
|
||||||
|
histogramBinsPtr.baseAddress!,
|
||||||
|
noFlags
|
||||||
|
)
|
||||||
assert(error == kvImageNoError)
|
assert(error == kvImageNoError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let alphaBinIndex = [.last, .premultipliedLast].contains(cgImage.alphaInfo) ? 3 : 0
|
let alphaBinIndex = [.last, .premultipliedLast].contains(cgImage.alphaInfo) ? 3 : 0
|
||||||
return (histogramBins, alphaBinIndex)
|
return ([histogramBinZero, histogramBinOne, histogramBinTwo, histogramBinThree], alphaBinIndex)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func imageHasTransparency(_ cgImage: CGImage) -> Bool {
|
public func imageHasTransparency(_ cgImage: CGImage) -> Bool {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user