请教一下各位,tif图片在picturebox里面加载的问题

kingdoom 2009-02-19 12:42:04
我用的Image.FromFile
出现了
An unhandled exception of type 'System.OutOfMemoryException' occurred in System.Drawing.dll

Additional information: Out of memory.
的错误,网上很多都说是我的tif文件有问题,不过我的tif 8m在acdsee里面能正常打开,请问怎么解决,谢谢
...全文
245 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
beyondwarrior 2011-10-11
  • 打赏
  • 举报
回复
Public Function setPicture(ByVal strFile As String, ByRef pic As PictureBox, ByVal backPic As PictureBox, ByVal lblMassage As Label) As Boolean
Try
If InStr(strFile, ".tif") > 0 Or InStr(strFile, ".TIF") > 0 Then
lblMassage.Visible = False

Application.DoEvents()

pic.Image = Nothing

'Dim guid As FrameDimension
Dim img As Image
img = Image.FromFile(strFile)
'guid = FrameDimension.Page
'img.SelectActiveFrame(guid, 0)
pic.Image = img
End If
Catch ex As Exception
Return False
End Try
Return True
End Function
dingwb 2009-02-19
  • 打赏
  • 举报
回复
文件太大了吧
jy251 2009-02-19
  • 打赏
  • 举报
回复
Out of memory

很显然picture不支持这个大(8MB)的图片显示。

如果你非要显示这么大的图片,你可以试试使用GDI来完成,C#中是GDI+

建立Image对象,通过FromFile来建。
建立好了之后,在你form的paint事件中,使用GDI+将这个image对象给画出来。
zgke 2009-02-19
  • 打赏
  • 举报
回复
.NET 可能不支持你打开的TIF格式
kingdoom 2009-02-19
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 jy251 的回复:]
Out of memory

很显然picture不支持这个大(8MB)的图片显示。

如果你非要显示这么大的图片,你可以试试使用GDI来完成,C#中是GDI+

建立Image对象,通过FromFile来建。
建立好了之后,在你form的paint事件中,使用GDI+将这个image对象给画出来。
[/Quote]
这个。。。我就是用FromFile来建的,显示的错误
kingdoom 2009-02-19
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 zgke 的回复:]
.NET 可能不支持你打开的TIF格式
[/Quote]
c#的GDI+不是说支持tif的格式吗

111,094

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