diff --git a/Samples/macOS/Sample.macOS/Info.plist b/Samples/macOS/Sample.macOS/Info.plist index 5ff82decb..9629bb950 100644 --- a/Samples/macOS/Sample.macOS/Info.plist +++ b/Samples/macOS/Sample.macOS/Info.plist @@ -11,7 +11,7 @@ CFBundleVersion 1 LSMinimumSystemVersion - 10.14 + 10.13 CFBundleDevelopmentRegion en CFBundleInfoDictionaryVersion diff --git a/Source/ZXing.Net.Mobile.macOS/BitmapRenderer.cs b/Source/ZXing.Net.Mobile.macOS/BitmapRenderer.cs index b953c2760..7f8288cae 100644 --- a/Source/ZXing.Net.Mobile.macOS/BitmapRenderer.cs +++ b/Source/ZXing.Net.Mobile.macOS/BitmapRenderer.cs @@ -1,18 +1,13 @@ using System; using ZXing.Rendering; - -using Foundation; -using CoreFoundation; using CoreGraphics; using AppKit; - using ZXing.Common; namespace ZXing.Mobile { public class BitmapRenderer : IBarcodeRenderer { - public NSImage Render(BitMatrix matrix, BarcodeFormat format, string content) { return Render(matrix, format, content, new EncodingOptions()); @@ -25,11 +20,12 @@ public NSImage Render(BitMatrix matrix, BarcodeFormat format, string content, En var black = new CGColor(0f, 0f, 0f); var white = new CGColor(1.0f, 1.0f, 1.0f); - for (int x = 0; x < matrix.Width; x++) + for (var x = 0; x < matrix.Width; x++) { - for (int y = 0; y < matrix.Height; y++) + for (var y = 0; y < matrix.Height; y++) { - context.SetFillColor(matrix[x, y] ? black : white); + var (cgX, cgY) = TransformToCoreGraphicsCoords(x, y, matrix); + context.SetFillColor(matrix[cgX, cgY] ? black : white); context.FillRect(new CGRect(x, y, 1, 1)); } } @@ -39,5 +35,10 @@ public NSImage Render(BitMatrix matrix, BarcodeFormat format, string content, En return img; } + + private static (int cgX, int cgY) TransformToCoreGraphicsCoords(int x, int y, BitMatrix matrix) + { + return (x, Math.Abs(y - matrix.Height + 1)); + } } }