当前位置: 首页>>代码示例>>C#>>正文


C# TextureBrush.TranslateTransform方法代码示例

本文整理汇总了C#中System.Drawing.TextureBrush.TranslateTransform方法的典型用法代码示例。如果您正苦于以下问题:C# TextureBrush.TranslateTransform方法的具体用法?C# TextureBrush.TranslateTransform怎么用?C# TextureBrush.TranslateTransform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Drawing.TextureBrush的用法示例。


在下文中一共展示了TextureBrush.TranslateTransform方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Draw

        public override void Draw(Paddle onPaddle, Graphics g)
        {
            Rectangle rct = new Rectangle(Point.Empty, onPaddle.Getrect().Size);
            using (TextureBrush tb = new TextureBrush(drawimage, WrapMode.Tile,rct))
            {

                //calculate length to translate.
                int translateamount = (int) (((float)drawimage.Width / 1000f) * DateTime.Now.Millisecond);
                tb.TranslateTransform(translateamount, 0);
                g.FillRectangle(tb, onPaddle.Getrect());
            }
        }
开发者ID:BCProgramming,项目名称:BASeBlock,代码行数:12,代码来源:DeflectorBehaviour.cs

示例2: dropShadow

        public static Bitmap dropShadow(Bitmap original)
        {
            Bitmap dest = new Bitmap(original.Width + shadowSize, original.Height + shadowSize);
            Graphics g = Graphics.FromImage(dest);

            TextureBrush shadowRightBrush = new TextureBrush(shadowRight, WrapMode.Tile);
            TextureBrush shadowDownBrush = new TextureBrush(shadowDown, WrapMode.Tile);

            shadowRightBrush.TranslateTransform(original.Width - shadowSize, 0);
            shadowDownBrush.TranslateTransform(0, original.Height - shadowSize);

            Rectangle shadowDownRectangle = new Rectangle(
                shadowSize,                               // X
                original.Height, //- shadowSize,                            // Y
                original.Width - shadowSize,// - (shadowSize * 2 + shadowMargin),        // width (stretches)
                shadowSize                                               // height
                );

            Rectangle shadowRightRectangle = new Rectangle(
                original.Width,// - shadowSize,                             // X
                shadowSize, // + shadowMargin,                      // Y
                shadowSize,                                     // width
                original.Height -shadowSize // - (shadowSize * 2 + shadowMargin)        // height (stretches)
                );

            // And draw the shadow on the right and at the bottom.

            g.FillRectangle(shadowDownBrush, shadowDownRectangle);
            g.FillRectangle(shadowRightBrush, shadowRightRectangle);

            // 隅っこ三つ
            g.DrawImage(shadowTopRight, new Rectangle(original.Width, 0, shadowSize, shadowSize));
            g.DrawImage(shadowDownRight, new Rectangle(original.Width, original.Height, shadowSize, shadowSize));
            g.DrawImage(shadowDownLeft, new Rectangle(0, original.Height, shadowSize, shadowSize));

            g.DrawImage(original, new Rectangle(new Point(0, 0), new Size(original.Width, original.Height)));

            shadowDownBrush.Dispose();
            shadowRightBrush.Dispose();

            shadowDownBrush = null;
            shadowRightBrush = null;

            return dest;
        }
开发者ID:akipponn,项目名称:FriendsOnDesktop,代码行数:45,代码来源:Shadow.cs

示例3: DrawImageTiled

		public static void DrawImageTiled(Graphics g, Image image, Rectangle destRect)
		{
			using (ImageAttributes attr = new ImageAttributes())
			{
				// initialize wrap mode to tile
				attr.SetWrapMode(System.Drawing.Drawing2D.WrapMode.Tile);

				// create the texture brush 
				using (TextureBrush b = new TextureBrush(image, new Rectangle(0, 0, image.Width, image.Height), attr))
				{
					// adjust the origin of the brush to coincide with the destination rect 
					b.TranslateTransform((float)destRect.Left, (float)destRect.Top);

					// fill the area using the texture 
					g.FillRectangle(b, destRect);
				}
			}
		}
开发者ID:rodrigos01,项目名称:toggldesktop,代码行数:18,代码来源:DrawUtil.cs

