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


C# Bitmap.Clone方法代码示例

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


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

示例1: CropImage

 //The method takes two objects - the image to crop (System.Drawing.Image) and the rectangle to
 //crop out (System.Drawing.Rectangle).
 //The next thing done is to create a Bitmap (System.Drawing.Bitmap) of the image.
 // The only thing left is to crop the image.
 //This is done by cloning the original image but only taking a rectangle of the original.
 public static Image CropImage(Image img, Rectangle cropArea)
 {
     Bitmap bmpImage = new Bitmap(img);
         Bitmap bmpCrop = bmpImage.Clone(cropArea,
         bmpImage.PixelFormat);
         return (Image)(bmpCrop);
 }
开发者ID:asifashraf,项目名称:Radmade-Portable-Framework,代码行数:12,代码来源:Image.cs

示例2: FromScreen

        /// <summary>Creates a new <see cref="T:System.Drawing.Analysis.SlowBitmapPixelProvider"/> instance using a screenshot of a spefic rectangle on the screen.</summary>
        /// <param name="rectangle">The rectangle</param>
        /// <param name="operation">The <see cref="T:System.Drawing.CopyPixelOperation"/> to use.</param>
        /// <returns>A new <see cref="T:System.Drawing.Analysis.SlowBitmapPixelProvider"/> instance.</returns>
        public static SlowBitmapPixelProvider FromScreen(Rectangle rectangle, CopyPixelOperation operation)
        {
            if (rectangle.Width < 1)
                throw new ArgumentException("The width must not be 0 or less.");
            if (rectangle.Height < 1)
                throw new ArgumentException("The height must not be 0 or less.");

            using (var bmp = new Bitmap(rectangle.Width, rectangle.Height))
            {
                using (var g = Graphics.FromImage(bmp))
                {
                    g.Clear(GdiConstants.CopyFromScreenBugFixColor.ToDrawingColor());
                    g.CopyFromScreen(rectangle.X, rectangle.Y, 0, 0, bmp.Size, operation);
                    return new SlowBitmapPixelProvider(bmp.Clone() as Bitmap, true);
                }
            }
        }
开发者ID:nikeee,项目名称:pixlib,代码行数:21,代码来源:SlowBitmapPixelProvider.cs

示例3: GetResizedImage

    public static Image GetResizedImage(Image img, Rectangle rect)
    {
        Bitmap b = new Bitmap(rect.Width, rect.Height);
        Graphics g = Graphics.FromImage((Image)b);
        g.InterpolationMode = InterpolationMode.HighQualityBicubic;
        g.DrawImage(img, 0, 0, rect.Width, rect.Height);
        g.Dispose();

        try
        {
            return (Image)b.Clone();
        }
        finally
        {
            b.Dispose();
            b = null;
            g = null;
        }
    }
开发者ID:ytn3rd,项目名称:MovMan,代码行数:19,代码来源:ImageHandling.cs

示例4: DistortImage

    /// <summary>Distorts the image.</summary>
    /// <param name="b">The image to be transformed.</param>
    /// <param name="distortion">An amount of distortion.</param>
    private static void DistortImage(Bitmap b, double distortion)
    {
        int width = b.Width, height = b.Height;

        // Copy the image so that we're always using the original for source color
        using (Bitmap copy = (Bitmap)b.Clone())
        {
            // Iterate over every pixel
            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    // Adds a simple wave
                    int newX = (int)(x + (distortion * Math.Sin(Math.PI * y / 64.0)));
                    int newY = (int)(y + (distortion * Math.Cos(Math.PI * x / 64.0)));
                    if (newX < 0 || newX >= width) newX = 0;
                    if (newY < 0 || newY >= height) newY = 0;
                    b.SetPixel(x, y, copy.GetPixel(newX, newY));
                }
            }
        }
    }
开发者ID:nagaveeram,项目名称:MnDayCare,代码行数:25,代码来源:Captcha.aspx.cs

