예제 #1
0
		public void MantieneColor()
		{
			var assembly = Assembly.GetExecutingAssembly();
			var resourceName = "RopHelperTest.TestImage.gif";
			var gifstream = assembly.GetManifestResourceStream(resourceName);
			var midecode = GifBitmap.FromStream(gifstream, true);
			Assert.IsNotNull(midecode);
			gifstream.Close();
			var pixelgif = midecode.Image(0).Bitmap32ToPixels();
			var pix = pixelgif.Flat();
			var oct = new OctTree();
			
			foreach (var c in pix)
			{
				oct.Add(c);
				var t = oct.Read();
				Assert.IsTrue(t.Contains(c));
			}
			Assert.IsTrue(oct.LeafCount > 0);
			var tabla = oct.Read().OrderBy(e=>e.ToArgb()).ToArray();
			var pal = midecode.Image(0).Palette.Entries.OrderBy(e=>e.ToArgb()).ToArray();
			var lin = pix.Select(e=>(Color)e).OrderBy(e => e.ToArgb()).ToArray();
			foreach(var p in lin)
			{
				Assert.IsTrue(tabla.Contains(p));
			}
		}
		public static Color[] QuantizeColors(this Bitmap image)
		{
			if (image.HasPalette()) return image.Palette.Entries;
			var pix = image.Bitmap32ToPixels().Flat();
			var oct = new OctTree();
			foreach (var c in pix)
			{
				oct.Add(c);
			}
			var tabla = oct.Read();
			return tabla;
		}
예제 #3
0
		public void ReduceColor()
		{
			var img = Properties.Resources.TestImageColor;
			var pix = img.Bitmap32ToPixels().Flat();
			var oct = new OctTree();
			foreach(var c in pix)
			{
				oct.Add(c);
			}
			Assert.IsTrue(oct.LeafCount > 0);
			var tabla = oct.Read();
			var bmptest = img.ToIndexFormat(tabla);
			System.Windows.Forms.Clipboard.SetImage(bmptest);
		}