C#打开tif文件时内存溢出(System.OutOfMemoryException)解决办法
2020-12-13 14:38
标签:style blog http io color os ar 使用 for 原创性声明 此博文的出处 为http://blog.csdn.net/zhujunxxxxx/article/details/40649887如果进行转载请注明出处。本文作者原创,邮箱zhujunxxxxx@163.com,如有问题请联系作者 我在做一个统计图片长和宽的软件时遇到一个问题,本来是用的 程序竟然在创建Image类型时出现内存溢出(System.OutOfMemoryException) 错误代码: System.Drawing.Image myimg=System.Drawing.Image.FromFile(file.FullName); 当打开的文件不是图像文件时会引发的异常: 或者出现 Bitmap System.ArgumentException: 参数无效问题 这其实不是程序的问题,而是系统中内存的问题,或者图片太大了,大于65535像素了。 我测试 2G内存 BitMap最大 5000*5000,反正这个BitMap大小和机器配置有关。 win7 64位 16G内存最大 23200*23200 由于 GDI+ 解码器的限制,如果使用单维大小大于 65,535 像素的 .png 图像文件构造位图,将引发 System.ArgumentException。
C#打开tif文件时内存溢出(System.OutOfMemoryException)解决办法 标签:style blog http io color os ar 使用 for 原文地址:http://blog.csdn.net/zhujunxxxxx/article/details/40649887前言
Image img = null;
img = Image.FromFile(f.FullName);
w = img.Width;
h = img.Height;
错误问题
获取TIF图片的长和宽
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.IO;
namespace ImageSize
{
public class ReadTIF:IDisposable
{
#region 读入TIF图像的变量设置
/// 使用方法
ReadTIF rt = new ReadTIF();
rt.TifFile(f.FullName);
w = rt.GetW();
h = rt.GetH();
文章标题:C#打开tif文件时内存溢出(System.OutOfMemoryException)解决办法
文章链接:http://soscw.com/essay/34300.html