本文介绍了尝试修改后保存图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道为什么这个源代码会抛出错误?

Dim myBitmap As System.Drawing.Bitmap

Dim myGraphics As Graphics

myBitmap = New System.Drawing.Bitmap(fileName:=" C:\ test.tif")

myGraphics = PictureBox1.CreateGraphics

Dim expansionRectangle As New Rectangle (25,550,1000,350)

Dim destRectangle1 As New Rectangle(0,0,1000,350)

myGraphics.DrawImage(myBitmap,destRectangle1,expansionRectangle,

GraphicsUnit.Pixel)

PictureBox1.Image.Save(" c:\ xx.tif")

myGraphics.Dispose()

myBitmap.Dispose()

myBitmap = Nothing

myGraphics = Nothing

does anyone know why this source code throws an error??
Dim myBitmap As System.Drawing.Bitmap
Dim myGraphics As Graphics
myBitmap = New System.Drawing.Bitmap(fileName:="C:\test.tif")
myGraphics = PictureBox1.CreateGraphics
Dim expansionRectangle As New Rectangle(25, 550, 1000, 350)
Dim destRectangle1 As New Rectangle(0, 0, 1000, 350)
myGraphics.DrawImage(myBitmap, destRectangle1, expansionRectangle,
GraphicsUnit.Pixel)
PictureBox1.Image.Save("c:\xx.tif")
myGraphics.Dispose()
myBitmap.Dispose()
myBitmap = Nothing
myGraphics = Nothing

推荐答案



它会抛出什么错误?


-




那个没有为图片框中的图像获取图形对象,它会为屏幕获取图形对象。对于图片框控件没有具体的

CreateGraphics方法,你使用的是继承自Control类的

方法。

That doesn''t get a graphics object for the image in the picture box, it
gets a graphics object for the screen. There is no specific
CreateGraphics method for the picture box control, you are using the
method inherited from the Control class.



你有没有把图像放在图片框中?这里没有代码。

Have you even put an image in the picture box? There is no code for it here.



-

G?ran Andersson

_____




这并没有为图片框中的图像获取图形对象,它为b / b $ b获取了屏幕的图形对象。对于图片框控件没有具体的

CreateGraphics方法,你使用的是继承自Control类的

方法。


That doesn''t get a graphics object for the image in the picture box, it
gets a graphics object for the screen. There is no specific
CreateGraphics method for the picture box control, you are using the
method inherited from the Control class.



你有没有把图像放在图片框中?这里没有代码。


Have you even put an image in the picture box? There is no code for it here.



-

G?ran Andersson

_____http://www.guffa.com


--
G?ran Andersson
_____http://www.guffa.com



是的,图片显示。

好​​吧,也许我有点困惑;我只是想加载TIF文件

(无论它可能是什么对象),选择一些矩形区域并将其复制

并将其保存到单独的TIFF文件中。 />
如何做到这一点?

感谢您的帮助。

yes, the picture is displayed.
ok, maybe I am little confused; I am just trying to load TIF file
(whatever object it may be in), select some rectangle area and copy it
and save it into separate TIFF file.
how hord is it to do?
thanks for your help.


这篇关于尝试修改后保存图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 08:25