示例5: GenerateImage

    public virtual Image GenerateImage()
    {
        // Gravatar
        string gravatarUrl = string.Format("http://www.gravatar.com/avatar/{0}?s={1}&d=identicon&=PG", Data.DisplayHash, TemplateOptions.GravatarSize);
        Image gravatarImage = DownloadImage(gravatarUrl);

        //calculate the size first
        int faviconSize = 16;
        int minWidth = TemplateOptions.BorderWidth + TemplateOptions.Spacing + TemplateOptions.GravatarSize +
                    ((TemplateOptions.Spacing + faviconSize) * Math.Min(Data.Sites.Count, Utility.MaxSites)) + TemplateOptions.Spacing + TemplateOptions.BorderWidth;
        int actualWidth = 0;
        int topLine = TemplateOptions.BorderWidth + TemplateOptions.Spacing;
        int middleLine = TemplateOptions.GravatarSize / 3 + topLine;
        int bottomLine = TemplateOptions.GravatarSize / 3 + middleLine;
        int leftCol = topLine;
        int rightCol = leftCol + TemplateOptions.GravatarSize + TemplateOptions.Spacing;
        int height = TemplateOptions.BorderWidth + TemplateOptions.Spacing + TemplateOptions.GravatarSize + TemplateOptions.Spacing + TemplateOptions.BorderWidth;
        var bitmap = new Bitmap(1000, 200);
        Graphics graphics = Graphics.FromImage(bitmap);
        graphics.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
        graphics.CompositingMode = CompositingMode.SourceOver;

        //draw border
        Brush brush = new SolidBrush(TemplateOptions.BackgroundColor);
        graphics.FillRectangle(brush, 1, 1, 1000, height);

        //draw gravatar
        graphics.DrawImage(gravatarImage, topLine, topLine);

        //draw username
        Font topLineFont = new Font(TemplateOptions.FontFamily, TemplateOptions.TopLineSize, FontStyle.Bold);
        Brush usernameBrush = new SolidBrush(TemplateOptions.NameColor);
        graphics.DrawString(Data.DisplayName, topLineFont, usernameBrush, rightCol, topLine);
        int usernameWidth = (int)graphics.MeasureString(Data.DisplayName, topLineFont).Width;

        //draw rep
        string rep = Utility.FormatTotalRep(Data.TotalRep);
        int repWidth = (int)graphics.MeasureString(rep, topLineFont).Width;
        int neededWidth = rightCol + usernameWidth + TemplateOptions.Spacing + repWidth + TemplateOptions.Spacing + TemplateOptions.BorderWidth;
        actualWidth = Math.Max(neededWidth, minWidth);
        Brush repBrush = new SolidBrush(TemplateOptions.RepColor);
        graphics.DrawString(rep, topLineFont, repBrush, actualWidth - TemplateOptions.Spacing - repWidth, topLine);

        //draw mod and badges
        int x = rightCol;
        Font modBadgeFont = new Font(TemplateOptions.FontFamily, TemplateOptions.MiddleLineSize, FontStyle.Regular, GraphicsUnit.Point, Convert.ToByte(2));

        if (Data.ModCount > 0) {
            Brush modBrush = new SolidBrush(TemplateOptions.ModColor);
            string modString = "♦" + Data.ModCount;
            graphics.DrawString(modString, modBadgeFont, modBrush, x, middleLine);
            x += (int)graphics.MeasureString(modString, modBadgeFont).Width;
        }

        if (Data.TotalBadges.Gold > 0) {
            Brush goldBrush = new SolidBrush(TemplateOptions.GoldColor);
            string goldString = "●" + Data.TotalBadges.Gold.ToString();
            graphics.DrawString(goldString, modBadgeFont, goldBrush, x, middleLine);
            x += (int)graphics.MeasureString(goldString, modBadgeFont).Width;
        }

        if (Data.TotalBadges.Silver > 0) {
            Brush silverBrush = new SolidBrush(TemplateOptions.SilverColor);
            string silverString = "●" + Data.TotalBadges.Silver.ToString();
            graphics.DrawString(silverString, modBadgeFont, silverBrush, x, middleLine);
            x += (int)graphics.MeasureString(silverString, modBadgeFont).Width;
        }

        if (Data.TotalBadges.Bronze > 0) {
            Brush bronzeBrush = new SolidBrush(TemplateOptions.BronzeColor);
            string bronzeString = "●" + Data.TotalBadges.Bronze.ToString();
            graphics.DrawString(bronzeString, modBadgeFont, bronzeBrush, x, middleLine);
            x += (int)graphics.MeasureString(bronzeString, modBadgeFont).Width;
        }

        //draw favicons
        x = TemplateOptions.BorderWidth + TemplateOptions.Spacing + TemplateOptions.GravatarSize + TemplateOptions.Spacing;

        // Favicons
        List<Image> favicons = new List<Image>();
        foreach (var site in Data.Sites.Take(Utility.MaxSites).ToList()) {
            var favicon = GetFavicon(site.SiteName);
            favicons.Add(favicon);
            graphics.DrawImage(favicon, x, bottomLine);
            x += favicon.Width + TemplateOptions.Spacing;
        }

        graphics.DrawRectangle(new Pen(TemplateOptions.BorderColor, TemplateOptions.BorderWidth), TemplateOptions.BorderWidth, TemplateOptions.BorderWidth, actualWidth - 2 * TemplateOptions.BorderWidth, height - 2 * TemplateOptions.BorderWidth);
        bitmap = bitmap.Clone(new Rectangle(0, 0, actualWidth, height), PixelFormat.DontCare);

        gravatarImage.Dispose();
        foreach (var favicon in favicons) {
            favicon.Dispose();
        }

        return bitmap;
    }
