Resize a bitmap in drawing : Draw Image « 2D « C# / CSharp Tutorial

Home
C# / CSharp Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statement
5.String
6.struct
7.Class
8.Operator Overload
9.delegate
10.Attribute
11.Data Structure
12.Assembly
13.Date Time
14.Development
15.File Directory Stream
16.Preprocessing Directives
17.Regular Expression
18.Generic
19.Reflection
20.Thread
21.I18N Internationalization
22.LINQ
23.GUI Windows Forms
24.Windows Presentation Foundation
25.Windows Communication Foundation
26.Workflow
27.2D
28.Design Patterns
29.Windows
30.XML
31.XML LINQ
32.ADO.Net
33.Network
34.Directory Services
35.Security
36.unsafe
C# / C Sharp
C# / C Sharp by API
C# / CSharp Open Source
C# / CSharp Tutorial » 2D » Draw Image 
27.19.1.Resize a bitmap in drawing
Resize a bitmap in drawing
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Drawing.Drawing2D;

public class DoubleBuffering : Form
{
    public DoubleBuffering()
    {
        InitializeComponent();
        image = Image.FromFile("YourFile.bmp");

        tmrRefresh.Start();

    }
    private int imageSize = 0;
    private Image image;

    private void tmrRefresh_Tick(object sender, EventArgs e)
    {
        imageSize++;
        this.Invalidate();
    }

    private void DoubleBuffering_Paint(object sender, PaintEventArgs e)
    {
        Graphics g;
        g = e.Graphics;
        g.SmoothingMode = SmoothingMode.HighQuality;
        g.FillRectangle(Brushes.Yellow, new Rectangle(new Point(00),this.ClientSize));
        g.DrawImage(image, 505050 + imageSize, 50 + imageSize);
    }

    private void chkUseDoubleBuffering_CheckedChanged(object sender, EventArgs e)
    {
        this.DoubleBuffered = chkUseDoubleBuffering.Checked;
    }
    [STAThread]
    static void Main()
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new DoubleBuffering());
    }
    private System.ComponentModel.IContainer components = null;

    private void InitializeComponent()
    {
        this.components = new System.ComponentModel.Container();
        this.tmrRefresh = new System.Windows.Forms.Timer(this.components);
        this.chkUseDoubleBuffering = new System.Windows.Forms.CheckBox();
        this.SuspendLayout();
        // 
        // tmrRefresh
        // 
        this.tmrRefresh.Tick += new System.EventHandler(this.tmrRefresh_Tick);
        // 
        // chkUseDoubleBuffering
        // 
        this.chkUseDoubleBuffering.AutoSize = true;
        this.chkUseDoubleBuffering.Location = new System.Drawing.Point(123);
        this.chkUseDoubleBuffering.Size = new System.Drawing.Size(12717);
        this.chkUseDoubleBuffering.TabIndex = 0;
        this.chkUseDoubleBuffering.Text = "Use Double Buffering";
        this.chkUseDoubleBuffering.UseVisualStyleBackColor = true;
        this.chkUseDoubleBuffering.CheckedChanged += new System.EventHandler(this.chkUseDoubleBuffering_CheckedChanged);
        // 
        this.AutoScaleDimensions = new System.Drawing.SizeF(6F13F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.ClientSize = new System.Drawing.Size(299277);
        this.Controls.Add(this.chkUseDoubleBuffering);
        this.Text = "Double Buffering";
        this.Paint += new System.Windows.Forms.PaintEventHandler(this.DoubleBuffering_Paint);
        this.ResumeLayout(false);
        this.PerformLayout();
    }
    private System.Windows.Forms.Timer tmrRefresh;
    private System.Windows.Forms.CheckBox chkUseDoubleBuffering;

}
27.19.Draw Image
27.19.1.Resize a bitmap in drawingResize a bitmap in drawing
27.19.2.Thumbnail Image CreationThumbnail Image Creation
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.