Click here to Skip to main content
15,867,704 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a large .tiff,about 2.2G, I want to change it to png or jpg in C#/GDI+,but when I load it,it throws "Parameter is valid","Array dimensions exceeded supported range".

What I have tried:

I try it like this:

C#
byte[] buffer = null;
using (FileStream fs = new FileStream(file, FileMode.Open, FileAccess.Read))
{
    buffer = new byte[fs.Length];
    fs.Read(buffer, 0, (int)fs.Length);
}


... or like this:

C#
FileStream pngStream = new FileStream(file, FileMode.Open, FileAccess.Read);
var image = new Bitmap(pngStream)
Posted
Updated 9-Oct-19 1:33am
v3

1 solution

You can't: Creating a File Mapping Object - Windows applications | Microsoft Docs[^]
Quote:
The size of a file mapping object that is backed by a named file is limited by disk space. The size of a file view is limited to the largest available contiguous block of unreserved virtual memory. This is at most 2 GB minus the virtual memory already reserved by the process.
And since your tiff files exceeds that, and tiff is a compressed format, you cannot use GDI+ to load that file at all.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900