开发者ID:rchern,项目名称:StackFlair,代码行数:97,代码来源:Templates.cs

示例6: FromFile

 public static Bitmap FromFile(string location)
 {
     Bitmap ans;
     using (Bitmap bmp = new Bitmap(location))
     {
         ans = bmp.Clone(new Rectangle(0, 0, bmp.Width, bmp.Height), PixelFormat.Format32bppArgb);
     }
     return ans;
 }
开发者ID:fsps60312,项目名称:Digging-Game-2,代码行数:9,代码来源:BITMAP.cs

示例7: Main

    static void Main(string[] args)
    {
        if(args.Length < 1 || args[0].ToLower() != "/s") return;

        string wallpaper, backColor;
        int wallStyle;
        bool isTiled;

        try {
            wallpaper   = (string)Registry.GetValue("HKEY_CURRENT_USER\\Control Panel\\Desktop\\", "Wallpaper", "");
            backColor   = (string)Registry.GetValue("HKEY_CURRENT_USER\\Control Panel\\Colors\\", "Background", "");
            wallStyle   = int.Parse((string)Registry.GetValue("HKEY_CURRENT_USER\\Control Panel\\Desktop\\", "WallpaperStyle", ""));
            isTiled     = Convert.ToBoolean(int.Parse((string)Registry.GetValue("HKEY_CURRENT_USER\\Control Panel\\Desktop\\", "TileWallpaper", "")));
        } catch {
            LogError("Can not read registry values.");
            return;
        }

        byte r = 0, g = 0, b = 0;

        try {
            var pos = 0;
            var ind = backColor.IndexOf(' ', pos);
            byte.TryParse(backColor.Substring(pos, ind - pos), out r);
            pos = ind + 1;
            ind = backColor.IndexOf(' ', pos);
            byte.TryParse(backColor.Substring(pos, ind - pos), out g);
            pos = ind + 1;
            byte.TryParse(backColor.Substring(pos), out b);
        } catch { }

        Wnd = new Form();
        Wnd.Text = "DesktopFadeScreensaver";
        Wnd.FormBorderStyle = FormBorderStyle.None;
        Wnd.ShowInTaskbar = false;
        Wnd.TopLevel = true;
        Wnd.TopMost = true;
        Wnd.WindowState = FormWindowState.Maximized;
        Wnd.Opacity = 0.0;
        Wnd.BackColor = Color.FromArgb(r, g, b);

        Img = new PictureBox();
        Img.Dock = DockStyle.Fill;
        Wnd.Controls.Add(Img);

        if(File.Exists(wallpaper)) {
            Bitmap bmp = null;

            try {
                bmp = new Bitmap(wallpaper);
            } catch {
                LogError("Can not open wallpaper file.");
                return;
            }

            if(wallStyle == 0) {
                if(isTiled) {
                    Img.BackgroundImage = bmp;
                    Img.BackgroundImageLayout = ImageLayout.Tile;
                } else {
                    Img.Image = bmp;
                    Img.SizeMode = PictureBoxSizeMode.CenterImage;
                }
            } else if(wallStyle == 2) {
                Img.BackgroundImage = bmp;
                Img.BackgroundImageLayout = ImageLayout.Stretch;
            } else if(wallStyle == 6) {
                Img.BackgroundImage = bmp;
                Img.BackgroundImageLayout = ImageLayout.Zoom;
            } else if(wallStyle == 10 || wallStyle == 22) {
                double dx = 0, dy = 0;
                double coef = (double)bmp.Width / bmp.Height > (double)Screen.PrimaryScreen.Bounds.Width / Screen.PrimaryScreen.Bounds.Height ? (double)bmp.Height / Screen.PrimaryScreen.Bounds.Height : (double)bmp.Width / Screen.PrimaryScreen.Bounds.Width;

                dx = Math.Max(0, bmp.Width - Screen.PrimaryScreen.Bounds.Width * coef);
                dy = Math.Max(0, bmp.Height - Screen.PrimaryScreen.Bounds.Height * coef);

                Img.BackgroundImage = bmp.Clone(new RectangleF((float)(dx / 2), (float)(dy / (wallStyle == 10 ? 3 : 2)), (float)(bmp.Width - dx), (float)(bmp.Height - dy)), System.Drawing.Imaging.PixelFormat.Format32bppArgb);
                Img.BackgroundImageLayout = ImageLayout.Stretch;
                bmp.Dispose();
            }

        }

        Wnd.Load += Wnd_Load;

        Application.Run(Wnd);
    }
