Ejemplo n.º 1
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);
		}
Ejemplo n.º 2
0
        public static GraphicsContainer Rotate(Graphics g, float angle, PointF center)
        {
            GraphicsContainer gcr = g.BeginContainer();
            RotateMatrix      m   = Rotate(angle, center.X, center.Y);

            g.Transform = m.Matrix;
            return(gcr);
        }
Ejemplo n.º 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);
		}
Ejemplo n.º 4
0
 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);
         }
     }
 }
Ejemplo n.º 5
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);
		}
Ejemplo n.º 6
0
        protected void DrawString(string text, Font font, Brush brush, double angle, double drawOffsetX, double drawOffsetY)
        {
            Graphics g  = Graphics.FromImage(BufferImage.Source);
            SizeF    sz = g.MeasureString(text, font);

            if (RenderHelper.IsRectOverRect(new RectangleF((float)drawOffsetX, (float)drawOffsetY, sz.Width, sz.Height), Portion))
            {
                RotateMatrix rm = RenderHelper.Rotate(angle, sz.Width / 2, sz.Height / 2, sz.Width, sz.Height, 1, 1, 0, 0, drawOffsetX, drawOffsetY);
                lock (BufferImageLock)
                {
                    RenderHelper.DrawString(ref BufferImage, text, sz, font, brush, rm);
                    //Image imgstr = new Bitmap((int)sz.Width, (int)sz.Height);
                    //Graphics gstr = Graphics.FromImage(imgstr);
                    //gstr.DrawString(text, font, brush, new PointF(0, 0));
                    //RenderHelper.DrawImage(ref BufferImage, imgstr, rm);
                }
            }
            g.Dispose();
        }
Ejemplo n.º 7
0
        public static Bitmap DrawImage(ref Bitmap target, Bitmap content, RotateMatrix matrix)
        {
            Bitmap temp = null;

            try
            {
                if (matrix.IsBiggerEqualTo(target.Size))
                {
                    target.Dispose();
                    target = matrix.GetNewImage();
                }
                temp = new Bitmap((int)matrix.ActualSize.Width, (int)matrix.ActualSize.Height);
                PointF   offsetPoint = new PointF(matrix.AbsoluteOffset.X + matrix.RelativeOffset.X, matrix.AbsoluteOffset.Y + matrix.RelativeOffset.Y);
                Graphics g           = Graphics.FromImage(temp);
                g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
                g.InterpolationMode  = System.Drawing.Drawing2D.InterpolationMode.HighQualityBilinear;
                g.SmoothingMode      = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                g.Transform          = matrix.Matrix;
                g.DrawImage(content, new Point(0, 0));
                if (DrawActualBounds)
                {
                    g.DrawRectangle(Pens.Red, 0, 0, content.Width, content.Height);
                }
                g.Dispose();
                g = Graphics.FromImage(target);
                g.DrawImage(temp, offsetPoint);
                if (DrawActualBounds)
                {
                    g.DrawRectangle(Pens.Maroon, offsetPoint.X, offsetPoint.Y, matrix.ActualSize.Width, matrix.ActualSize.Height);
                }
                g.Dispose();
            }
            catch (Exception e)
            {
                Exceptions.LogOnly(e);
            }
            return(temp);
        }
Ejemplo n.º 8
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);
		}
Ejemplo n.º 9
0
		public static RotateMatrix Rotate(
			double angle
			, double centerX
			, double centerY
			, double width
			, double height
			, double scaleX
			, double scaleY
			, double shearX
			, double shearY
			, double drawOffsetX
			, double drawOffsetY
		)
		{
			float angleF = (float)angle;
			float centerXF = (float)centerX;
			float centerYF = (float)centerY;
			float widthF = (float)width;
			float heightF = (float)height;
			float scaleXF = (float)scaleX;
			float scaleYF = (float)scaleY;
			float shearXF = (float)shearX;
			float shearYF = (float)shearY;
			float drawOffsetXF = (float)drawOffsetX;
			float drawOffsetYF = (float)drawOffsetY;

			PointF offset = new PointF();
			PointF ur = new PointF();
			Matrix matrix = new Matrix();
			PointF center = new PointF(centerXF, centerYF);
			angleF = angleF % 360;
			if (angleF < 0)
			{
				angleF += 360;
			}
			if (angleF % 90 == 0)
			{
				angleF += 0.01f;
			}

			widthF = centerXF * 2 * scaleXF;
			heightF = centerYF * 2 * scaleYF;
			matrix.Scale(scaleXF, scaleYF);
			matrix.Shear(shearXF, shearYF);
			matrix.RotateAt(angleF, center);

			offset.X = matrix.OffsetX;
			offset.Y = matrix.OffsetY;
			float rs, rc;
			rs = (float)Math.Sin(angleF * Math.PI / 180);
			rc = (float)Math.Cos(angleF * Math.PI / 180);
			ur.X = rc * widthF;
			ur.Y = rs * widthF;
			ur.X += matrix.OffsetX;
			ur.Y += matrix.OffsetY;
			angleF = angleF % 360;
			if (angleF >= 0 && angleF <= 90)
			{
				offset.X = ur.X - widthF;
				offset.Y = -matrix.OffsetY;
			}
			else if (angleF > 90 && angleF < 180)
			{
				offset.X = -widthF + matrix.OffsetX;
				offset.Y = ur.Y - heightF;
			}
			else if (angleF >= 180 && angleF <= 270)
			{
				offset.X = -ur.X;
				offset.Y = matrix.OffsetY - heightF;
			}
			else
			{
				offset.X = -matrix.OffsetX;
				offset.Y = -ur.Y;
			}

			matrix.RotateAt(-angleF, center);
			matrix.Translate(offset.X / scaleXF, offset.Y / scaleYF);
			//matrix.Translate(offset.X / scaleXF + drawOffsetXF / scaleXF, offset.Y / scaleYF + drawOffsetYF / scaleYF);
			matrix.RotateAt(angleF, center);
			RotateMatrix rm = new RotateMatrix(matrix, angleF, -offset.X, -offset.Y, widthF, heightF);
			rm.AbsoluteOffset = new PointF(drawOffsetXF, drawOffsetYF);
			return rm;
		}