示例4: DrawMagnifier

        private void DrawMagnifier(Graphics g)
        {
            Point mousePos = InputManager.MousePosition0Based;
            Rectangle currentScreenRect0Based = CaptureHelpers.ScreenToClient(Screen.FromPoint(InputManager.MousePosition).Bounds);
            int offsetX = 10, offsetY = 10, infoTextOffset = 0, infoTextPadding = 3;
            Rectangle infoTextRect = Rectangle.Empty;
            string infoText = string.Empty;

            if (Config.ShowInfo)
            {
                infoTextOffset = 10;

                CurrentPosition = InputManager.MousePosition;

                infoText = GetInfoText();
                Size textSize = g.MeasureString(infoText, infoFont).ToSize();
                infoTextRect.Size = new Size(textSize.Width + infoTextPadding * 2, textSize.Height + infoTextPadding * 2);
            }

            using (Bitmap magnifier = Magnifier(SurfaceImage, mousePos, Config.MagnifierPixelCount, Config.MagnifierPixelCount, Config.MagnifierPixelSize))
            {
                int x = mousePos.X + offsetX;

                if (x + magnifier.Width > currentScreenRect0Based.Right)
                {
                    x = mousePos.X - offsetX - magnifier.Width;
                }

                int y = mousePos.Y + offsetY;

                if (y + magnifier.Height + infoTextOffset + infoTextRect.Height > currentScreenRect0Based.Bottom)
                {
                    y = mousePos.Y - offsetY - magnifier.Height - infoTextOffset - infoTextRect.Height;
                }

                if (Config.ShowInfo)
                {
                    infoTextRect.Location = new Point(x + (magnifier.Width / 2) - (infoTextRect.Width / 2), y + magnifier.Height + infoTextOffset);
                    DrawInfoText(g, infoText, infoTextRect, 3);
                }

                g.SetHighQuality();

                using (TextureBrush brush = new TextureBrush(magnifier))
                {
                    brush.TranslateTransform(x, y);

                    if (Config.UseSquareMagnifier)
                    {
                        g.FillRectangle(brush, x, y, magnifier.Width, magnifier.Height);
                        g.DrawRectangleProper(Pens.White, x - 1, y - 1, magnifier.Width + 2, magnifier.Height + 2);
                        g.DrawRectangleProper(Pens.Black, x, y, magnifier.Width, magnifier.Height);
                    }
                    else
                    {
                        g.FillEllipse(brush, x, y, magnifier.Width, magnifier.Height);
                        g.DrawEllipse(Pens.White, x - 1, y - 1, magnifier.Width + 2, magnifier.Height + 2);
                        g.DrawEllipse(Pens.Black, x, y, magnifier.Width, magnifier.Height);
                    }
                }
            }
        }
开发者ID:Rapti,项目名称:ShareX,代码行数:62,代码来源:RectangleRegion.cs

