All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
asp.net定制简单的错误处理页面_.net资料_编程技术
利用C#远程存取Access数据库_.net资料_编程技术
PHP实例:PHP如何实现在线发邮件_[PHP教程]
SQL操作全集(部分是Mssql语句,不在access中使用)_[SQL Server教程]
ASP.NET常用的三十三种实用代码_[Asp.Net教程]
SQL,Server如何得详细错误处理信息_[SQL,Server教程]
PHP中用正则表达式验证中文的问题_php资料_编程技术
Visual C++ 6.0教程:c++数据类型之数组
C#类的声明方法_[Asp.Net教程]
常用网页设计效果代码十五例_[Html教程]
Reading number is top 10 pictures
人美胸美腿更美2
Exquisite decoration is not paying too much4
陪睡门马睿菈自曝写真 称首拍大尺度照片2
中国女孩大胆自拍,显露完美身材3
初五接财神啦!五路财神齐来到
Angie Chiu vijara myth1
A man's favorite things10
Group of female porn in 《westwards》, uninhibited woman threatened to not the bottom line2
看到这名字我也是醉了。。。。。。
中国女孩大胆自拍,显露完美身材4
Download software ranking
Unix video tutorial9
The king of fighters 97(Mobile phone games-apk)
Prostitutes diary
Tram sex maniac 2 (H) rar bag12
Ashlynn Video4
网络管理员第三版
金山office2007
Such love down(擒爱记)
好色的外科大夫
Boxer vs Yellow1
qq published in(发表于) 2014/7/11 9:29:46 Edit(编辑)
在GDI+中绘制和克隆图像

在GDI+中绘制和克隆图像

在GDI+中绘制和克隆图像

在GDI+中绘制和克隆图像

1.绘制图像

在绘制图像时,可以使用Bitmap类对象指定Image图像,然后调用Graphics类中的DrawImage方法进行绘制。DrawImage方法为可重载方法,它主要用来在指定位置绘制指定的Image图像,其常用格式有以下3种。

(1)在指定的位置按原始大小绘制指定的Image图像。

语法:

public void DrawImage (

Image image,

Point point)

参数说明如下。

image:要绘制的Image图像。

point:Point结构,它表示所绘制图像的左上角的位置。

(2)在指定位置按指定大小绘制指定的Image图像。

语法:

public void DrawImage (

Image image,

Rectangle rect)

参数说明如下。

image:要绘制的Image图像。

rect:Rectangle结构,它指定所绘制图像的位置和大小。

(3)在指定位置按指定大小绘制指定Image图像的指定部分。

语法:

public void DrawImage (

Image image,

Point[] destPoints,

Rectangle srcRect,

GraphicsUnit srcUnit)

DrawImage方法中各参数及说明如表1所示。



表1 DrawImage方法各参数及说明

示例

绘制图像

本示例中,当程序运行时,单击【绘制图像】按钮,在窗体中的指定位置根据已创建的Bitmap对象绘制一幅指定大小的图像。示例运行结果如图1所示。



图1 绘制图像

Form1窗体中,在【绘制图像】按钮的Click事件中分别声明Graphics类和Bitmap类的两个实例对象,然后调用Graphics对象的DrawImage方法,在窗体中根据已创建的Bitmap对象绘制一幅指定大小的图像。【绘制图像】按钮的Click事件代码如下:

private void button1_Click(object sender, EventArgs e)

{

Graphics graphics = this.CreateGraphics();

Bitmap bitmap = new Bitmap("image.jpg");

graphics.DrawImage(bitmap, 20, 20, 180, 130);

}

完整程序代码如下:

★ ★★★★Form1.cs窗体代码文件完整程序代码★★★★★

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

namespace _6_17

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)

{

Graphics graphics = this.CreateGraphics();

Bitmap bitmap = new Bitmap("image.jpg");

graphics.DrawImage(bitmap, 20, 20, 180, 130);

}

}

}

★ ★★★★Form1.Designer.cs窗体设计文件完整程序代码★★★★★

namespace _6_17

{

partial class Form1

{

///



/// 必需的设计器变量。

///


private System.ComponentModel.IContainer components = null;

///

/// 清理所有正在使用的资源。

///


/// 如果应释放托管资源,为 true;否则为 false。

protected override void Dispose(bool disposing)

{

if (disposing && (components != null))

{

components.Dispose();

}

base.Dispose(disposing);

}

#region Windows 窗体设计器生成的代码

///

/// 设计器支持所需的方法 - 不要

/// 使用代码编辑器修改此方法的内容。

///


private void InitializeComponent()

{

this.button1 = new System.Windows.Forms.Button();

this.SuspendLayout();

//

// button1

//

this.button1.Location = new System.Drawing.Point(65, 155);

this.button1.Name = "button1";

this.button1.Size = new System.Drawing.Size(75, 23);

this.button1.TabIndex = 0;

this.button1.Text = "绘制图像";

this.button1.UseVisualStyleBackColor = true;

this.button1.Click += new System.EventHandler(this.button1_Click);

//

// Form1

//

this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);

this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;

this.ClientSize = new System.Drawing.Size(222, 189);


添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.