public void CreateMax() { if (!TestRuntime.CheckSystemAndSDKVersion(9, 3)) { Assert.Ignore("requires iOS 9.3+"); } var first = new CGColorConverterTriple() { Space = CGColorSpace.CreateGenericRgb(), Intent = CGColorRenderingIntent.Default, Transform = CGColorConverterTransformType.ApplySpace }; var second = new CGColorConverterTriple() { Space = CGColorSpace.CreateGenericGray(), Intent = CGColorRenderingIntent.Perceptual, Transform = CGColorConverterTransformType.FromSpace }; var third = new CGColorConverterTriple() { Space = CGColorSpace.CreateGenericXyz(), Intent = CGColorRenderingIntent.Saturation, Transform = CGColorConverterTransformType.ToSpace }; using (var converter = new CGColorConverter(null, first, first, first)) { Assert.That(converter.Handle, Is.Not.EqualTo(IntPtr.Zero), "Handle"); } }
public void CreateMax() { TestRuntime.AssertXcodeVersion(8, 0); var first = new GColorConversionInfoTriple() { Space = CGColorSpace.CreateGenericRgb(), Intent = CGColorRenderingIntent.Default, Transform = CGColorConversionInfoTransformType.ApplySpace }; var second = new GColorConversionInfoTriple() { Space = CGColorSpace.CreateGenericGray(), Intent = CGColorRenderingIntent.Perceptual, Transform = CGColorConversionInfoTransformType.FromSpace }; var third = new GColorConversionInfoTriple() { Space = CGColorSpace.CreateGenericXyz(), Intent = CGColorRenderingIntent.Saturation, Transform = CGColorConversionInfoTransformType.ToSpace }; using (var converter = new CGColorConversionInfo((NSDictionary)null, first, first, first)) { Assert.That(converter.Handle, Is.Not.EqualTo(IntPtr.Zero), "Handle"); } }
public void CreateSimple() { TestRuntime.AssertXcodeVersion(8, 0); using (var from = CGColorSpace.CreateGenericGray()) using (var to = CGColorSpace.CreateGenericRgb()) using (var converter = new CGColorConversionInfo(from, to)) { Assert.That(converter.Handle, Is.Not.EqualTo(IntPtr.Zero), "Handle"); } }
public void CreateSimple_GetINativeObject() { TestRuntime.AssertXcodeVersion(8, 0); using (var from = CGColorSpace.CreateGenericGray()) using (var to = CGColorSpace.CreateGenericRgb()) { var handle = CGColorConversionInfoCreate(from == null ? IntPtr.Zero : from.Handle, to == null ? IntPtr.Zero : to.Handle); using (var o = Runtime.GetINativeObject <CGColorConversionInfo> (handle, false)) { Assert.That(o.Handle, Is.Not.EqualTo(IntPtr.Zero), "Handle"); } } }
public void CreateSimple() { if (!TestRuntime.CheckSystemAndSDKVersion(9, 3)) { Assert.Ignore("requires iOS 9.3+"); } using (var from = CGColorSpace.CreateGenericGray()) using (var to = CGColorSpace.CreateGenericRgb()) using (var converter = new CGColorConverter(from, to)) { Assert.That(converter.Handle, Is.Not.EqualTo(IntPtr.Zero), "Handle"); } }
public void CGColorSpace_CGColorSpace_NSDictionary() { TestRuntime.AssertXcodeVersion(11, 0); using (var from = CGColorSpace.CreateGenericGray()) using (var to = CGColorSpace.CreateGenericRgb()) { using (var converter = new CGColorConversionInfo(from, to, (NSDictionary)null)) { Assert.That(converter.Handle, Is.Not.EqualTo(IntPtr.Zero), "Handle - null"); } using (var d = new NSDictionary()) using (var converter = new CGColorConversionInfo(from, to, d)) { Assert.That(converter.Handle, Is.Not.EqualTo(IntPtr.Zero), "Handle"); } } }
public void CGColorSpace_CGColorSpace_CGColorConversionOptions() { TestRuntime.AssertXcodeVersion(11, 0); using (var from = CGColorSpace.CreateGenericGray()) using (var to = CGColorSpace.CreateGenericRgb()) { using (var converter = new CGColorConversionInfo(from, to, (CGColorConversionOptions)null)) { Assert.That(converter.Handle, Is.Not.EqualTo(IntPtr.Zero), "Handle-null"); } var o = new CGColorConversionOptions(); o.BlackPointCompensation = true; using (var converter = new CGColorConversionInfo(from, to, o)) { Assert.That(converter.Handle, Is.Not.EqualTo(IntPtr.Zero), "Handle"); } } }
public void CreateSimple_GetINativeObject() { if (!TestRuntime.CheckSystemAndSDKVersion(9, 3)) { Assert.Ignore("requires iOS 9.3+"); } using (var from = CGColorSpace.CreateGenericGray()) using (var to = CGColorSpace.CreateGenericRgb()) { var handle = CGColorConverterCreateSimple(from == null ? IntPtr.Zero : from.Handle, to == null ? IntPtr.Zero : to.Handle); using (var o = Runtime.GetINativeObject <CGColorConverter> (handle, false)) { Assert.That(o.Handle, Is.Not.EqualTo(IntPtr.Zero), "Handle"); } } }
public NSImage Render(BitMatrix matrix, BarcodeFormat format, string content, EncodingOptions options) { var context = new CGBitmapContext(null, matrix.Width, matrix.Height, 8, 0, CGColorSpace.CreateGenericGray(), CGBitmapFlags.None); var black = new CGColor(0f, 0f, 0f); var white = new CGColor(1.0f, 1.0f, 1.0f); for (var x = 0; x < matrix.Width; x++) { for (var y = 0; y < matrix.Height; y++) { var(cgX, cgY) = TransformToCoreGraphicsCoords(x, y, matrix); context.SetFillColor(matrix[cgX, cgY] ? black : white); context.FillRect(new CGRect(x, y, 1, 1)); } } var img = new NSImage(context.ToImage(), new CGSize(matrix.Width, matrix.Height)); context.Dispose(); return(img); }