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


C# Graphics.DrawImage方法代码示例

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


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

示例1: Draw

        public void Draw(Graphics g,Point p)
        {
            SysPoint sysp=p.toSysPoint(32);

            SysRectangle dst=new SysRectangle(sysp.X,sysp.Y,spec.frames[frame].Width,spec.frames[frame].Height);

            g.DrawImage(spec.image, spec.frames[frame],dst);
        }
开发者ID:banthar,项目名称:frogger,代码行数:8,代码来源:FroggerAnimation.cs

示例2: LBPlot

 public LBPlot(Graphics Dest, Rectangle Location)
 {
     if (Dest == null) return;
     source = new ArrayList(1);
     dDest = Dest;
     location = Location;
     imgCash = new Bitmap(location.Width, location.Height);
     Dest.DrawImage(imgCash, location.Left, location.Top);
     minX = 0;
     maxX = 0;
     showAll = true;
 }
开发者ID:bastrich,项目名称:SpeechRecognition,代码行数:12,代码来源:LBPlot.cs

示例3: GDI_Draw_Tile

    // TODO:
    // Perhaps move square/hex tile drawing methods from TileViewPortControl into TileSprite ...
    // Such methods would want an argument for the TVP (or other GLControl?) to draw them upon ...
    // For now, will make TileViewPortControl.Render() get the texture_id via (sprite_obj).texture ...
    public void GDI_Draw_Tile(Graphics gg, int xx, int yy, ImageAttributes attrib)
    {
        // Keeping this around, as it may prove convenient to be able
        // to draw a tile onto a Control for certain UI purposes.

        // Draw the region this.rect of the image onto gg at xx,yy, with no scaling
        Rectangle destRect = new Rectangle(xx, yy, _rect.Width, _rect.Height);
        gg.DrawImage(_image,
                     new Rectangle(xx, yy, _rect.Width, _rect.Height),
                     _rect.X, _rect.Y, _rect.Width, _rect.Height,
                     GraphicsUnit.Pixel, attrib);
    }
开发者ID:gmcnutt,项目名称:HRAOS,代码行数:16,代码来源:StaticTileSprite.cs

示例4: Run

        public static void Run()
        {
            // ExStart:CombineImages
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_DrawingAndFormattingImages();

            // Create an instance of JpegOptions and set its various properties
            JpegOptions imageOptions = new JpegOptions();

            // Create an instance of FileCreateSource and assign it to Source property
            imageOptions.Source = new FileCreateSource(dataDir + "Two_images_result_out.bmp", false);

            // Create an instance of Image and define canvas size
            using (var image = Image.Create(imageOptions, 600, 600))
            {
                // Create and initialize an instance of Graphics, Clear the image surface with white color and Draw Image
                var graphics = new Graphics(image);
                graphics.Clear(Color.White);
                graphics.DrawImage(Image.Load(dataDir + "sample_1.bmp"), 0, 0, 600, 300);
                graphics.DrawImage(Image.Load(dataDir + "File1.bmp"), 0, 300, 600, 300);
                image.Save();
            }
            // ExEnd:CombineImages
        }
开发者ID:aspose-imaging,项目名称:Aspose.Imaging-for-.NET,代码行数:24,代码来源:CombineImages.cs

示例5: Run

        public static void Run()
        {
            // ExStart:AddSignatureToImage
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages();

            // Create an instance of Image and load the primary image
            using (Image canvas = Image.Load(dataDir + "SampleTiff1.tiff"))
            {
                // Create another instance of Image and load the secondary image containing the signature graphics
                using (Image signature = Image.Load(dataDir + "signature.gif"))
                {
                    // Create an instance of Graphics class and initialize it using the object of the primary image
                    Graphics graphics = new Graphics(canvas);

                    // Call the DrawImage method while passing the instance of secondary image and appropriate location. The following snippet tries to draw the secondary image at the right bottom of the primary image
                    graphics.DrawImage(signature, new Point(canvas.Height - signature.Height, canvas.Width - signature.Width));
                    canvas.Save(dataDir + "AddSignatureToImage_out.png", new PngOptions());
                }
            }
            // ExStart:AddSignatureToImage
        }
