Beispiel #1
0
        public void ColorSpace()
        {
            TestRuntime.AssertSystemVersion(ApplePlatform.MacOSX, 10, 9, throwIfOtherPlatform: false);
            TestRuntime.AssertSystemVersion(ApplePlatform.iOS, 7, 0, throwIfOtherPlatform: false);

            using (var f = new CIColorCubeWithColorSpace()) {
                Assert.Null(f.ColorSpace, "ColorSpace/default");
                using (var cs = CGColorSpace.CreateDeviceGray()) {
                    f.ColorSpace = cs;
                    var rc = CFGetRetainCount(cs.Handle);
                    for (int i = 0; i < 5; i++)
                    {
                        using (var fcs = f.ColorSpace)
                            Assert.NotNull(fcs, i.ToString());
                    }
                    Assert.That(CFGetRetainCount(cs.Handle), Is.EqualTo(rc), "RetainCount");
                    f.ColorSpace = null;
                }
                Assert.Null(f.ColorSpace, "ColorSpace/reset-null");
            }
        }
Beispiel #2
0
        public void ColorSpace()
        {
            if (!TestRuntime.CheckSystemAndSDKVersion(7, 0))
            {
                Assert.Ignore("Ignoring ColorSpace test: CIColorCubeWithColorSpace requires iOS7+");
            }

            using (var f = new CIColorCubeWithColorSpace()) {
                Assert.Null(f.ColorSpace, "ColorSpace/default");
                using (var cs = CGColorSpace.CreateDeviceGray()) {
                    f.ColorSpace = cs;
                    var rc = CFGetRetainCount(cs.Handle);
                    for (int i = 0; i < 5; i++)
                    {
                        Assert.NotNull(f.ColorSpace, i.ToString());
                    }
                    Assert.That(CFGetRetainCount(cs.Handle), Is.EqualTo(rc), "RetainCount");
                    f.ColorSpace = null;
                }
                Assert.Null(f.ColorSpace, "ColorSpace/reset-null");
            }
        }
		/// <summary>
		/// Modifies the source pixels using a 3D color-table and then maps the result to a color space.
		/// </summary>
		/// <returns>The altered image.</returns>
		public CIImage ColorCubeWithColorSpace ()
		{
			float [] color_cube_data = {
				0, 0, 0, 1,
				.1f, 0, 1, 1,
				0, 1, 0, 1,
				1, 1, 0, 1,
				0, 0, 1, 1,
				1, 0, 1, 1,
				0, 1, 1, 1,
				1, 1, 1, 1
			};

			var byteArray = new byte[color_cube_data.Length * 4];
			Buffer.BlockCopy(color_cube_data, 0, byteArray, 0, byteArray.Length);
			var data = NSData.FromArray (byteArray);

			using (var cs = CGColorSpace.CreateDeviceRGB ()) {
				var cube = new CIColorCubeWithColorSpace () {
					Image = flower,
					CubeDimension = 2,
					CubeData = data,
					ColorSpace = cs
				};
				return cube.OutputImage;
			}
		}