示例#1
0
        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);
        }
示例#2
0
        public static OffsetImage New(Bitmap img)
        {
            OffsetImage oi = new OffsetImage();

            oi.Source = img;
            return(oi);
        }
示例#3
0
		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);
		}
示例#4
0
		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);
		}
示例#5
0
        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);
        }
示例#6
0
        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);
        }
示例#7
0
文件: RenderForm.cs 项目: mind0n/hive
 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);
         }
     }
 }
示例#8
0
		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);
		}
示例#9
0
		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));
		}
示例#10
0
        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);
        }
示例#11
0
        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));
        }
示例#12
0
文件: RenderForm.cs 项目: mind0n/hive
        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);
        }
示例#13
0
		public static void DrawImage(Graphics g, OffsetImage oi)
		{
			DrawImage(g, oi, new PointF(0, 0));
		}
示例#14
0
 public static void DrawImage(ref OffsetImage oi, Bitmap content, RotateMatrix matrix)
 {
     DrawImage(ref oi.Source, content, matrix);
 }
示例#15
0
 public static void ClearRegion(Graphics g, OffsetImage oi)
 {
     ClearRegion(g, oi, Brushes.Blue);
 }
示例#16
0
        public static void ClearRegion(Graphics g, OffsetImage oi, Color c)
        {
            SolidBrush sbrush = new SolidBrush(c);

            ClearRegion(g, oi, sbrush);
        }
示例#17
0
		public static void ClearRegion(Graphics g, OffsetImage oi, Brush b)
		{
			g.FillRectangle(b, oi.ActualBounds);
		}
示例#18
0
		public static void ClearRegion(Graphics g, OffsetImage oi, Color c)
		{
			SolidBrush sbrush = new SolidBrush(c);
			ClearRegion(g, oi, sbrush);
		}
示例#19
0
		public static void ClearRegion(Graphics g, OffsetImage oi)
		{
			ClearRegion(g, oi, Brushes.Blue);
		}
示例#20
0
 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);
 }
示例#21
0
 public static void ClearRegion(Graphics g, OffsetImage oi, Brush b)
 {
     g.FillRectangle(b, oi.ActualBounds);
 }
示例#22
0
 public static void DrawImage(Graphics g, OffsetImage oi)
 {
     DrawImage(g, oi, new PointF(0, 0));
 }
示例#23
0
		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);
		}
示例#24
0
文件: RenderForm.cs 项目: mind0n/hive
		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);
		}
示例#25
0
文件: RenderForm.cs 项目: mind0n/hive
 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);
 }
示例#26
0
文件: RenderForm.cs 项目: mind0n/hive
		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);
				}
			}
		}
示例#27
0
		public static void DrawImage(ref OffsetImage oi, Bitmap content, RotateMatrix matrix)
		{
			DrawImage(ref oi.Source, content, matrix);
		}
示例#28
0
		public static OffsetImage New(Bitmap img)
		{
			OffsetImage oi = new OffsetImage();
			oi.Source = img;
			return oi;
		}