开发者ID:aspose-imaging,项目名称:Aspose.Imaging-for-.NET,代码行数:22,代码来源:AddSignatureToImage.cs

示例6: DrawRows

    // The function that print a bunch of rows that fit in one page
    // When it returns true, meaning that there are more rows still not printed,
    // so another PagePrint action is required
    // When it returns false, meaning that all rows are printed
    // (the CureentRow parameter reaches the last row of the DataGridView control)
    // and no further PagePrint action is required
    private bool DrawRows(Graphics g, DataGridView inDataGridView)
    {
        // Setting the LinePen that will be used to draw lines and rectangles (derived from the GridColor property of the DataGridView control)
        Pen TheLinePen = new Pen(inDataGridView.GridColor, 1);

        // The style paramters that will be used to print each cell
        Font RowFont;
        Color RowForeColor;
        Color RowBackColor;
        SolidBrush RowForeBrush;
        SolidBrush RowBackBrush;
        SolidBrush RowAlternatingBackBrush;

        // Setting the format that will be used to print each cell
        StringFormat CellFormat = new StringFormat();
        CellFormat.Trimming = StringTrimming.Word;
        CellFormat.FormatFlags = StringFormatFlags.NoWrap | StringFormatFlags.LineLimit;

        // Printing each visible cell
        String curCellValue = "";
        RectangleF RowBounds;
        float CurrentX;
        float ColumnWidth;
        while (CurrentRow < inDataGridView.Rows.Count)
        {
            if (inDataGridView.Rows[CurrentRow].Visible) // Print the cells of the CurrentRow only if that row is visible
            {
                // Setting the row font style
                RowFont = inDataGridView.Rows[CurrentRow].DefaultCellStyle.Font;
                if (RowFont == null) // If the there is no special font style of the CurrentRow, then use the default one associated with the DataGridView control
                    RowFont = inDataGridView.DefaultCellStyle.Font;

                // Setting the RowFore style
                RowForeColor = inDataGridView.Rows[CurrentRow].DefaultCellStyle.ForeColor;
                if (RowForeColor.IsEmpty) // If the there is no special RowFore style of the CurrentRow, then use the default one associated with the DataGridView control
                    RowForeColor = inDataGridView.DefaultCellStyle.ForeColor;
                RowForeBrush = new SolidBrush(RowForeColor);

                // Setting the RowBack (for even rows) and the RowAlternatingBack (for odd rows) styles
                RowBackColor = inDataGridView.Rows[CurrentRow].DefaultCellStyle.BackColor;
                if (RowBackColor.IsEmpty) // If the there is no special RowBack style of the CurrentRow, then use the default one associated with the DataGridView control
                {
                    RowBackBrush = new SolidBrush(inDataGridView.DefaultCellStyle.BackColor);
                    RowAlternatingBackBrush = new SolidBrush(inDataGridView.AlternatingRowsDefaultCellStyle.BackColor);
                }
                else // If the there is a special RowBack style of the CurrentRow, then use it for both the RowBack and the RowAlternatingBack styles
                {
                    RowBackBrush = new SolidBrush(RowBackColor);
                    RowAlternatingBackBrush = new SolidBrush(RowBackColor);
                }

                // Calculating the starting x coordinate that the printing process will start from
                CurrentX = (float)LeftMargin;
                if (IsCenterOnPage)
                    CurrentX += (((float)PageWidth - (float)RightMargin - (float)LeftMargin) - mColumnPointsWidth[mColumnPoint]) / 2.0F;

                // Calculating the entire CurrentRow bounds
                RowBounds = new RectangleF(CurrentX, CurrentY, mColumnPointsWidth[mColumnPoint], RowsHeight[CurrentRow]);

                // Filling the back of the CurrentRow
                if (CurrentRow % 2 == 0)
                    g.FillRectangle(RowBackBrush, RowBounds);
                else
                    g.FillRectangle(RowAlternatingBackBrush, RowBounds);

                // Printing each visible cell of the CurrentRow
                for (int CurrentCell = (int)mColumnPoints[mColumnPoint].GetValue(0); CurrentCell < (int)mColumnPoints[mColumnPoint].GetValue(1); CurrentCell++)
                {
                    if (!inDataGridView.Columns[CurrentCell].Visible) continue; // If the cell is belong to invisible column, then ignore this iteration

                    // Check the CurrentCell alignment and apply it to the CellFormat
                    if (inDataGridView.Columns[CurrentCell].DefaultCellStyle.Alignment.ToString().Contains("Right"))
                        CellFormat.Alignment = StringAlignment.Far;
                    else if (inDataGridView.Columns[CurrentCell].DefaultCellStyle.Alignment.ToString().Contains("Center"))
                        CellFormat.Alignment = StringAlignment.Center;
                    else
                        CellFormat.Alignment = StringAlignment.Near;

                    if (inDataGridView.Columns[CurrentCell].DefaultCellStyle.Alignment.ToString().Contains("Top"))
                        CellFormat.LineAlignment = StringAlignment.Near;
                    else if (inDataGridView.Columns[CurrentCell].DefaultCellStyle.Alignment.ToString().Contains("Middle"))
                        CellFormat.LineAlignment = StringAlignment.Center;
                    else
                        CellFormat.LineAlignment = StringAlignment.Far;

                    ColumnWidth = ColumnsWidth[CurrentCell];
                    RectangleF CellBounds = new RectangleF(CurrentX, CurrentY, ColumnWidth, RowsHeight[CurrentRow]);

                    if ( inDataGridView.Rows[CurrentRow].Cells[CurrentCell].GetType() == typeof( DataGridViewImageCell ) ) {
                        DataGridViewImageColumn curImageCell = (DataGridViewImageColumn)inDataGridView.Columns [CurrentCell];
                        if ( curImageCell != null ) {
                            if ( curImageCell.Image != null ) {
                                g.DrawImage( curImageCell.Image, CurrentX, CurrentY );
                            }
//.........这里部分代码省略.........
开发者ID:WaterskiScoring,项目名称:WaterskiScoringSystem,代码行数:101,代码来源:DataGridViewPrinter.cs

示例7: Paint

        protected override void Paint(Graphics g, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
        {
            ReadOnly = true;

            // Draw the cell border
            base.Paint(g, clipBounds, cellBounds,
                       rowIndex, cellState, value, formattedValue, errorText,
                       cellStyle, advancedBorderStyle, DataGridViewPaintParts.Border);

            try
            {
                // Draw the ProgressBar to an in-memory bitmap
                Bitmap bmp = new Bitmap(cellBounds.Width, cellBounds.Height);
                Rectangle bmpBounds = new Rectangle(0, 0, cellBounds.Width, cellBounds.Height);
                _progressBar.Size = cellBounds.Size;
                _progressBar.DrawToBitmap(bmp, bmpBounds);

                // Draw the bitmap on the cell
                g.DrawImage(bmp, cellBounds);

                // Replace special value placeholders
                var editedMessage = _text.Replace(MessageSpecialValue.CurrentValue, Value.ToString())
                                         .Replace(MessageSpecialValue.Maximum, Maximum.ToString())
                                         .Replace(MessageSpecialValue.Minimum, Minimum.ToString());

                // Write text over bar
                base.Paint(g, clipBounds, cellBounds,
                           rowIndex, cellState, value, editedMessage, errorText,
                           cellStyle, advancedBorderStyle, DataGridViewPaintParts.ContentForeground);
            }
            catch (ArgumentOutOfRangeException)
            {
                // Row probably couldn't be accessed
            }
        }
开发者ID:AlexandreBurel,项目名称:pwiz-mzdb,代码行数:35,代码来源:DataGridViewProgressBar.cs

示例8: DrawBackground

 public void DrawBackground(Graphics drawingSurface, Card dealerCard)
 {
     // Draw different colored backgrounds to match the advice
     switch (GetAdvice(dealerCard))
     {
         case Strategy.AdviceType.Hit:
             drawingSurface.DrawImage(Resources.GetImage(backgroundImage + "_hit"), location);
             break;
         case Strategy.AdviceType.Stand:
             drawingSurface.DrawImage(Resources.GetImage(backgroundImage + "_stand"), location);
             break;
         case Strategy.AdviceType.Split:
             drawingSurface.DrawImage(Resources.GetImage(backgroundImage + "_split"), location);
             break;
         case Strategy.AdviceType.DoubleDown:
             drawingSurface.DrawImage(Resources.GetImage(backgroundImage + "_ddown"), location);
             break;
         case Strategy.AdviceType.None:
             drawingSurface.DrawImage(Resources.GetImage(backgroundImage + "_noadvice"), location);
             break;
         default:
             break;
     }
 }
开发者ID:itgsod-alexander-karlsson,项目名称:Blackjack,代码行数:24,代码来源:Player.cs

示例9: addWatermarkImage


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


        }

        else if ((_width < watermark.Width * 4) && (_height > watermark.Height * 4))
        {

            bl = Convert.ToDouble(_width / 4) / Convert.ToDouble(watermark.Width);

        }

        else
        {

            if ((_width * watermark.Height) > (_height * watermark.Width))
            {

                bl = Convert.ToDouble(_height / 4) / Convert.ToDouble(watermark.Height);



            }

            else
            {

                bl = Convert.ToDouble(_width / 4) / Convert.ToDouble(watermark.Width);



            }



        }

        WatermarkWidth = Convert.ToInt32(watermark.Width * bl);

        WatermarkHeight = Convert.ToInt32(watermark.Height * bl);

        switch (_watermarkPosition)
        {

            case "WM_TOP_LEFT":

                xpos = 10;

                ypos = 10;

                break;

            case "WM_TOP_RIGHT":

                xpos = _width - WatermarkWidth - 10;

                ypos = 10;

                break;

            case "WM_BOTTOM_RIGHT":

                xpos = _width - WatermarkWidth - 10;

                ypos = _height - WatermarkHeight - 10;

                break;

            case "WM_BOTTOM_LEFT":

                xpos = 10;

                ypos = _height - WatermarkHeight - 10;

                break;

        }

        picture.DrawImage(

            watermark,

            new Rectangle(xpos, ypos, WatermarkWidth, WatermarkHeight),

            0,

            0,

            watermark.Width,

            watermark.Height,

            GraphicsUnit.Pixel,

            imageAttributes);

        watermark.Dispose();

        imageAttributes.Dispose();

    }
开发者ID:ningkyolei,项目名称:.NET,代码行数:101,代码来源:ImageWaterMark.cs

示例10: OnPaint

	// Handle paint requests.
	protected override void OnPaint(Graphics graphics)
	{
		graphics.DrawImage(0, 0, image);
	}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:5,代码来源:XHello.cs

示例11: DrawImage

 /// <summary>
 /// Draws the image for the button
 /// </summary>
 /// <param name="g">The graphics object used in the paint event.</param>
 private void DrawImage(Graphics g)
 {
     if (this.Image == null) { return; }
     Rectangle r = new Rectangle(8, 8, this.ImageSize.Width, this.ImageSize.Height);
     switch (this.ImageAlign)
         {
         case ContentAlignment.TopCenter:
             r = new Rectangle(this.Width / 2 - this.ImageSize.Width / 2, 8, this.ImageSize.Width, this.ImageSize.Height);
             break;
         case ContentAlignment.TopRight:
             r = new Rectangle(this.Width - 8 - this.ImageSize.Width, 8, this.ImageSize.Width, this.ImageSize.Height);
             break;
         case ContentAlignment.MiddleLeft:
             r = new Rectangle(8, this.Height / 2 - this.ImageSize.Height / 2, this.ImageSize.Width, this.ImageSize.Height);
             break;
         case ContentAlignment.MiddleCenter:
             r = new Rectangle(this.Width / 2 - this.ImageSize.Width / 2, this.Height / 2 - this.ImageSize.Height / 2, this.ImageSize.Width, this.ImageSize.Height);
             break;
         case ContentAlignment.MiddleRight:
             r = new Rectangle(this.Width - 8 - this.ImageSize.Width, this.Height / 2 - this.ImageSize.Height / 2, this.ImageSize.Width, this.ImageSize.Height);
             break;
         case ContentAlignment.BottomLeft:
             r = new Rectangle(8, this.Height - 8 - this.ImageSize.Height, this.ImageSize.Width, this.ImageSize.Height);
             break;
         case ContentAlignment.BottomCenter:
             r = new Rectangle(this.Width / 2 - this.ImageSize.Width / 2, this.Height - 8 - this.ImageSize.Height, this.ImageSize.Width, this.ImageSize.Height);
             break;
         case ContentAlignment.BottomRight:
             r = new Rectangle(this.Width - 8 - this.ImageSize.Width, this.Height - 8 - this.ImageSize.Height, this.ImageSize.Width, this.ImageSize.Height);
             break;
         }
     g.DrawImage(this.Image, r);
 }
开发者ID:RobertFurer,项目名称:Picasso23,代码行数:37,代码来源:VistaButton.cs

示例12: Paint


//.........这里部分代码省略.........
            //{
            //    paintingNumericUpDown =new NumericUpDown();
            //}
            // First paint the borders and background of the cell.
            base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle,
                       paintParts & ~(DataGridViewPaintParts.ErrorIcon | DataGridViewPaintParts.ContentForeground));

            Point ptCurrentCell = this.DataGridView.CurrentCellAddress;
            bool cellCurrent = ptCurrentCell.X == this.ColumnIndex && ptCurrentCell.Y == rowIndex;
            bool cellEdited = cellCurrent && this.DataGridView.EditingControl != null;

            // If the cell is in editing mode, there is nothing else to paint
            if (!cellEdited)
            {
                if (PartPainted(paintParts, DataGridViewPaintParts.ContentForeground))
                {
                    // Paint a NumericUpDown control
                    // Take the borders into account
                    Rectangle borderWidths = BorderWidths(advancedBorderStyle);
                    Rectangle valBounds = cellBounds;
                    valBounds.Offset(borderWidths.X, borderWidths.Y);
                    valBounds.Width -= borderWidths.Right;
                    valBounds.Height -= borderWidths.Bottom;
                    // Also take the padding into account
                    if (cellStyle.Padding != Padding.Empty)
                    {
                        if (this.DataGridView.RightToLeft == RightToLeft.Yes)
                        {
                            valBounds.Offset(cellStyle.Padding.Right, cellStyle.Padding.Top);
                        }
                        else
                        {
                            valBounds.Offset(cellStyle.Padding.Left, cellStyle.Padding.Top);
                        }
                        valBounds.Width -= cellStyle.Padding.Horizontal;
                        valBounds.Height -= cellStyle.Padding.Vertical;
                    }
                    // Determine the NumericUpDown control location
                    valBounds = GetAdjustedEditingControlBounds(valBounds, cellStyle);

                    bool cellSelected = (cellState & DataGridViewElementStates.Selected) != 0;

                    if (renderingBitmap.Width < valBounds.Width ||
                        renderingBitmap.Height < valBounds.Height)
                    {
                        // The static bitmap is too small, a bigger one needs to be allocated.
                        renderingBitmap.Dispose();
                        renderingBitmap = new Bitmap(valBounds.Width, valBounds.Height);
                    }
                    // Make sure the NumericUpDown control is parented to a visible control
                    if (paintingNumericUpDown.Parent == null || !paintingNumericUpDown.Parent.Visible)
                    {
                        paintingNumericUpDown.Parent = this.DataGridView;
                    }
                    // Set all the relevant properties
                    paintingNumericUpDown.TextAlign = DataGridViewNumericUpDownCell.TranslateAlignment(cellStyle.Alignment);
                    paintingNumericUpDown.DecimalPlaces = this.DecimalPlaces;
                    paintingNumericUpDown.ThousandsSeparator = this.ThousandsSeparator;
                    paintingNumericUpDown.Font = cellStyle.Font;
                    paintingNumericUpDown.Width = valBounds.Width;
                    paintingNumericUpDown.Height = valBounds.Height;
                    paintingNumericUpDown.RightToLeft = this.DataGridView.RightToLeft;
                    paintingNumericUpDown.Location = new Point(0, -paintingNumericUpDown.Height - 100);
                    paintingNumericUpDown.Text = formattedValue as string;

                    Color backColor;
                    if (PartPainted(paintParts, DataGridViewPaintParts.SelectionBackground) && cellSelected)
                    {
                        backColor = cellStyle.SelectionBackColor;
                    }
                    else
                    {
                        backColor = cellStyle.BackColor;
                    }
                    if (PartPainted(paintParts, DataGridViewPaintParts.Background))
                    {
                        if (backColor.A < 255)
                        {
                            // The NumericUpDown control does not support transparent back colors
                            backColor = Color.FromArgb(255, backColor);
                        }
                        paintingNumericUpDown.BackColor = backColor;
                    }
                    // Finally paint the NumericUpDown control
                    Rectangle srcRect = new Rectangle(0, 0, valBounds.Width, valBounds.Height);
                    if (srcRect.Width > 0 && srcRect.Height > 0)
                    {
                        paintingNumericUpDown.DrawToBitmap(renderingBitmap, srcRect);
                        graphics.DrawImage(renderingBitmap, new Rectangle(valBounds.Location, valBounds.Size),
                                           srcRect, GraphicsUnit.Pixel);
                    }
                }
                if (PartPainted(paintParts, DataGridViewPaintParts.ErrorIcon))
                {
                    // Paint the potential error icon on top of the NumericUpDown control
                    base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText,
                               cellStyle, advancedBorderStyle, DataGridViewPaintParts.ErrorIcon);
                }
            }
        }
开发者ID:anushkaD,项目名称:AnushkaPrivate,代码行数:101,代码来源:CustomControls.cs

示例13: GetThumbnail

    /// <summary>
    /// Returns a Image which represents a rezised Image
    /// </summary>
    /// <returns>A Image which represents a rezised Image, using the 
    /// proprerty settings provided</returns>
    public virtual System.Drawing.Image GetThumbnail()
    {
        // Flag whether a new image is required
        bool recalculate = false;
        double new_width = Width;
        double new_height = Height;
        // Load via stream rather than Image.FromFile to release the file
        // handle immediately
        if (m_src_image != null)
            m_src_image.Dispose();
        m_src_image = m_image;
        recalculate = true;
        // If you opted to specify width and height as percentages of the original
        // image's width and height, compute these now
        if (UsePercentages)
        {
            if (Width != 0)
            {
                new_width = (double)m_src_image.Width * Width / 100;

                if (PreserveAspectRatio)
                {
                    new_height = new_width * m_src_image.Height / (double)m_src_image.Width;
                }
            }
            if (Height != 0)
            {
                new_height = (double)m_src_image.Height * Height / 100;

                if (PreserveAspectRatio)
                {
                    new_width = new_height * m_src_image.Width / (double)m_src_image.Height;
                }
            }
        }
        else
        {
            // If you specified an aspect ratio and absolute width or height, then calculate this 
            // now; if you accidentally specified both a width and height, ignore the 
            // PreserveAspectRatio flag
            if (PreserveAspectRatio)
            {
                if (Width != 0 && Height == 0)
                {
                    new_height = (Width / (double)m_src_image.Width) * m_src_image.Height;
                }
                else if (Height != 0 && Width == 0)
                {
                    new_width = (Height / (double)m_src_image.Height) * m_src_image.Width;
                }
            }
        }
        recalculate = true;
        if (recalculate)
        {
            // Calculate the new image
            if (m_dst_image != null)
            {
                m_dst_image.Dispose();
                m_graphics.Dispose();
            }
            Bitmap bitmap = new Bitmap((int)new_width, (int)new_height, m_src_image.PixelFormat);
            m_graphics = Graphics.FromImage(bitmap);
            m_graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            m_graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
            m_graphics.DrawImage(m_src_image, 0, 0, bitmap.Width, bitmap.Height);
            m_dst_image = bitmap;
            // Cache the image and its associated settings
            m_cache = this.MemberwiseClone() as ImageResize;
        }

        return m_dst_image;
    }
开发者ID:EasyDenken,项目名称:GrupoINCI,代码行数:78,代码来源:ImageResize.cs

示例14: DrawBackground

 /// <summary>
 /// Draws the background for the control
 /// using the background image and the 
 /// BaseColor.
 /// </summary>
 /// <param name="g">The graphics object used in the paint event.</param>
 private void DrawBackground(Graphics g)
 {
     if (this.ButtonStyle == Style.Flat && this.mButtonState == State.None) { return; }
     int alpha = (mButtonState == State.Pressed) ? 204 : 127;
     Rectangle r = this.ClientRectangle;
     r.Width--; r.Height--;
     using (GraphicsPath rr = RoundRect(r, CornerRadius, CornerRadius, CornerRadius, CornerRadius))
         {
         using (SolidBrush sb = new SolidBrush(this.BaseColor))
             {
             g.FillPath(sb, rr);
             }
         SetClip(g);
         if (this.BackImage != null) { g.DrawImage(this.BackImage, this.ClientRectangle); }
         g.ResetClip();
         using (SolidBrush sb = new SolidBrush(Color.FromArgb(alpha, this.ButtonColor)))
             {
             g.FillPath(sb, rr);
             }
         }
 }
开发者ID:RobertFurer,项目名称:Picasso23,代码行数:27,代码来源:VistaButton.cs

示例15: DrawImage

                private void DrawImage(Graphics g)
                {
                    Image image;
                    if (this.Enabled)
                    {
                        image = this.ImageEnabled;
                    }
                    else
                    {
                        if (ImageDisabled != null)
                        {
                            image = this.ImageDisabled;
                        }
                        else
                        {
                            image = this.ImageEnabled;
                        }
                    }
                    ImageAttributes imageAttr = null;
                    if (image == null)
                    {
                        return;
                    }
                    if (m_monochrom)
                    {
                        imageAttr = new ImageAttributes();
                        // transform the monochrom image
                        // white -> BackColor
                        // black -> ForeColor
                        ColorMap[] myColorMap = new ColorMap[2];
                        myColorMap[0] = new ColorMap();
                        myColorMap[0].OldColor = Color.White;
                        myColorMap[0].NewColor = Color.Transparent;
                        myColorMap[1] = new ColorMap();
                        myColorMap[1].OldColor = Color.Black;
                        myColorMap[1].NewColor = this.ForeColor;
                        imageAttr.SetRemapTable(myColorMap);
                    }
                    Rectangle rect = new Rectangle(0, 0, image.Width, image.Height);
                    if ((! Enabled) && (ImageDisabled == null))
                    {
                        using (Bitmap bitmapMono = new Bitmap(image, ClientRectangle.Size))
                        {
                            if (imageAttr != null)
                            {
                                using (Graphics gMono = Graphics.FromImage(bitmapMono))
                                {
                                    gMono.DrawImage(image, new Point[3] {new Point(0, 0), new Point(image.Width - 1, 0), new Point(0, image.Height - 1)}, rect, GraphicsUnit.Pixel, imageAttr);
                                }

                            }
                            ControlPaint.DrawImageDisabled(g, bitmapMono, 0, 0, this.BackColor);
                        }

                    }
                    else
                    {
                        // Three points provided are upper-left, upper-right and
                        // lower-left of the destination parallelogram.
                        Point[] pts = new Point[3]();
                        if (Enabled && m_mouseOver && m_mouseCapture)
                        {
                            pts[0].X = 1;
                            pts[0].Y = 1;
                        }
                        else
                        {
                            pts[0].X = 0;
                            pts[0].Y = 0;
                        }
                        pts[1].X = pts[0].X + ClientRectangle.Width;
                        pts[1].Y = pts[0].Y;
                        pts[2].X = pts[0].X;
                        pts[2].Y = pts[1].Y + ClientRectangle.Height;
                        if (imageAttr == null)
                        {
                            g.DrawImage(image, pts, rect, GraphicsUnit.Pixel);
                        }
                        else
                        {
                            g.DrawImage(image, pts, rect, GraphicsUnit.Pixel, imageAttr);
                        }
                    }
                }
开发者ID:okyereadugyamfi,项目名称:softlogik,代码行数:84,代码来源:PopupButton.cs


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