Optimize image drawing

This commit is contained in:
Ali
2021-06-16 22:35:34 +04:00
parent d0830b3c00
commit 0f9648fb6c
17 changed files with 137 additions and 148 deletions

View File

@@ -56,7 +56,7 @@ var deviceScale: CGFloat {
func generateImage(_ size: CGSize, contextGenerator: (CGSize, CGContext) -> Void, opaque: Bool = false, scale: CGFloat? = nil) -> GImage? {
let selectedScale = scale ?? deviceScale
let scaledSize = CGSize(width: size.width * selectedScale, height: size.height * selectedScale)
let bytesPerRow = (4 * Int(scaledSize.width) + 15) & (~15)
let bytesPerRow = (4 * Int(scaledSize.width) + 31) & (~31)
let length = bytesPerRow * Int(scaledSize.height)
let bytes = malloc(length)!.assumingMemoryBound(to: Int8.self)