According to this -> https://social.msdn.microsoft.com/Forums/vstudio/en-US/58710bdd-4832-4531-a50a-b83a7e733cdd/maximum-size-of-a-writeablebitmap-systemwindowsmediaimagingwritablebitmap?forum=wpf
The maximum height and width of an image is 2^16 pixels at 32 bits per channel * 4 channels. The maximum size of a BitmapSource is 2^32 bytes (64 gigabytes) >and the maximum image size is four gigapixels. The minimum image size is 1x1.
The max size is (2^16)^2 = 4,294,967,296 pixels
Each pixel is 4 bytes per channel, and with four channels (A/R/G/B), that’s 16 bytes.
So the max size in bytes would be 16 * 4,294,967,296 = 68,719,476,736 bytes = 64 gigabytes.
However, I'm only able to go as high as
System.Windows.Media.Imaging.WriteableBitmap wbit = new WriteableBitmap(32000, 32000, 97, 97, PixelFormats.Bgra32, null);
If I go higher, for example to 33,000 x 33,000, the constructor throws a System.OverflowException: The image data generated an overflow during processing. ---> System.ArithmeticException: Overflow or underflow in the arithmetic operation.
My computer has 32GB of memory, running Windows 8.1, VS , and this is a .NET 4.5 console application, targeting 64-bit platform, and gcAllowVeryLargeObjects has been enabled in App.Config so this is not a problem related with .NET Maximum Object Size of 2GB. I can create an array of integers as large as 15GB in this application.
Additionally, I'm referencing PresentationCore, PresentationFramework, and WindowsBase to get access to WIC, which are all located inside C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5\ which alarmed me at first because it was in the x86 directory but as I understand it, these are only used to retrieve metadata, and the real assemblies actually being used are in the GAC, so for example, in Windows 8.1 Pro, there is both 32bit and 64bit PresentationCore are at C:\Windows\assembly\NativeImages_v4.0.30319_32\PresentationCore\24f6c80242420a1cea5cc254bf420027 and at C:\Windows\assembly\NativeImages_v4.0.30319_64\PresentationCore\7a22d69ccf672cec14abf04d9551b3a0 respectively. Same type of deal goes for PresentationFramework and WindowsBase, and I'm not 100% on this, but I think application is probably using the 64-bit versions of these assemblies in the GAC even though the reference assemblies in the reference assemblies directory are being referenced.
Does anyone know how I can construct a WriteableBitmap at its maximum resolution of 2^16 which is 65,536 x 65,536 or what I am doing wrong?