Click here to Skip to main content
14,333,745 members
Rate this:
Please Sign up or sign in to vote.
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:

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:

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

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

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.
   

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100