开发者ID:HanabishiRecca,项目名称:DesktopFadeScreensaver,代码行数:87,代码来源:Screensaver.cs

示例8: OnPaint

    protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
    {
        base.OnPaint(e);
        Bitmap B = new Bitmap(Width, Height);
        Graphics G = Graphics.FromImage(B);
        G.Clear(Color.Transparent);

        EnabledStringColor = ColorTranslator.FromHtml(fontColor);
        EnabledFocusedColor = ColorTranslator.FromHtml(focusColor);

        LollipopTB.TextAlign = TextAlignment;
        LollipopTB.ForeColor = IsEnabled ? EnabledStringColor : DisabledStringColor;
        LollipopTB.UseSystemPasswordChar = UseSystemPasswordChar;

        G.DrawLine(new Pen(new SolidBrush(IsEnabled ? EnabledUnFocusedColor : DisabledUnFocusedColor)), new Point(0, Height - 2), new Point(Width, Height - 2));
        if (IsEnabled)
        { G.FillRectangle(new SolidBrush(EnabledFocusedColor), PointAnimation, (float)Height - 3, SizeAnimation, 2); }

        G.SmoothingMode = SmoothingMode.AntiAlias;
        G.FillEllipse(new SolidBrush(IsEnabled ? EnabledInPutColor : DisabledInputColor), Width - 5, 9, 4, 4);
        G.FillEllipse(new SolidBrush(IsEnabled ? EnabledInPutColor : DisabledInputColor), Width - 11, 9, 4, 4);
        G.FillEllipse(new SolidBrush(IsEnabled ? EnabledInPutColor : DisabledInputColor), Width - 17, 9, 4, 4);

        e.Graphics.DrawImage((Image)(B.Clone()), 0, 0);
        G.Dispose();
        B.Dispose();
    }
开发者ID:uit-cs217-g11,项目名称:smart-search,代码行数:27,代码来源:LollipopFolderInPut.cs

