Exemplo n.º 1
0
        public void Example()
        {
            // Load the sample bitmap.
            FIBITMAP dib = FreeImage.LoadEx("Sample.jpg");

            // Check success
            if (dib.IsNull)
            {
                Console.WriteLine("Sample.jpg could not be loaded. Aborting.");
                return;
            }

            // Get the bitmaps ICC-Profile.
            FIICCPROFILE icc = FreeImage.GetICCProfileEx(dib);

            // Print the profiles address.
            Console.WriteLine("The profiles memory-address is : 0x{0}", icc.DataPointer.ToString("X"));

            // Print the profiles size
            Console.WriteLine("The profiles size is : {0} bytes", icc.Size);

            // Create data for a new profile.
            byte[] data = new byte[256];
            for (int i = 0; i < data.Length; i++)
                data[i] = (byte)i;

            // Create the new profile
            icc = new FIICCPROFILE(dib, data);

            Console.WriteLine("The profiles memory-address is : 0x{0}", icc.DataPointer.ToString("X"));
            Console.WriteLine("The profiles size is : {0} bytes", icc.Size);

            // Create the new profile but only use the first 64 bytes
            icc = new FIICCPROFILE(dib, data, 64);

            Console.WriteLine("The profiles memory-address is : 0x{0}", icc.DataPointer.ToString("X"));
            Console.WriteLine("The profiles size is : {0} bytes", icc.Size);

            // CreateICCProfileEx(...) does the same as above
            icc = FreeImage.CreateICCProfileEx(dib, data, 16);

            Console.WriteLine("The profiles memory-address is : 0x{0}", icc.DataPointer.ToString("X"));
            Console.WriteLine("The profiles size is : {0} bytes", icc.Size);

            FreeImage.UnloadEx(ref dib);
        }
Exemplo n.º 2
0
        public void FIICCPROFILE()
        {
            Random rand = new Random(DateTime.Now.Millisecond);
            FIICCPROFILE var = new FIICCPROFILE();
            Assert.AreEqual(0, var.Data.Length);
            Assert.AreEqual(IntPtr.Zero, var.DataPointer);
            Assert.AreEqual(0, var.Size);

            dib = iManager.GetBitmap(ImageType.Odd, ImageColorType.Type_24);
            Assert.That(!dib.IsNull);

            byte[] data = new byte[512];
            rand.NextBytes(data);

            var = FreeImage.GetICCProfileEx(dib);
            Assert.AreEqual(0, var.Size);

            var = new FIICCPROFILE(dib, data, 256);
            Assert.AreEqual(256, var.Data.Length);
            Assert.AreNotEqual(IntPtr.Zero, var.DataPointer);
            Assert.AreEqual(256, var.Size);
            byte[] dataComp = var.Data;
            for (int i = 0; i < data.Length && i < dataComp.Length; i++)
                if (data[i] != dataComp[i])
                    Assert.Fail();

            FreeImage.DestroyICCProfile(dib);
            var = FreeImage.GetICCProfileEx(dib);
            Assert.AreEqual(0, var.Size);

            var = new FIICCPROFILE(dib, data);
            Assert.AreEqual(512, var.Data.Length);
            Assert.AreNotEqual(IntPtr.Zero, var.DataPointer);
            Assert.AreEqual(512, var.Size);
            dataComp = var.Data;
            for (int i = 0; i < data.Length && i < dataComp.Length; i++)
                if (data[i] != dataComp[i])
                    Assert.Fail();

            var = FreeImage.GetICCProfileEx(dib);
            Assert.AreEqual(512, var.Data.Length);
            Assert.AreNotEqual(IntPtr.Zero, var.DataPointer);
            Assert.AreEqual(512, var.Size);

            FreeImage.DestroyICCProfile(dib);
            var = FreeImage.GetICCProfileEx(dib);
            Assert.AreEqual(0, var.Size);

            FreeImage.UnloadEx(ref dib);
        }