Ejemplo n.º 1
0
		IndexedBitmap CreateImage()
		{
			var image = new IndexedBitmap (100, 100, 8);
			var pal = new Palette (Palette.GetEgaPalette ());
			
			// must have at least 256 colors for an 8-bit bitmap
			while (pal.Count < 256)
				pal.Add (Color.Black);
			image.Palette = pal;
			var bd = image.Lock ();
			
			unsafe {
				int col = 0;
				byte* brow = (byte*)bd.Data;
				for (int y = 0; y < image.Size.Height; y++) {
					byte* b = brow;
					for (int x = 0; x < image.Size.Width; x++) {
						if (col >= pal.Count) 
							col = 0;
						*b = (byte)col++;
						b++;
					}
					brow += bd.ScanWidth;
				}
			}
			image.Unlock (bd);
			return image;
			
		}
Ejemplo n.º 2
0
		IndexedBitmap CreateImage()
		{
			var image = new IndexedBitmap(100, 100, 8, Generator);
			var ega = Palette.GetEgaPalette();
			var pal = new Palette(ega);
			
			// must have at least 256 colors for an 8-bit bitmap
			while (pal.Count < 256)
				pal.Add(Colors.Black);
			image.Palette = pal;
			using (var bd = image.Lock())
			{
				unsafe
				{
					var brow = (byte*)bd.Data;
					for (int y = 0; y < image.Size.Height; y++)
					{
						byte* b = brow;
						var col = -y;
						for (int x = 0; x < image.Size.Width; x++)
						{
							while (col < 0)
								col = ega.Count + col;
							while (col >= ega.Count)
								col -= ega.Count;
							*b = (byte)col++;
							b++;
						}
						brow += bd.ScanWidth;
					}
				}
			}
			return image;
			
		}