示例5: setPaint

        public override void setPaint(java.awt.Paint paint)
        {
            if (paint is java.awt.Color)
            {
                setColor((java.awt.Color)paint);
                return;
            }

            if (paint == null || this.javaPaint == paint)
            {
                return;
            }
            this.javaPaint = paint;

            if (paint is java.awt.GradientPaint)
            {
                java.awt.GradientPaint gradient = (java.awt.GradientPaint)paint;
                LinearGradientBrush linear;
                if (gradient.isCyclic())
                {
                    linear = new LinearGradientBrush(
                        J2C.ConvertPoint(gradient.getPoint1()),
                        J2C.ConvertPoint(gradient.getPoint2()),
                        composite.GetColor(gradient.getColor1()),
                        composite.GetColor(gradient.getColor2()));
                }
                else
                {
                    //HACK because .NET does not support continue gradient like Java else Tile Gradient
                    //that we receize the rectangle very large (factor z) and set 4 color values
                    // a exact solution will calculate the size of the Graphics with the current transform
                    Color color1 = composite.GetColor(gradient.getColor1());
                    Color color2 = composite.GetColor(gradient.getColor2());
                    float x1 = (float)gradient.getPoint1().getX();
                    float x2 = (float)gradient.getPoint2().getX();
                    float y1 = (float)gradient.getPoint1().getY();
                    float y2 = (float)gradient.getPoint2().getY();
                    float diffX = x2 - x1;
                    float diffY = y2 - y1;
                    const float z = 60; //HACK zoom factor, with a larger factor .NET will make the gradient wider.
                    linear = new LinearGradientBrush(
                        new PointF(x1 - z * diffX, y1 - z * diffY),
                        new PointF(x2 + z * diffX, y2 + z * diffY),
                        color1,
                        color1);
                    ColorBlend colorBlend = new ColorBlend(4);
                    Color[] colors = colorBlend.Colors;
                    colors[0] = colors[1] = color1;
                    colors[2] = colors[3] = color2;
                    float[] positions = colorBlend.Positions;
                    positions[1] = z / (2 * z + 1);
                    positions[2] = (z + 1) / (2 * z + 1);
                    positions[3] = 1.0f;
                    linear.InterpolationColors = colorBlend;
                }
                linear.WrapMode = WrapMode.TileFlipXY;
                brush = linear;
                pen.Brush = brush;
                return;
            }

            if (paint is java.awt.TexturePaint)
            {
                java.awt.TexturePaint texture = (java.awt.TexturePaint)paint;
                Bitmap txtr = J2C.ConvertImage(texture.getImage());
                java.awt.geom.Rectangle2D anchor = texture.getAnchorRect();
                TextureBrush txtBrush;
                brush = txtBrush = new TextureBrush(txtr, new Rectangle(0, 0, txtr.Width, txtr.Height), composite.GetImageAttributes());
                txtBrush.TranslateTransform((float)anchor.getX(), (float)anchor.getY());
                txtBrush.ScaleTransform((float)anchor.getWidth() / txtr.Width, (float)anchor.getHeight() / txtr.Height);
                txtBrush.WrapMode = WrapMode.Tile;
                pen.Brush = brush;
                return;
            }

            if (paint is java.awt.LinearGradientPaint) {
                java.awt.LinearGradientPaint gradient = (java.awt.LinearGradientPaint)paint;
                PointF start = J2C.ConvertPoint(gradient.getStartPoint());
                PointF end = J2C.ConvertPoint(gradient.getEndPoint());

                java.awt.Color[] javaColors = gradient.getColors();
                ColorBlend colorBlend;
                Color[] colors;
                bool noCycle = gradient.getCycleMethod() == java.awt.MultipleGradientPaint.CycleMethod.NO_CYCLE;
                if (noCycle) {
                    //HACK because .NET does not support continue gradient like Java else Tile Gradient
                    //that we receize the rectangle very large (factor z) and set 2 additional color values
                    //an exact solution will calculate the size of the Graphics with the current transform
                    float diffX = end.X - start.X;
                    float diffY = end.Y - start.Y;
                    SizeF size = GetSize();
                    //HACK zoom factor, with a larger factor .NET will make the gradient wider.
                    float z = Math.Min(10, Math.Max(size.Width / diffX, size.Height / diffY));
                    start.X -= z * diffX;
                    start.Y -= z * diffY;
                    end.X += z * diffX;
                    end.Y += z * diffY;

                    colorBlend = new ColorBlend(javaColors.Length + 2);
                    colors = colorBlend.Colors;
//.........这里部分代码省略.........
开发者ID:kenasogoo,项目名称:ikvm-fork,代码行数:101,代码来源:graphics.cs

示例6: RenderRowBackground

        protected void RenderRowBackground(
            Graphics g, TextRowVisualStyle style, Rectangle r)
        {
            r.Width--;
            r.Height--;

            using (Brush br = style.Background.GetBrush(r))
                g.FillRectangle(br, r);

            if (_BackgroundImage != null)
            {
                Rectangle sr = r;
                sr.Location = Point.Empty;

                switch (_BackgroundImageLayout)
                {
                    case GridBackgroundImageLayout.TopRight:
                        OffsetRight(ref sr, ref r);
                        g.DrawImage(_BackgroundImage, r, sr, GraphicsUnit.Pixel);
                        break;

                    case GridBackgroundImageLayout.BottomLeft:
                        OffsetBottom(ref sr, ref r);
                        g.DrawImage(_BackgroundImage, r, sr, GraphicsUnit.Pixel);
                        break;

                    case GridBackgroundImageLayout.BottomRight:
                        OffsetRight(ref sr, ref r);
                        OffsetBottom(ref sr, ref r);
                        g.DrawImage(_BackgroundImage, r, sr, GraphicsUnit.Pixel);
                        break;

                    case GridBackgroundImageLayout.Center:
                        RenderImageCentered(g, _BackgroundImage, r);
                        break;

                    case GridBackgroundImageLayout.Stretch:
                        g.DrawImage(_BackgroundImage, r);
                        break;

                    case GridBackgroundImageLayout.Zoom:
                        RenderImageScaled(g, _BackgroundImage, r);
                        break;

                    case GridBackgroundImageLayout.Tile:
                        using (TextureBrush tbr = new TextureBrush(_BackgroundImage))
                        {
                            tbr.TranslateTransform(r.X, r.Y);
                            g.FillRectangle(tbr, r);
                        }
                        break;

                    default:
                        g.DrawImage(_BackgroundImage, r, sr, GraphicsUnit.Pixel);
                        break;
                }
            }
        }
开发者ID:huamanhtuyen,项目名称:VNACCS,代码行数:58,代码来源:GridTextRow.cs

示例7: FileUploadHandler

        public ActionResult FileUploadHandler()
        {
            string[] fileNames = null;
            bool canpass = true;
            string filename = "";
            
            for (int i = 0; i < Request.Files.Count; i++)
            {
                if (canpass)
                {
                    fileNames = new string[Request.Files.Count];
                    canpass = false;
                }
                try
                {
                    IAmazonS3 client;
                    //string logo = "logo2.png";
                    //using (client = new AmazonS3Client(Amazon.RegionEndpoint.USEast1))
                    //{
                    //    GetObjectRequest request = new GetObjectRequest
                    //         {
                    //             BucketName = _bucketName,
                    //             Key = logo
                    //         };
                    //    using (GetObjectResponse response = client.GetObject(request))
                    //    {
                         //   string dest =System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), logo);
                            //if (!System.IO.File.Exists(logo))
                            //{
                            //    response.WriteResponseStreamToFile(dest);
                            //}
                            Image imgg = Image.FromFile(Server.MapPath(@"\Images\others\WaterMark.png"));
                            float f = float.Parse("0.5");
                            Image img = SetImageOpacity(imgg, f);

                            HttpPostedFileBase file = Request.Files[i];
                            using (Image image = Image.FromStream(file.InputStream, true, true))
                          //  using (Image watermarkImage = Image.FromFile(Server.MapPath(@"\Images\others\WaterMark.png")))
                            using (Image watermarkImage = img)
                            using (Graphics imageGraphics = Graphics.FromImage(image))
                            using (TextureBrush watermarkBrush = new TextureBrush(watermarkImage))
                            {
                               // int x = (image.Width / 2 - watermarkImage.Width / 2);
                                int x = 4;
                                int y = image.Height - watermarkImage.Height;
                                //int y = (image.Height / 2 - watermarkImage.Height / 2);
                                watermarkBrush.TranslateTransform(x, y);
                                imageGraphics.FillRectangle(watermarkBrush, new Rectangle(new Point(x, y), new Size(watermarkImage.Width + 1, watermarkImage.Height)));
                            //    image.Save(file.FileName);
                                
                              //  image.Save(@"C:\Users\Irfan\Desktop\logo12.png");

                                

                                //upload on aws
                                string extension = System.IO.Path.GetExtension(file.FileName);
                                filename = "temp" + DateTime.UtcNow.Ticks + extension;
                                image.Save(Server.MapPath(@"\Images\Ads\" + filename));
                                if (file.ContentLength > 0) // accept the file
                                {
                                    AmazonS3Config config = new AmazonS3Config();
                                    config.ServiceURL = "https://s3.amazonaws.com/";
                                    Amazon.S3.IAmazonS3 s3Client = AWSClientFactory.CreateAmazonS3Client(_awsAccessKey, _awsSecretKey, config);

                                    var request2 = new PutObjectRequest()
                                    {
                                        BucketName = _bucketName,
                                        CannedACL = S3CannedACL.PublicRead,//PERMISSION TO FILE PUBLIC ACCESIBLE
                                        Key = _folderName + filename,
                                        //InputStream = file.InputStream//SEND THE FILE STREAM
                                        FilePath = Server.MapPath(@"\Images\Ads\" + filename)
                                    };
                                    s3Client.PutObject(request2);
                                }
                                if (System.IO.File.Exists(Server.MapPath(@"\Images\Ads\" + filename)))
                                {
                                    System.IO.File.Delete(Server.MapPath(@"\Images\Ads\" + filename));
                                }
                            }
                      //  }
                        fileNames[i] = filename;
                    }
               // }
                catch (Exception ex)
                {
                    return Json(new { Message = "Error in saving file" });
                }

            }
            return Json(fileNames);
        }
开发者ID:mubasharali,项目名称:myfiles3,代码行数:91,代码来源:ElectronicsController.cs

示例8: OnPaint

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            bool linkBroken = this.ReferenceBroken;

            Color bgColorBright = Color.White;
            if (this.dragHover) bgColorBright = bgColorBright.MixWith(Color.FromArgb(192, 255, 0), 0.4f);
            else if (this.multiple) bgColorBright = Color.Bisque;
            else if (linkBroken) bgColorBright = Color.FromArgb(255, 128, 128);

            bool darkBg = false;
            Rectangle rectImage = new Rectangle(this.rectPanel.X + 2, this.rectPanel.Y + 2, this.rectPanel.Width - 4, this.rectPanel.Height - 4);
            if (this.prevImage == null)
            {
                if (this.ReadOnly || !this.Enabled)
                    e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(64, bgColorBright)), rectImage);
                else
                    e.Graphics.FillRectangle(new SolidBrush(bgColorBright), rectImage);
            }
            else
            {
                Color brightChecker = this.prevImageLum > 0.5f ? Color.FromArgb(48, 48, 48) : Color.FromArgb(224, 224, 224);
                Color darkChecker = this.prevImageLum > 0.5f ? Color.FromArgb(32, 32, 32) : Color.FromArgb(192, 192, 192);

                if (this.dragHover)
                {
                    brightChecker = brightChecker.MixWith(Color.FromArgb(192, 255, 0), 0.4f);
                    darkChecker = darkChecker.MixWith(Color.FromArgb(192, 255, 0), 0.4f);
                }
                else if (this.multiple)
                {
                    brightChecker = brightChecker.MixWith(Color.FromArgb(255, 200, 128), 0.4f);
                    darkChecker = darkChecker.MixWith(Color.FromArgb(255, 200, 128), 0.4f);
                }
                else if (linkBroken)
                {
                    brightChecker = brightChecker.MixWith(Color.FromArgb(255, 128, 128), 0.4f);
                    darkChecker = darkChecker.MixWith(Color.FromArgb(255, 128, 128), 0.4f);
                }

                e.Graphics.FillRectangle(new HatchBrush(HatchStyle.LargeCheckerBoard, brightChecker, darkChecker), rectImage);

                TextureBrush bgImageBrush = new TextureBrush(this.prevImage);
                bgImageBrush.ResetTransform();
                bgImageBrush.TranslateTransform(rectImage.X, rectImage.Y);
                e.Graphics.FillRectangle(bgImageBrush, rectImage);

                darkBg = this.prevImageLum > 0.5f;
                if (this.ReadOnly || !this.Enabled)
                {
                    e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(128, SystemColors.Control)), rectImage);
                    darkBg = (this.prevImageLum + SystemColors.Control.GetLuminance()) * 0.5f < 0.5f;
                }
            }

            StringFormat format = StringFormat.GenericDefault;
            format.Alignment = StringAlignment.Center;
            format.LineAlignment = StringAlignment.Center;
            format.Trimming = StringTrimming.EllipsisPath;
            SizeF textSize = e.Graphics.MeasureString(
                this.ReferenceName ?? "null",
                SystemFonts.DefaultFont,
                new SizeF(this.rectPanel.Width, this.rectPanel.Height),
                format);

            Rectangle rectText;
            if (this.prevImage == null)
                rectText = this.rectPanel;
            else
                rectText = new Rectangle(
                    this.rectPanel.X, this.rectPanel.Bottom - (int)textSize.Height - 2, this.rectPanel.Width, (int)textSize.Height);

            if (this.prevImage != null)
            {
                e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(192, bgColorBright)),
                    rectText.X + rectText.Width / 2 - textSize.Width / 2 - 1,
                    rectText.Y + rectText.Height / 2 - textSize.Height / 2 - 2,
                    textSize.Width + 1,
                    textSize.Height + 2);
            }
            e.Graphics.DrawString(
                this.ReferenceName ?? "null",
                SystemFonts.DefaultFont,
                new SolidBrush(this.Enabled ? SystemColors.ControlText : SystemColors.GrayText),
                rectText,
                format);

            ControlRenderer.DrawBorder(e.Graphics,
                this.rectPanel,
                BorderStyle.ContentBox,
                (this.ReadOnly || !this.Enabled) ? BorderState.Disabled : BorderState.Normal);

            ButtonState buttonStateSet = ButtonState.Disabled;
            if(!this.ReadOnly && this.Enabled)
            {
                if (this.buttonSetPressed) buttonStateSet = ButtonState.Pressed;
                else if (this.buttonSetHovered) buttonStateSet = ButtonState.Hot;
                else buttonStateSet = ButtonState.Normal;
            }
//.........这里部分代码省略.........
开发者ID:BraveSirAndrew,项目名称:duality,代码行数:101,代码来源:ObjectRefPropertyEditor.cs

示例9: DrawCursorGraphics

        private void DrawCursorGraphics(Graphics g)
        {
            Point mousePos = InputManager.MousePosition0Based;
            Rectangle currentScreenRect0Based = CaptureHelpers.GetActiveScreenBounds0Based();
            int cursorOffsetX = 10, cursorOffsetY = 10, itemGap = 10, itemCount = 0;
            Size totalSize = Size.Empty;

            int magnifierPosition = 0;
            Bitmap magnifier = null;

            if (Config.ShowMagnifier)
            {
                if (itemCount > 0) totalSize.Height += itemGap;
                magnifierPosition = totalSize.Height;

                magnifier = Magnifier(backgroundImage, mousePos, Config.MagnifierPixelCount, Config.MagnifierPixelCount, Config.MagnifierPixelSize);
                totalSize.Width = Math.Max(totalSize.Width, magnifier.Width);

                totalSize.Height += magnifier.Height;
                itemCount++;
            }

            int infoTextPadding = 3;
            int infoTextPosition = 0;
            Rectangle infoTextRect = Rectangle.Empty;
            string infoText = "";

            if (Config.ShowInfo)
            {
                if (itemCount > 0) totalSize.Height += itemGap;
                infoTextPosition = totalSize.Height;

                CurrentPosition = InputManager.MousePosition;
                infoText = GetInfoText();
                Size textSize = g.MeasureString(infoText, infoFont).ToSize();
                infoTextRect.Size = new Size(textSize.Width + infoTextPadding * 2, textSize.Height + infoTextPadding * 2);
                totalSize.Width = Math.Max(totalSize.Width, infoTextRect.Width);

                totalSize.Height += infoTextRect.Height;
                itemCount++;
            }

            int x = mousePos.X + cursorOffsetX;

            if (x + totalSize.Width > currentScreenRect0Based.Right)
            {
                x = mousePos.X - cursorOffsetX - totalSize.Width;
            }

            int y = mousePos.Y + cursorOffsetY;

            if (y + totalSize.Height > currentScreenRect0Based.Bottom)
            {
                y = mousePos.Y - cursorOffsetY - totalSize.Height;
            }

            if (Config.ShowMagnifier)
            {
                using (GraphicsQualityManager quality = new GraphicsQualityManager(g))
                using (TextureBrush brush = new TextureBrush(magnifier))
                {
                    brush.TranslateTransform(x, y + magnifierPosition);

                    if (Config.UseSquareMagnifier)
                    {
                        g.FillRectangle(brush, x, y + magnifierPosition, magnifier.Width, magnifier.Height);
                        g.DrawRectangleProper(Pens.White, x - 1, y + magnifierPosition - 1, magnifier.Width + 2, magnifier.Height + 2);
                        g.DrawRectangleProper(Pens.Black, x, y + magnifierPosition, magnifier.Width, magnifier.Height);
                    }
                    else
                    {
                        g.FillEllipse(brush, x, y + magnifierPosition, magnifier.Width, magnifier.Height);
                        g.DrawEllipse(Pens.White, x - 1, y + magnifierPosition - 1, magnifier.Width + 2, magnifier.Height + 2);
                        g.DrawEllipse(Pens.Black, x, y + magnifierPosition, magnifier.Width, magnifier.Height);
                    }
                }
            }

            if (Config.ShowInfo)
            {
                infoTextRect.Location = new Point(x + (totalSize.Width / 2) - (infoTextRect.Width / 2), y + infoTextPosition);
                DrawInfoText(g, infoText, infoTextRect, infoFont, infoTextPadding);
            }
        }
开发者ID:RailTracker,项目名称:ShareX,代码行数:84,代码来源:RectangleRegionForm.cs

示例10: DrawMagnifier

        private void DrawMagnifier(Graphics g)
        {
            Point mousePos = InputManager.MousePosition0Based;
            int offsetX = 10, offsetY = 10;

            if (Config.ShowInfo && AreaManager.IsCurrentAreaValid && AreaManager.CurrentArea.Location == mousePos)
            {
                offsetY = 50;
            }

            using (Bitmap magnifier = Magnifier(SurfaceImage, mousePos, Config.MagnifierPixelCount, Config.MagnifierPixelCount, Config.MagnifierPixelSize))
            {
                int x = mousePos.X + offsetX;

                if (x + magnifier.Width > ScreenRectangle0Based.Width)
                {
                    x = mousePos.X - offsetX - magnifier.Width;
                }

                int y = mousePos.Y + offsetY;

                if (y + magnifier.Height > ScreenRectangle0Based.Height)
                {
                    y = mousePos.Y - offsetY - magnifier.Height;
                }

                g.SetHighQuality();

                using (TextureBrush brush = new TextureBrush(magnifier))
                {
                    brush.TranslateTransform(x, y);
                    g.FillEllipse(brush, x, y, magnifier.Width, magnifier.Height);
                    g.DrawEllipse(Pens.Black, x, y, magnifier.Width, magnifier.Height);
                }
            }
        }
开发者ID:barsv,项目名称:ShareX,代码行数:36,代码来源:RectangleRegion.cs

示例11: ApplyFilter

        /// <summary>
        /// Applies the halftone filter. 
        /// </summary>
        /// <param name="source">
        /// The <see cref="Bitmap"/> to apply the filter to.
        /// </param>
        /// <returns>
        /// The <see cref="Bitmap"/> with the filter applied.
        /// </returns>
        public Bitmap ApplyFilter(Bitmap source)
        {
            // TODO: Make this class implement an interface?
            Bitmap padded = null;
            Bitmap cyan = null;
            Bitmap magenta = null;
            Bitmap yellow = null;
            Bitmap keyline = null;
            Bitmap newImage = null;

            try
            {
                int sourceWidth = source.Width;
                int sourceHeight = source.Height;
                int width = source.Width + this.distance;
                int height = source.Height + this.distance;

                // Draw a slightly larger image, flipping the top/left pixels to prevent
                // jagged edge of output.
                padded = new Bitmap(width, height, PixelFormat.Format32bppPArgb);
                padded.SetResolution(source.HorizontalResolution, source.VerticalResolution);
                using (Graphics graphicsPadded = Graphics.FromImage(padded))
                {
                    graphicsPadded.Clear(Color.White);
                    Rectangle destinationRectangle = new Rectangle(0, 0, sourceWidth + this.distance, source.Height + this.distance);
                    using (TextureBrush tb = new TextureBrush(source))
                    {
                        tb.WrapMode = WrapMode.TileFlipXY;
                        tb.TranslateTransform(this.distance, this.distance);
                        graphicsPadded.FillRectangle(tb, destinationRectangle);
                    }
                }

                // Calculate min and max widths/heights.
                Rectangle rotatedBounds = this.GetBoundingRectangle(width, height);
                int minY = -(rotatedBounds.Height + height);
                int maxY = rotatedBounds.Height + height;
                int minX = -(rotatedBounds.Width + width);
                int maxX = rotatedBounds.Width + width;
                Point center = Point.Empty;

                // Yellow oversaturates the output.
                int offset = this.distance;
                float yellowMultiplier = this.distance * 1.587f;
                float magentaMultiplier = this.distance * 2.176f;
                float multiplier = this.distance * 2.2f;
                float max = this.distance * (float)Math.Sqrt(2);
                float magentaMax = this.distance * (float)Math.Sqrt(1.4545);

                // Bump up the keyline max so that black looks black.
                float keylineMax = max * (float)Math.Sqrt(2);

                // Color sampled process colours from Wikipedia pages.
                // Keyline brush is declared separately.
                Brush cyanBrush = new SolidBrush(Color.FromArgb(0, 183, 235));
                Brush magentaBrush = new SolidBrush(Color.FromArgb(255, 0, 144));
                Brush yellowBrush = new SolidBrush(Color.FromArgb(255, 239, 0));

                // Create our images.
                cyan = new Bitmap(width, height, PixelFormat.Format32bppPArgb);
                magenta = new Bitmap(width, height, PixelFormat.Format32bppPArgb);
                yellow = new Bitmap(width, height, PixelFormat.Format32bppPArgb);
                keyline = new Bitmap(width, height, PixelFormat.Format32bppPArgb);
                newImage = new Bitmap(sourceWidth, sourceHeight, PixelFormat.Format32bppPArgb);

                // Ensure the correct resolution is set.
                cyan.SetResolution(source.HorizontalResolution, source.VerticalResolution);
                magenta.SetResolution(source.HorizontalResolution, source.VerticalResolution);
                yellow.SetResolution(source.HorizontalResolution, source.VerticalResolution);
                keyline.SetResolution(source.HorizontalResolution, source.VerticalResolution);
                newImage.SetResolution(source.HorizontalResolution, source.VerticalResolution);

                // Check bounds against this.
                Rectangle rectangle = new Rectangle(0, 0, width, height);

                using (Graphics graphicsCyan = Graphics.FromImage(cyan))
                using (Graphics graphicsMagenta = Graphics.FromImage(magenta))
                using (Graphics graphicsYellow = Graphics.FromImage(yellow))
                using (Graphics graphicsKeyline = Graphics.FromImage(keyline))
                {
                    // Set the quality properties.
                    graphicsCyan.PixelOffsetMode = PixelOffsetMode.Half;
                    graphicsMagenta.PixelOffsetMode = PixelOffsetMode.Half;
                    graphicsYellow.PixelOffsetMode = PixelOffsetMode.Half;
                    graphicsKeyline.PixelOffsetMode = PixelOffsetMode.Half;

                    graphicsCyan.SmoothingMode = SmoothingMode.AntiAlias;
                    graphicsMagenta.SmoothingMode = SmoothingMode.AntiAlias;
                    graphicsYellow.SmoothingMode = SmoothingMode.AntiAlias;
                    graphicsKeyline.SmoothingMode = SmoothingMode.AntiAlias;

//.........这里部分代码省略.........
开发者ID:ChaseFlorell,项目名称:ImageProcessor,代码行数:101,代码来源:HalftoneFilter.cs

示例12: DrawMagnifier

        private void DrawMagnifier(Graphics g)
        {
            Point mousePos = InputManager.MousePosition0Based;
            Rectangle currentScreenRect0Based = CaptureHelpers.ScreenToClient(Screen.FromPoint(InputManager.MousePosition).Bounds);
            int offsetX = RulerMode ? 20 : 10, offsetY = RulerMode ? 20 : 10;

            if (Config.ShowInfo && ((AreaManager.IsCurrentAreaValid && AreaManager.CurrentArea.Location == mousePos) || OneClickMode))
            {
                offsetY = RulerMode ? 85 : 50;
            }

            using (Bitmap magnifier = Magnifier(SurfaceImage, mousePos, Config.MagnifierPixelCount, Config.MagnifierPixelCount, Config.MagnifierPixelSize))
            {
                int x = mousePos.X + offsetX;

                if (x + magnifier.Width > currentScreenRect0Based.Right)
                {
                    x = mousePos.X - offsetX - magnifier.Width;
                }

                int y = mousePos.Y + offsetY;

                if (y + magnifier.Height > currentScreenRect0Based.Bottom)
                {
                    y = mousePos.Y - offsetY - magnifier.Height;
                }

                g.SetHighQuality();

                using (TextureBrush brush = new TextureBrush(magnifier))
                {
                    brush.TranslateTransform(x, y);
                    g.FillEllipse(brush, x, y, magnifier.Width, magnifier.Height);
                    g.DrawEllipse(Pens.Black, x, y, magnifier.Width, magnifier.Height);
                }
            }
        }
开发者ID:snakems,项目名称:ShareX,代码行数:37,代码来源:RectangleRegion.cs

示例13: GetTextureBrush

 public override RBrush GetTextureBrush(RImage image, RRect dstRect, RPoint translateTransformLocation)
 {
     var brush = new TextureBrush(((ImageAdapter)image).Image, Utils.Convert(dstRect));
     brush.TranslateTransform((float)translateTransformLocation.X, (float)translateTransformLocation.Y);
     return new BrushAdapter(brush, true);
 }
开发者ID:jcaillon,项目名称:YamuiFramework,代码行数:6,代码来源:GraphicsAdapter.cs

示例14: ToGdiPlus

		public static d.Brush ToGdiPlus(this ImageBrush brush, Rect bounds) {
			var img = brush.ImageSource;
			var bt = new BrushTransform(brush, bounds);
			if (bt.DegenerateBrush != null) return bt.DegenerateBrush;

			var viewbox = brush.Viewbox;
			if (brush.ViewboxUnits == BrushMappingMode.RelativeToBoundingBox)
				viewbox.Scale(img.Width, img.Height);
			var viewport = brush.Viewport;
			if (brush.ViewportUnits == BrushMappingMode.RelativeToBoundingBox)
				viewport.Transform(bt.ToAbsolute);

			var ia = new di.ImageAttributes();
			ia.SetColorMatrix(new di.ColorMatrix { Matrix33 = (float)brush.Opacity });
			var b = new d.TextureBrush(img.ToGdiPlus(), viewbox.ToGdiPlus(), ia);
			b.WrapMode = brush.TileMode.ToGdiPlus();

			b.TranslateTransform((float)viewport.X, (float)viewport.Y);
			b.ScaleTransform((float)(viewport.Width/viewbox.Width), (float)(viewport.Height/viewbox.Height));
			b.MultiplyTransform(bt.ToBrush.ToGdiPlus(), d2.MatrixOrder.Append);

			return b;
		}
开发者ID:goutkannan,项目名称:ironlab,代码行数:23,代码来源:XamlToys.cs

示例15: TranslateTransform_InvalidOrder

		public void TranslateTransform_InvalidOrder ()
		{
			TextureBrush t = new TextureBrush (image);
			t.TranslateTransform (1, 1, (MatrixOrder) Int32.MinValue);
		}
开发者ID:nlhepler,项目名称:mono,代码行数:5,代码来源:TextureBrushTest.cs


注:本文中的System.Drawing.TextureBrush.TranslateTransform方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。