public static bool WritePixelImageAsPng(Stream s, IPixelImage img, Action <int> reportProgress, Func <bool> shouldCancel) { var imgInfo = new ImageInfo(img.Width, img.Height, 8, true); var writer = new PngWriter(s, imgInfo); for (var y = 0; y < img.Height; y++) { if (shouldCancel()) { return(false); } var line = new ImageLine(imgInfo); for (var x = 0; x < img.Width; x++) { var c = img.GetPixel(x, y); var offset = x * 4; line.Scanline[offset] = c.R; line.Scanline[offset + 1] = c.G; line.Scanline[offset + 2] = c.B; line.Scanline[offset + 3] = c.A; } writer.WriteRow(line, y); reportProgress((y * 100) / img.Height); } writer.End(); return(true); }
public static Bitmap ToBitmap(IPixelImage map) { var b = new Bitmap(map.Width, map.Height); for (var y = 0; y < map.Height; y++) { for (var x = 0; x < map.Width; x++) { b.SetPixel(x, y, map.GetPixel(x, y)); } } return(b); }
public static Bitmap GenerateMinimap(IPixelImage map) { int width, height; if (map.Width > map.Height) { width = 252; height = (int)(252 * (map.Height / (float)map.Width)); } else { height = 252; width = (int)(252 * (map.Width / (float)map.Height)); } var wrapper = new NearestNeighbourWrapper(map, width, height); return(ToBitmap(wrapper)); }
public NearestNeighbourWrapper(IPixelImage source, int width, int height) { this.source = source; this.Width = width; this.Height = height; }
public BilinearWrapper(IPixelImage source, int width, int height) { this.source = source; this.Width = width; this.Height = height; }
public NearestNeighbourPaletteWrapper(IPixelImage source, IPalette palette) { this.source = source; this.palette = palette; }