示例#1
0
        public void SaveAdd()
        {
            string filename = @"saveadd.tif";
            FreeImageBitmap fib = new FreeImageBitmap(100, 100, PixelFormat.Format24bppRgb);
            try
            {
                fib.SaveAdd();
                Assert.Fail();
            }
            catch { }
            Assert.IsFalse(File.Exists(filename));
            fib.Save(filename);
            fib.AdjustBrightness(0.3d);
            fib.SaveAdd();
            FreeImageBitmap other = new FreeImageBitmap(100, 100, PixelFormat.Format24bppRgb);
            foreach (Scanline<RGBTRIPLE> scanline in other)
            {
                for (int i = 0; i < scanline.Length; i++)
                {
                    scanline[i] = new RGBTRIPLE(Color.FromArgb(0x339955));
                }
            }
            fib.SaveAdd(other);
            other.SaveAdd(filename);
            other.Dispose();
            fib.Dispose();

            fib = new FreeImageBitmap(filename);
            Assert.AreEqual(4, fib.FrameCount);
            fib.Dispose();
            File.Delete(filename);
            Assert.IsFalse(File.Exists(filename));
        }
示例#2
0
        public void RGBTRIPLE()
        {
            RGBTRIPLE rgbt = new RGBTRIPLE();
            Assert.AreEqual(0, rgbt.rgbtBlue);
            Assert.AreEqual(0, rgbt.rgbtGreen);
            Assert.AreEqual(0, rgbt.rgbtRed);

            rgbt = new RGBTRIPLE(Color.Chartreuse);
            Assert.That(EqualColors(Color.Chartreuse, rgbt.Color));

            rgbt = new RGBTRIPLE(Color.FromArgb(133, 83, 95, 173));
            Assert.AreEqual(173, rgbt.rgbtBlue);
            Assert.AreEqual(95, rgbt.rgbtGreen);
            Assert.AreEqual(83, rgbt.rgbtRed);

            rgbt.Color = Color.Crimson;
            Assert.That(EqualColors(Color.Crimson, rgbt.Color));

            rgbt.Color = Color.MidnightBlue;
            Assert.That(EqualColors(Color.MidnightBlue, rgbt.Color));

            rgbt.Color = Color.White;
            Assert.AreEqual(255, rgbt.rgbtBlue);
            Assert.AreEqual(255, rgbt.rgbtGreen);
            Assert.AreEqual(255, rgbt.rgbtRed);

            rgbt.Color = Color.Black;
            Assert.AreEqual(0, rgbt.rgbtBlue);
            Assert.AreEqual(0, rgbt.rgbtGreen);
            Assert.AreEqual(0, rgbt.rgbtRed);

            rgbt = Color.DarkGoldenrod;
            Color color = rgbt;
            Assert.That(EqualColors(Color.DarkGoldenrod, color));
        }