override protected bool Save(Image image, Drawable drawable, string filename) { var writer = new BinaryWriter(File.Open(filename, FileMode.Create)); var rgn = new PixelRgn(drawable, false, false); for (IntPtr pr = PixelRgn.Register(rgn); pr != IntPtr.Zero; pr = PixelRgn.Process(pr)) { } writer.Close(); return(true); }
public void Render(Image image, Drawable drawable) { var src = new PixelRgn(drawable, false, false); PixelRgn.Register(src); var trimColor = GetTrimColor(src, drawable); var tb = GetLowerUpper(trimColor, src.Rows, "top", "bottom"); var lr = GetLowerUpper(trimColor, src.Columns, "left", "right"); var croppingArea = new Rectangle(lr.Item1, tb.Item1, lr.Item2, tb.Item2); if (croppingArea != image.Bounds) { image.Crop(croppingArea); } }