public static OffsetImage LoadImage( string fullFileName , int startx, int starty , int width, int height ) { float scale = 1; Image raw = new Bitmap(fullFileName); if (width == 0) { width = raw.Width; } if (height == 0) { height = raw.Height; } int rltwidth = Convert.ToInt32(Math.Ceiling(width * scale)); int rltheight = Convert.ToInt32(Math.Ceiling(height * scale)); Bitmap rlt = new Bitmap(rltwidth, rltheight); Graphics g = Graphics.FromImage(rlt); PointF ul = new PointF(0, 0); PointF ur = new PointF(rltwidth, 0); PointF ll = new PointF(0, rltheight); PointF[] imgscale = new PointF[] { ul, ur, ll }; Rectangle portion = new Rectangle(startx, starty, width, height); g.DrawImage(raw, imgscale, portion, GraphicsUnit.Pixel); g.Dispose(); OffsetImage oi = OffsetImage.New(rlt); return(oi); }
public static OffsetImage New(Bitmap img) { OffsetImage oi = new OffsetImage(); oi.Source = img; return(oi); }
public static void DrawString(ref OffsetImage target, string text, Font font, Brush brush, RotateMatrix rm) { SizeF size = new SizeF(); Bitmap img = new Bitmap(1, 1); Graphics g = Graphics.FromImage(img); size = g.MeasureString(text, font); DrawString(ref target, text, size, font, brush, rm); }
public static void DrawString(ref OffsetImage target, string text, SizeF stringSize, Font font, Brush brush, RotateMatrix rm) { //RotateMatrix rm = RenderHelper.Rotate(angle, stringSize.Width / 2, stringSize.Height / 2, stringSize.Width, stringSize.Height, 1, 1, 0, 0, drawOffsetX, drawOffsetY); Bitmap imgstr = new Bitmap((int)stringSize.Width, (int)stringSize.Height); Graphics gstr = Graphics.FromImage(imgstr); gstr.DrawString(text, font, brush, new PointF(0, 0)); DrawImage(ref target, imgstr, rm); }
protected void DrawImage(OffsetImage img, double angle, double centerX, double centerY, double scaleX, double scaleY, double shearX, double shearY, double drawOffsetX, double drawOffsetY) { //Graphics g = Graphics.FromImage(BufferImage.Source); if (RenderHelper.IsRectOverRect(new RectangleF((float)drawOffsetX, (float)drawOffsetY, img.Width, img.Height), Portion)) { RotateMatrix rm = RenderHelper.Rotate(angle, centerX, centerY, img.Width, img.Height, scaleX, scaleY, shearX, shearY, drawOffsetX, drawOffsetY); lock (BufferImageLock) { img.zIndex = RenderIndex; RenderHelper.DrawImage(ref BufferImage, img, rm); } } }
public static void DrawString(Graphics g, OffsetImage target, string text, Font font, Brush brush, RotateMatrix matrix, PointF location) { if (g != null) { g = Graphics.FromImage(new Bitmap(1, 1)); } SizeF sz = g.MeasureString(text, font); Bitmap iTemp = new Bitmap((int)sz.Width, (int)sz.Height); Graphics gTemp = Graphics.FromImage(iTemp); gTemp.DrawString(text, font, brush, 0, 0); gTemp.Dispose(); DrawImage(ref target, iTemp, matrix); DrawImage(g, target, location); }
public static void DrawImage(Graphics g, OffsetImage oi, PointF location) { float x = 0, y = 0; x = location.X + oi.Offset.X; y = location.Y + oi.Offset.Y; oi.Position = new PointF(x, y); oi.IsDrawn = true; g.SmoothingMode = SmoothingMode.AntiAlias; g.CompositingQuality = CompositingQuality.HighQuality; //Matrix m = new Matrix(); //m.RotateAt(-90, new PointF(portion.Width/2, portion.Height/2)); //g.Transform = m; g.DrawImage(oi.Source, new PointF(0, 0)); }
public RenderForm() { int num = Math.Max(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height); BufferSize = new Size(num, num); Portion = new Rectangle(0, 0, Width, Height); BufferImage = OffsetImage.New(new Bitmap(BufferSize.Width, BufferSize.Height)); UpdatePortion(00, 00, Width, Height); Load += new EventHandler(MainForm_Load); Paint += new PaintEventHandler(MainForm_Paint); Resize += new EventHandler(MainForm_Resize); KeyDown += new KeyEventHandler(RenderForm_KeyDown); KeyUp += new KeyEventHandler(RenderForm_KeyUp); MouseMove += new MouseEventHandler(RenderForm_MouseMove); MouseDown += new MouseEventHandler(RenderForm_MouseDown); MouseUp += new MouseEventHandler(RenderForm_MouseUp); MouseDoubleClick += new MouseEventHandler(RenderForm_MouseDoubleClick); }
public static void DrawImage(Graphics g, OffsetImage oi) { DrawImage(g, oi, new PointF(0, 0)); }
public static void DrawImage(ref OffsetImage oi, Bitmap content, RotateMatrix matrix) { DrawImage(ref oi.Source, content, matrix); }
public static void ClearRegion(Graphics g, OffsetImage oi) { ClearRegion(g, oi, Brushes.Blue); }
public static void ClearRegion(Graphics g, OffsetImage oi, Color c) { SolidBrush sbrush = new SolidBrush(c); ClearRegion(g, oi, sbrush); }
public static void ClearRegion(Graphics g, OffsetImage oi, Brush b) { g.FillRectangle(b, oi.ActualBounds); }
public static void DrawImage(ref OffsetImage oi, OffsetImage content, RotateMatrix matrix) { //oi.Matrix = matrix; content.Matrix = matrix; content.RenderedSource = DrawImage(ref oi.Source, content.Source, matrix); }
protected void DrawImage(OffsetImage img, double angle, double x, double y) { DrawImage(img, angle, img.Width / 2, img.Height / 2, 1, 1, 0, 0, x, y); }
public static OffsetImage New(Bitmap img) { OffsetImage oi = new OffsetImage(); oi.Source = img; return oi; }