示例9: OnPaint

    protected override void OnPaint(PaintEventArgs e)
    {
        Bitmap B = new Bitmap(Width, Height);
        Graphics G = Graphics.FromImage(B);
        base.OnPaint(e);
        G.Clear(BackColor);
        G.SmoothingMode = SmoothingMode.HighQuality;

        LinearGradientBrush mlgb = null;
        Font mf = new Font("Marlett", 9);
        SolidBrush mfb = new SolidBrush(Color.FromArgb(174, 195, 30));
        Pen P1 = new Pen(Color.FromArgb(21, 21, 21), 1);
        Color C1 = Color.FromArgb(66, 67, 70);
        Color C2 = Color.FromArgb(43, 44, 48);
        GraphicsPath GP1 = Draw.RoundRect(MinBtn, 4);
        GraphicsPath GP2 = Draw.RoundRect(MaxBtn, 4);
        switch (State)
        {
            case MouseState.None:
                mlgb = new LinearGradientBrush(MinBtn, C1, C2, 90);
                G.FillPath(mlgb, GP1);
                G.DrawPath(P1, GP1);
                G.DrawString("0", mf, mfb, 4, 4);

                G.FillPath(mlgb, GP2);
                G.DrawPath(P1, GP2);
                G.DrawString("r", mf, mfb, 28, 4);
                break;
            case MouseState.Over:
                if (x > 0 && x < 20)
                {
                    mlgb = new LinearGradientBrush(MinBtn, Color.FromArgb(100, C1), Color.FromArgb(100, C2), 90);
                    G.FillPath(mlgb, GP1);
                    G.DrawPath(P1, GP1);
                    G.DrawString("0", mf, mfb, 4, 4);

                    mlgb = new LinearGradientBrush(MaxBtn, C1, C2, 90);
                    G.FillPath(mlgb, Draw.RoundRect(MaxBtn, 4));
                    G.DrawPath(P1, GP2);
                    G.DrawString("r", mf, mfb, 4, 4);
                }
                else if (x > 25 && x < 45)
                {
                    mlgb = new LinearGradientBrush(MinBtn, C1, C2, 90);
                    G.FillPath(mlgb, GP1);
                    G.DrawPath(P1, GP1);
                    G.DrawString("0", mf, mfb, 4, 4);
                    mlgb = new LinearGradientBrush(MaxBtn, Color.FromArgb(100, C1), Color.FromArgb(100, C2), 90);
                    G.FillPath(mlgb, GP2);
                    G.DrawPath(P1, GP2);
                    G.DrawString("r", mf, mfb, 28, 4);
                }
                else
                {
                    mlgb = new LinearGradientBrush(MinBtn, C1, C2, 90);
                    G.FillPath(mlgb, GP1);
                    G.DrawPath(P1, GP1);
                    G.DrawString("0", mf, mfb, 4, 4);

                    LinearGradientBrush lgb = new LinearGradientBrush(MaxBtn, C1, C2, 90);
                    G.FillPath(lgb, GP2);
                    G.DrawPath(P1, GP2);
                    G.DrawString("r", mf, mfb, 28, 4);
                }
                break;
            case MouseState.Down:
                mlgb = new LinearGradientBrush(MinBtn, C1, C2, 90);
                G.FillPath(mlgb, GP1);
                G.DrawPath(P1, GP1);
                G.DrawString("0", mf, mfb, 4, 4);

                mlgb = new LinearGradientBrush(MaxBtn, C1, C2, 90);
                G.FillPath(mlgb, GP2);
                G.DrawPath(P1, GP2);
                G.DrawString("r", mf, mfb, 28, 4);
                break;
            default:
                mlgb = new LinearGradientBrush(MinBtn, C1, C2, 90);
                G.FillPath(mlgb, GP1);
                G.DrawPath(P1, GP1);
                G.DrawString("0", mf, mfb, 4, 4);

                mlgb = new LinearGradientBrush(MaxBtn, C1, C2, 90);
                G.FillPath(mlgb, GP2);
                G.DrawPath(P1, GP2);
                G.DrawString("r", mf, mfb, 28, 4);
                break;
        }
        e.Graphics.DrawImage((Image)B.Clone(), 0, 0);
        G.Dispose();
        B.Dispose();
    }
开发者ID:MrAdder,项目名称:Launcher_Arma3,代码行数:92,代码来源:Theme_Perplex.cs

示例10: cropImage

 public static Image cropImage(Image img, Rectangle area)
 {
     var bmp = new Bitmap(img);
     Bitmap bmpCrop = bmp.Clone(area, PixelFormat.Format16bppRgb555);
     return (Image)bmpCrop;
 }
开发者ID:janmaru,项目名称:mobile-day-2014-slides,代码行数:6,代码来源:ImageHelper.cs

