Showing
3 changed files
with
21 additions
and
4 deletions
@@ -247,9 +247,17 @@ public class PrintJob: UIPrintPageRenderer, UIPrintInteractionControllerDelegate | @@ -247,9 +247,17 @@ public class PrintJob: UIPrintPageRenderer, UIPrintInteractionControllerDelegate | ||
247 | let stride = width * 4 | 247 | let stride = width * 4 |
248 | var data = Data(repeating: 0, count: stride * height) | 248 | var data = Data(repeating: 0, count: stride * height) |
249 | 249 | ||
250 | - data.withUnsafeMutableBytes { (ptr: UnsafeMutablePointer<UInt8>) in | 250 | + data.withUnsafeMutableBytes { (outputBytes: UnsafeMutableRawBufferPointer) in |
251 | let rgb = CGColorSpaceCreateDeviceRGB() | 251 | let rgb = CGColorSpaceCreateDeviceRGB() |
252 | - let context = CGContext(data: ptr, width: width, height: height, bitsPerComponent: 8, bytesPerRow: stride, space: rgb, bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue) | 252 | + let context = CGContext( |
253 | + data: outputBytes.baseAddress?.assumingMemoryBound(to: UInt8.self), | ||
254 | + width: width, | ||
255 | + height: height, | ||
256 | + bitsPerComponent: 8, | ||
257 | + bytesPerRow: stride, | ||
258 | + space: rgb, | ||
259 | + bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue | ||
260 | + ) | ||
253 | if context != nil { | 261 | if context != nil { |
254 | context!.scaleBy(x: scale, y: scale) | 262 | context!.scaleBy(x: scale, y: scale) |
255 | context!.drawPDFPage(page) | 263 | context!.drawPDFPage(page) |
@@ -185,9 +185,17 @@ public class PrintJob: NSView, NSSharingServicePickerDelegate { | @@ -185,9 +185,17 @@ public class PrintJob: NSView, NSSharingServicePickerDelegate { | ||
185 | let stride = width * 4 | 185 | let stride = width * 4 |
186 | var data = Data(repeating: 0, count: stride * height) | 186 | var data = Data(repeating: 0, count: stride * height) |
187 | 187 | ||
188 | - data.withUnsafeMutableBytes { (ptr: UnsafeMutablePointer<UInt8>) in | 188 | + data.withUnsafeMutableBytes { (outputBytes: UnsafeMutableRawBufferPointer) in |
189 | let rgb = CGColorSpaceCreateDeviceRGB() | 189 | let rgb = CGColorSpaceCreateDeviceRGB() |
190 | - let context = CGContext(data: ptr, width: width, height: height, bitsPerComponent: 8, bytesPerRow: stride, space: rgb, bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue) | 190 | + let context = CGContext( |
191 | + data: outputBytes.baseAddress?.assumingMemoryBound(to: UInt8.self), | ||
192 | + width: width, | ||
193 | + height: height, | ||
194 | + bitsPerComponent: 8, | ||
195 | + bytesPerRow: stride, | ||
196 | + space: rgb, | ||
197 | + bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue | ||
198 | + ) | ||
191 | if context != nil { | 199 | if context != nil { |
192 | context!.scaleBy(x: scale, y: scale) | 200 | context!.scaleBy(x: scale, y: scale) |
193 | context!.drawPDFPage(page) | 201 | context!.drawPDFPage(page) |
-
Please register or login to post a comment