Ejemplo n.º 10
0
		public static Bitmap DrawImage(ref Bitmap target, Bitmap content, RotateMatrix matrix)
		{
			Bitmap temp = null;
			try
			{
				if (matrix.IsBiggerEqualTo(target.Size))
				{
					target.Dispose();
					target = matrix.GetNewImage();
				}
				temp = new Bitmap((int)matrix.ActualSize.Width, (int)matrix.ActualSize.Height);
				PointF offsetPoint = new PointF(matrix.AbsoluteOffset.X + matrix.RelativeOffset.X, matrix.AbsoluteOffset.Y + matrix.RelativeOffset.Y);
				Graphics g = Graphics.FromImage(temp);
				g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
				g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBilinear;
				g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
				g.Transform = matrix.Matrix;
				g.DrawImage(content, new Point(0, 0));
				if (DrawActualBounds)
				{
					g.DrawRectangle(Pens.Red, 0, 0, content.Width, content.Height);
				}
				g.Dispose();
				g = Graphics.FromImage(target);
				g.DrawImage(temp, offsetPoint);
				if (DrawActualBounds)
				{
					g.DrawRectangle(Pens.Maroon, offsetPoint.X, offsetPoint.Y, matrix.ActualSize.Width, matrix.ActualSize.Height);
				}
				g.Dispose();
			}
			catch (Exception e)
			{
				Exceptions.LogOnly(e);
			}
			return temp;
		}
Ejemplo n.º 11
0
 public static void DrawImage(ref OffsetImage oi, Bitmap content, RotateMatrix matrix)
 {
     DrawImage(ref oi.Source, content, matrix);
 }
Ejemplo n.º 12
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);
        }
Ejemplo n.º 13
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);
        }
Ejemplo n.º 14
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);
        }
Ejemplo n.º 15
0
        public static RotateMatrix Rotate(
            double angle
            , double centerX
            , double centerY
            , double width
            , double height
            , double scaleX
            , double scaleY
            , double shearX
            , double shearY
            , double drawOffsetX
            , double drawOffsetY
            )
        {
            float angleF       = (float)angle;
            float centerXF     = (float)centerX;
            float centerYF     = (float)centerY;
            float widthF       = (float)width;
            float heightF      = (float)height;
            float scaleXF      = (float)scaleX;
            float scaleYF      = (float)scaleY;
            float shearXF      = (float)shearX;
            float shearYF      = (float)shearY;
            float drawOffsetXF = (float)drawOffsetX;
            float drawOffsetYF = (float)drawOffsetY;

            PointF offset = new PointF();
            PointF ur     = new PointF();
            Matrix matrix = new Matrix();
            PointF center = new PointF(centerXF, centerYF);

            angleF = angleF % 360;
            if (angleF < 0)
            {
                angleF += 360;
            }
            if (angleF % 90 == 0)
            {
                angleF += 0.01f;
            }

            widthF  = centerXF * 2 * scaleXF;
            heightF = centerYF * 2 * scaleYF;
            matrix.Scale(scaleXF, scaleYF);
            matrix.Shear(shearXF, shearYF);
            matrix.RotateAt(angleF, center);

            offset.X = matrix.OffsetX;
            offset.Y = matrix.OffsetY;
            float rs, rc;

            rs     = (float)Math.Sin(angleF * Math.PI / 180);
            rc     = (float)Math.Cos(angleF * Math.PI / 180);
            ur.X   = rc * widthF;
            ur.Y   = rs * widthF;
            ur.X  += matrix.OffsetX;
            ur.Y  += matrix.OffsetY;
            angleF = angleF % 360;
            if (angleF >= 0 && angleF <= 90)
            {
                offset.X = ur.X - widthF;
                offset.Y = -matrix.OffsetY;
            }
            else if (angleF > 90 && angleF < 180)
            {
                offset.X = -widthF + matrix.OffsetX;
                offset.Y = ur.Y - heightF;
            }
            else if (angleF >= 180 && angleF <= 270)
            {
                offset.X = -ur.X;
                offset.Y = matrix.OffsetY - heightF;
            }
            else
            {
                offset.X = -matrix.OffsetX;
                offset.Y = -ur.Y;
            }

            matrix.RotateAt(-angleF, center);
            matrix.Translate(offset.X / scaleXF, offset.Y / scaleYF);
            //matrix.Translate(offset.X / scaleXF + drawOffsetXF / scaleXF, offset.Y / scaleYF + drawOffsetYF / scaleYF);
            matrix.RotateAt(angleF, center);
            RotateMatrix rm = new RotateMatrix(matrix, angleF, -offset.X, -offset.Y, widthF, heightF);

            rm.AbsoluteOffset = new PointF(drawOffsetXF, drawOffsetYF);
            return(rm);
        }
Ejemplo n.º 16
0
        public static void Rotate(GraphicsPath gp, float angle, PointF center)
        {
            RotateMatrix m = Rotate(angle, center.X, center.Y);

            gp.Transform(m.Matrix);
        }
Ejemplo n.º 17
0
		public static void DrawImage(ref OffsetImage oi, Bitmap content, RotateMatrix matrix)
		{
			DrawImage(ref oi.Source, content, matrix);
		}
Ejemplo n.º 18
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);
 }