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


C# Graphics.SetHighQuality方法代码示例

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


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

示例1: Wallpaper

        public Wallpaper()
        {
            s = Settings.Instance;
            allScreen = MultiScreenInfo.Instance;
            CanAddAnotherBitmap = true;

            try
            {
                desktop = new Bitmap(allScreen.VirtualDesktop.Width, allScreen.VirtualDesktop.Height);
                gDesktop = Graphics.FromImage(desktop);
                gDesktop.SetHighQuality();
                needFullRedraw = true;

                try
                {
                    if (allScreen.IsChanged == false)
                    {
                        var currentPath = GetCurrentPath();
                        var expectedPath = SafeFilename.Convert(s.SaveFolder, "Current Wallpaper.bmp", true);

                        if (currentPath == expectedPath)
                        {
                            using (var currentDesktop = new Bitmap(currentPath))
                            {
                                //not needed?
                                if (currentDesktop.Size == allScreen.VirtualDesktop.Size)
                                {
                                    gDesktop.DrawImageUnscaled(currentDesktop, 0, 0);
                                    needFullRedraw = false;
                                }
                            }
                        }
                    }
                }
                catch
                {
                }
            }
            catch
            {
                if (gDesktop != null)
                {
                    gDesktop.Dispose();
                    gDesktop = null;
                }

                if (desktop != null)
                {
                    desktop.Dispose();
                    desktop = null;
                }
            }

            if (desktop == null)
            {
                throw new ArgumentException();
            }
        }
开发者ID:iamxail,项目名称:DailyWallpainter,代码行数:58,代码来源:Wallpaper.cs

示例2: cLogo_Draw

        private void cLogo_Draw(Graphics g)
        {
            g.SetHighQuality();

            using (Matrix m = new Matrix())
            {
                m.RotateAt(45, new PointF(mX, mY));
                g.Transform = m;
            }

            using (Pen pen = new Pen(lineColor))
            {
                for (int i = 0; i <= mX; i += step)
                {
                    g.DrawLine(pen, i, mY, mX, mY + i); // Left top
                    g.DrawLine(pen, i, mY, mX, mY - i); // Left bottom
                    g.DrawLine(pen, w - i, mY, mX, mY - i); // Right top
                    g.DrawLine(pen, w - i, mY, mX, mY + i); // Right bottom
                }

                g.DrawLine(pen, mX, mY, mX, mY + mX); // Left top
                g.DrawLine(pen, mX, mY, mX, mY - mX); // Left bottom
                g.DrawLine(pen, w - mX, mY, mX, mY - mX); // Right top
                g.DrawLine(pen, w - mX, mY, mX, mY + mX); // Right bottom
            }

            if (!isPaused)
            {
                if (step + speed > maxStep)
                {
                    direction = -speed;
                }
                else if (step - speed < minStep)
                {
                    direction = speed;
                }

                step += direction;

                HSB hsb = lineColor;

                if (hsb.Hue >= 1)
                {
                    hsb.Hue = 0;
                }
                else
                {
                    hsb.Hue += 0.01;
                }

                lineColor = hsb;
            }
        }
开发者ID:Z1ni,项目名称:ShareX,代码行数:53,代码来源:AboutForm.cs

示例3: 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

示例4: DrawAutoScaledImage

        private void DrawAutoScaledImage(Graphics g, Image img, Rectangle rect, bool allowEnlarge = false, bool centerImage = false)
        {
            double ratio;
            int newWidth, newHeight;

            if (!allowEnlarge && img.Width <= rect.Width && img.Height <= rect.Height)
            {
                ratio = 1.0;
                newWidth = img.Width;
                newHeight = img.Height;
            }
            else
            {
                double ratioX = (double)rect.Width / img.Width;
                double ratioY = (double)rect.Height / img.Height;
                ratio = ratioX < ratioY ? ratioX : ratioY;
                newWidth = (int)(img.Width * ratio);
                newHeight = (int)(img.Height * ratio);
            }

            int newX = rect.X;
            int newY = rect.Y;

            if (centerImage)
            {
                newX += (int)((rect.Width - (img.Width * ratio)) / 2);
                newY += (int)((rect.Height - (img.Height * ratio)) / 2);
            }

            g.SetHighQuality();
            g.DrawImage(img, newX, newY, newWidth, newHeight);
        }
开发者ID:BallisticLingonberries,项目名称:ShareX,代码行数:32,代码来源:PrintHelper.cs

示例5: DrawBackground

        private void DrawBackground(Graphics g)
        {
            g.SetHighQuality();

            if (isHover)
            {
                g.DrawRoundedRectangle(backgroundHoverBrush, borderPen, new Rectangle(0, 0, ClientSize.Width - 1, ClientSize.Height - 1), 2);
            }
            else
            {
                g.DrawRoundedRectangle(backgroundBrush, borderPen, new Rectangle(0, 0, ClientSize.Width - 1, ClientSize.Height - 1), 2);
            }
        }
开发者ID:noscripter,项目名称:ShareX,代码行数:13,代码来源:GreenlightButton.cs

示例6: 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

示例7: 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


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