釋放這個 Graphics 所使用的所有資源。Releases all resources used by this Graphics.

public:

virtual void Dispose();

public void Dispose ();

abstract member Dispose : unit -> unit

override this.Dispose : unit -> unit

Public Sub Dispose ()

實作

範例

下列程式碼範例是設計用來搭配 Windows Forms 使用,它需要 PaintEventArgs e 是 Paint 事件處理常式的參數。The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, which is a parameter of the Paint event handler. 此程式碼會執行下列動作:The code performs the following actions:

Image從範例目錄中的圖形檔案 SampImag.jpg 建立。Creates an Image from a graphics file SampImag.jpg in the example directory.

藉由填滿矩形內的矩形來改變影像。Alters the image by filling a rectangle within it.

將繪製 Image 到螢幕。Draws the Image to the screen.

Releases the created Graphics.

private:

void FromImageImage1( PaintEventArgs^ e )

{

// Create image.

Image^ imageFile = Image::FromFile( "SampImag.jpg" );

// Create graphics object for alteration.

Graphics^ newGraphics = Graphics::FromImage( imageFile );

// Alter image.

newGraphics->FillRectangle( gcnew SolidBrush( Color::Black ), 100, 50, 100, 100 );

// Draw image to screen.

e->Graphics->DrawImage( imageFile, PointF(0.0F,0.0F) );

// Release graphics object.

delete newGraphics;

}private void FromImageImage1(PaintEventArgs e)

{

// Create image.

Image imageFile = Image.FromFile("SampImag.jpg");

// Create graphics object for alteration.

Graphics newGraphics = Graphics.FromImage(imageFile);

// Alter image.

newGraphics.FillRectangle(new SolidBrush(Color.Black), 100, 50, 100, 100);

// Draw image to screen.

e.Graphics.DrawImage(imageFile, new PointF(0.0F, 0.0F));

// Release graphics object.

newGraphics.Dispose();

}Private Sub FromImageImage1(ByVal e As PaintEventArgs)

' Create image.

Dim imageFile As Image = Image.FromFile("SampImag.jpg")

' Create graphics object for alteration.

Dim newGraphics As Graphics = Graphics.FromImage(imageFile)

' Alter image.

newGraphics.FillRectangle(New SolidBrush(Color.Black), 100, _

50, 100, 100)

' Draw image to screen.

e.Graphics.DrawImage(imageFile, New PointF(0.0F, 0.0F))

' Dispose of graphics object.

newGraphics.Dispose()

End Sub

備註

呼叫可 Dispose 讓這個所使用的資源重新配置以 Graphics 供其他用途使用。Calling Dispose allows the resources used by this Graphics to be reallocated for other purposes.

適用於

java graphics dispose_Graphics.Dispose 方法 (System.Drawing) | Microsoft Docs相关推荐

  1. java rect offset_Rect.Offset 方法 (System.Windows) | Microsoft Docs

    傳回矩形,這個矩形是使用所指定水平和垂直數量從指定之矩形位移的矩形.Returns a rectangle that is offset from the specified rectangle by ...

  2. java中的dispose()方法

    java中的dispose()方法 先来看看 JAVA 1.5 的帮助文档的原文 - dispose - public void dispose() ****** 释放由此 Window.其子组件及其 ...

  3. java中的dispose函数_[转载]java中的dispose()方法

    这是我第100篇IT技术文章,也正好让我实现了一个完整的从客户端输入参数,使用遗传算法计算生产排程的实例,前端由客户输入种群大小,遗传代数,交叉概率,变异概率,零件数,机器数,时间矩阵,机器矩阵,经运 ...

  4. java enum.isdefined_Enum.IsDefined 方法 (System) | Microsoft Docs

    返回一个布尔值,该值指示给定的整数值或其名称字符串是否存在于指定的枚举中.Returns a Boolean telling whether a given integral value, or it ...

  5. java graphics.drawstring_Graphics.DrawString 方法

    MSDN上的解释: 在指定位置而且用指定的 public void DrawString( string s, Font font, Brush brush, float x, float y ) M ...

  6. php xmlreader nodetype,XmlNodeReader.NodeType 属性 (System.Xml) | Microsoft Docs

    获取当前节点的类型.Gets the type of the current node. public: virtual property System::Xml::XmlNodeType NodeT ...

  7. php xmlreader nodetype,XmlReader.NodeType 属性 (System.Xml) | Microsoft Docs

    当在派生类中被重写时,获取当前节点的类型.When overridden in a derived class, gets the type of the current node. public: ...

  8. java中dispose什么意思_java中的dispose()方法

    先来看看 JAVA 1.5 的帮助文档的原文 – dispose – public void dispose() 释放由此 Window.其子组件及其拥有的所有子组件所使用的所有本机屏幕资源.即这些 ...

  9. dispose方法的使用

    java中的dispose()方法 从JAVA 1.5 的帮助文档的原文 - dispose - public void dispose() 释放由此 Window.其子组件及其拥有的所有子组件所使用 ...

最新文章

  1. 2011图灵新春特献
  2. MySQL 性能跟踪语句
  3. 每日一皮:在同一个项目上工作2年的样子...
  4. html电池百分比,显示电池百分比在哪设置
  5. 斐波那契数列算法分析
  6. python的6种基本数据类型--字典
  7. SQL SERVER 2012修改数据库名称(包括 db.mdf 名称的修改)
  8. mysql数据库主要用来做什么的_水晶头骨用来做什么的?
  9. stm32f103r6最小系统原理图_超强PCB布线设计经验谈附原理图
  10. 大学计算机课程设计日历,课程设计题三:日历和数字钟
  11. 利用openpyxl模块来操作Excel
  12. 对计算机的硬盘进行高级格式化,牛刀初试 高级格式化硬盘完全体验
  13. python中面向对象空间时间_零基础老男孩学Python|面向对象之类的空间问题
  14. Hierarchical line matching based on Line–Junction–Line structure
  15. 如何利用第三方数据进行大数据分析
  16. 禁止root,处理错误 sudo must be owned by uid 0
  17. windows sesrver2003下搭建DHCP服务器
  18. 计算机结构工程专业,我是学计算机的,我想问一下怎么考结构工程师
  19. CPLEX——关键字
  20. chrome谷歌浏览器script标签引入CLODOP CLodopfuncs.js 跨域报错

热门文章

  1. Tricks(三十六)—— remove_list_entry(无需 if 逻辑)
  2. python inspect —— 查看类的继承体系
  3. python爬虫抓取分页_Scrapy爬虫框架之Scrapy爬取分页数据(一)
  4. java 创建类带泛型_java-创建泛型类列表
  5. ssms 缺少索引信息_疯象网:都说二十世纪信息值钱,其实二十一世纪的信息更值钱...
  6. python的第三方库是干什么用的-python一些工作用到的第三方库
  7. python和java学哪个好-Python和Java该学哪个?还在纠结的你看过来呀~
  8. python有趣小程序-你用python写过那些好玩的微信小程序?
  9. 用python画玫瑰花-使用Python画一朵玫瑰花
  10. iOS利用Speech Kit实现语音识别