示例11: generateTicket

    public static Bitmap generateTicket(string ticketType, string special, string destination, string price, string person, string printerType)
    {

        DateTime today = DateTime.Now;
        string date = today.ToString("dd.MM.yyyy");
        if (special == "Kein Zusatzangebot")
        {
            special = "";
        }
        else
        {

        }

        if (printerType == TVMSettings.mobilePrinter)
        {
            //Orte der verschiedenen Textboxen auf dem Ticket:
            PointF logoLocation = new PointF(110, 10);
            Point StartLine1 = new Point(20, 60);
            Point EndLine1 = new Point(480, 60);
            PointF ticketTypeLocation = new PointF(20, 75);
            PointF dateLocation = new PointF(320, 75);
            PointF personLocation = new PointF(20, 115);
            PointF destinationLocation = new PointF(20, 220);
            PointF specialLocation = new PointF(250, 300);
            Point StartLine2 = new Point(20, 350);
            Point EndLine2 = new Point(480, 350);
            PointF totalLocation = new PointF(20, 385);
            PointF priceLocation = new PointF(320, 385);


            Bitmap tempBmp = new Bitmap(560, 450);

            //auf das neu erstellte Bitmap draufzeichnen:
            using (Graphics g = Graphics.FromImage(tempBmp))
            {

                g.Clear(Color.White);

                using (Font arialFont = new Font("Arial", 30, FontStyle.Bold))
                {
                    g.DrawString("Cloud4all TVM", arialFont, Brushes.Black, logoLocation);
                }

                g.DrawLine(new Pen(Brushes.Black, 5), StartLine1, EndLine1);

                using (Font arialFont = new Font("Arial", 20, FontStyle.Bold))
                {
                    g.DrawString(ticketType, arialFont, Brushes.Black, ticketTypeLocation);
                    g.DrawString(date, arialFont, Brushes.Black, dateLocation);
                }

                using (Font arialFont = new Font("Arial", 20, FontStyle.Regular))
                {
                    g.DrawString(person, arialFont, Brushes.Black, personLocation);
                    g.DrawString(special, arialFont, Brushes.Black, specialLocation);
                }

                using (Font arialFont = new Font("Arial", 33, FontStyle.Bold))
                {

                    g.DrawString(destination, arialFont, Brushes.Black, destinationLocation);
                }

                g.DrawLine(new Pen(Brushes.Black, 5), StartLine2, EndLine2);

                using (Font arialFont = new Font("Arial", 25, FontStyle.Regular))
                {
                    g.DrawString("Summe:", arialFont, Brushes.Black, totalLocation);
                    g.DrawString(price, arialFont, Brushes.Black, priceLocation);
                }

            }
            //Farbtiefe auf 1 reduzieren:
            Bitmap ticket = tempBmp.Clone(new Rectangle(0, 0, tempBmp.Width, tempBmp.Height), PixelFormat.Format1bppIndexed);
            return ticket;
        }
        else
        {
            //Orte der verschiedenen Textboxen auf dem Ticket:
            PointF logoLocation = new PointF(260, 10);
            Point StartLine1 = new Point(100, 90);
            Point EndLine1 = new Point(860, 90);
            PointF ticketTypeLocation = new PointF(120, 110);
            PointF dateLocation = new PointF(605, 110);
            PointF personLocation = new PointF(120, 160);
            PointF destinationLocation = new PointF(120, 270);
            PointF specialLocation = new PointF(490, 430);
            Point StartLine2 = new Point(100, 480);
            Point EndLine2 = new Point(860, 480);
            PointF totalLocation = new PointF(120, 535);
            PointF priceLocation = new PointF(605, 535);


            Bitmap tempBmp = new Bitmap(1040, 630);

            //auf das neu erstellte Bitmap draufzeichnen:
            using (Graphics g = Graphics.FromImage(tempBmp))
            {

//.........这里部分代码省略.........
开发者ID:cstrobbe,项目名称:C4A-TVM,代码行数:101,代码来源:Printer.cs

示例12: generateStreifenticket


//.........这里部分代码省略.........

                using (Font arialFont = new Font("Arial", 20, FontStyle.Regular))
                {
                    g.DrawString(person, arialFont, Brushes.Black, personLocation);
                    g.DrawString(special, arialFont, Brushes.Black, specialLocation);
                }
                using (Font arialFont = new Font("Arial", 30, FontStyle.Bold))
                {

                    g.DrawString("1", arialFont, Brushes.Black, OneLocation);
                    g.DrawString("2", arialFont, Brushes.Black, TwoLocation);
                    g.DrawString("3", arialFont, Brushes.Black, ThreeLocation);
                    g.DrawString("4", arialFont, Brushes.Black, FourLocation);
                    g.DrawString("5", arialFont, Brushes.Black, FiveLocation);
                    g.DrawString("6", arialFont, Brushes.Black, SixLocation);
                    g.DrawString("7", arialFont, Brushes.Black, SevenLocation);
                    g.DrawString("8", arialFont, Brushes.Black, EightLocation);
                }

                using (Font arialFont = new Font("Arial", 25, FontStyle.Regular))
                {
                    g.DrawString("Summe:", arialFont, Brushes.Black, totalLocation);
                    g.DrawString(price, arialFont, Brushes.Black, priceLocation);
                }

                using (Font arialFont = new Font("Arial", 15, FontStyle.Bold))
                {
                    g.DrawString("Bitte stempeln Sie pro Zone einen Streifen.", arialFont, Brushes.Black, instructionLocation1);
                    g.DrawString("Ab dem Zeitpunkt des Stempelns für 2 Stunden gültig.", arialFont, Brushes.Black, instructionLocation2);

                }
            }
            //Farbtiefe auf 1 reduzieren:
            Bitmap ticket = tempBmp.Clone(new Rectangle(0, 0, tempBmp.Width, tempBmp.Height), PixelFormat.Format1bppIndexed);


            return ticket;
        }
        else
        {
            PointF logoLocation = new PointF(260, 10);
            Point StartLine = new Point(100, 90);
            Point EndLine = new Point(860, 90);
            PointF ticketTypeLocation = new PointF(120, 110);
            PointF dateLocation = new PointF(605, 110);
            PointF personLocation = new PointF(120, 160);
            PointF specialLocation = new PointF(490, 220);

            int startLines = 280;
            int n = 140;

            Point StartLine1 = new Point(0, startLines);
            Point EndLine1 = new Point(1040, startLines);
            PointF EightLocation = new PointF(50, startLines + 40);

            Point StartLine2 = new Point(0, startLines + n);
            Point EndLine2 = new Point(1040, startLines + n);
            PointF SevenLocation = new PointF(50, startLines + n + 40);

            Point StartLine3 = new Point(0, startLines + 2 * n);
            Point EndLine3 = new Point(1040, startLines + 2 * n);
            PointF SixLocation = new PointF(50, startLines + 2 * n + 40);

            Point StartLine4 = new Point(0, startLines + 3 * n);
            Point EndLine4 = new Point(1040, startLines + 3 * n);
            PointF FiveLocation = new PointF(50, startLines + 3 * n + 40);
开发者ID:cstrobbe,项目名称:C4A-TVM,代码行数:67,代码来源:Printer.cs

示例13: OnPaint


//.........这里部分代码省略.........
        {
        }
        G.Clear(Color.White);
        for (int i = 0; i <= TabCount - 1; i++)
        {
            Rectangle x2 = new Rectangle(new Point(GetTabRect(i).Location.X - 2, GetTabRect(i).Location.Y - 2), new Size(GetTabRect(i).Width + 3, GetTabRect(i).Height - 1));
            Rectangle textrectangle = new Rectangle(x2.Location.X + 20, x2.Location.Y, x2.Width - 20, x2.Height);
            if (i == SelectedIndex)
            {
                G.FillRectangle(new SolidBrush(C1), new Rectangle(x2.Location, new Size(9, x2.Height)));

                if (ImageList != null)
                {
                    try
                    {
                        if (ImageList.Images[TabPages[i].ImageIndex] != null)
                        {
                            G.DrawImage(ImageList.Images[TabPages[i].ImageIndex], new Point(textrectangle.Location.X + 8, textrectangle.Location.Y + 6));
                            G.DrawString("      " + TabPages[i].Text, Font, Brushes.Black, textrectangle, new StringFormat
                            {
                                LineAlignment = StringAlignment.Center,
                                Alignment = StringAlignment.Near
                            });
                        }
                        else
                        {
                            G.DrawString(TabPages[i].Text, Font, Brushes.Black, textrectangle, new StringFormat
                            {
                                LineAlignment = StringAlignment.Center,
                                Alignment = StringAlignment.Near
                            });
                        }
                    }
                    catch
                    {
                        G.DrawString(TabPages[i].Text, Font, Brushes.Black, textrectangle, new StringFormat
                        {
                            LineAlignment = StringAlignment.Center,
                            Alignment = StringAlignment.Near
                        });
                    }
                }
                else
                {
                    G.DrawString(TabPages[i].Text, Font, Brushes.Black, textrectangle, new StringFormat
                    {
                        LineAlignment = StringAlignment.Center,
                        Alignment = StringAlignment.Near
                    });
                }

            }
            else
            {
                if (ImageList != null)
                {
                    try
                    {
                        if (ImageList.Images[TabPages[i].ImageIndex] != null)
                        {
                            G.DrawImage(ImageList.Images[TabPages[i].ImageIndex], new Point(textrectangle.Location.X + 8, textrectangle.Location.Y + 6));
                            G.DrawString("      " + TabPages[i].Text, Font, Brushes.DimGray, textrectangle, new StringFormat
                            {
                                LineAlignment = StringAlignment.Center,
                                Alignment = StringAlignment.Near
                            });
                        }
                        else
                        {
                            G.DrawString(TabPages[i].Text, Font, Brushes.DimGray, textrectangle, new StringFormat
                            {
                                LineAlignment = StringAlignment.Center,
                                Alignment = StringAlignment.Near
                            });
                        }
                    }
                    catch
                    {
                        G.DrawString(TabPages[i].Text, Font, Brushes.DimGray, textrectangle, new StringFormat
                        {
                            LineAlignment = StringAlignment.Center,
                            Alignment = StringAlignment.Near
                        });
                    }
                }
                else
                {
                    G.DrawString(TabPages[i].Text, Font, Brushes.DimGray, textrectangle, new StringFormat
                    {
                        LineAlignment = StringAlignment.Center,
                        Alignment = StringAlignment.Near
                    });
                }
            }
        }

        e.Graphics.DrawImage((Image)B.Clone(), 0, 0);
        G.Dispose();
        B.Dispose();
    }
开发者ID:bomzhkolyadun,项目名称:InvisibilityGame,代码行数:101,代码来源:ChromeForm.cs

示例14: CropImageToCircle

    private static Bitmap CropImageToCircle(Bitmap SourceImage)
    {
        int circleDiameter = SourceImage.Width;
        int circleUpperLeftX = 0;
        int circleUpperLeftY = 0;

        //Load our source image
        //Create a rectangle that crops a square of our image
        Rectangle CropRect = new Rectangle(circleUpperLeftX, circleUpperLeftY, circleDiameter, circleDiameter);

        //Crop the image to that square
        using (Bitmap CroppedImage = SourceImage.Clone(CropRect, SourceImage.PixelFormat))
        {

            //Create a texturebrush to draw our circle with
            using (TextureBrush TB = new TextureBrush(CroppedImage))
            {

                //Create our output image
                Bitmap FinalImage = new Bitmap(circleDiameter, circleDiameter);

                //Create a graphics object to draw with
                using (Graphics myGraphic = FromImage(FinalImage))
                {
                    myGraphic.FillEllipse(TB, 0, 0, circleDiameter, circleDiameter);
                    return FinalImage;
                }
            }
        }
    }
开发者ID:hkdilan,项目名称:CreateCircleImage,代码行数:30,代码来源:CircleImageCreater.cs

示例15: CropBitmap

 public Bitmap CropBitmap(Bitmap bitmap, Rectangle rect)
 {
     var cropped = bitmap.Clone(rect, bitmap.PixelFormat);
     return cropped;
 }
开发者ID:nhatkycon,项目名称:xetui,代码行数:5,代码来源:Crop.aspx.cs


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