Jump to content

Crash when rotating images with more than 2^29 pixels


Recommended Posts

If I attempt to bring up the rotate layer dialog, I get an OverflowException if the canvas size is large enough.  The error seems to happen when the total memory usage exceeds the 31 bit address space limit:

 

23170x23170 @ 4 bytes/pixel = 2^31 bytes = no crash

 

23171x23171 @ 4 bytes/pixel = 2^31 + 8 bytes = crash

 

 

Thanks!

 

 
Exception details:
 
System.OverflowException: Overflow error.
 
   at System.Drawing.Graphics.CheckErrorStatus(Int32 status)
 
   at System.Drawing.Graphics.DrawImage(Image image, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit)
 
   at PaintDotNet.Controls.PanControl.DrawToGraphics(Graphics g) in d:\src\pdn\paintdotnet\src\PaintDotNet\Controls\PanControl.cs:line 368
 
   at PaintDotNet.Controls.PanControl.CheckRenderSurface() in d:\src\pdn\paintdotnet\src\PaintDotNet\Controls\PanControl.cs:line 258
 
   at PaintDotNet.Controls.PanControl.DoPaint(Graphics g) in d:\src\pdn\paintdotnet\src\PaintDotNet\Controls\PanControl.cs:line 266
 
   at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
 
   at System.Windows.Forms.Control.WmEraseBkgnd(Message& m)
 
   at System.Windows.Forms.Control.WndProc(Message& m)
 
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
 
 
 
Link to comment
Share on other sites

Yup, reproduced it here, first try. Interesting find :) I'll file a bug

 

This text file was created because paint.net crashed. Please e-mail this to crashlog4@getpaint.net so we can diagnose and fix the problem.
 
 
 
Application version: paint.net 4.0.6 (Final 4.6.5693.28)
 
Time of crash: 2015-08-12 9:05:22 PM
 
Application uptime: 00:00:54.4001256
 
Application state: Running 
 
Working set: 343,760 KiB
 
Threads: 118
 
Install directory: C:\Program Files\paint.net
 
Current directory: C:\Program Files\paint.net
 
OS Version: 10.0.10240.0 Workstation x64
 
.NET version: CLR 4.0.30319.42000 x64, FX 4.0 4.5
 
Processor: 32x "Intel(R) Xeon(R) CPU E5-2687W 0 @ 3.10GHz" @ ~3111MHz (DEP, SSE, SSE2, SSE3, SSSE3, SSE4_1, SSE4_2, XSAVE)
 
Physical memory: 65484 MB
 
Video card: NVIDIA GeForce GTX 980 Ti (v:10DE, d:17C8, r:161), Microsoft Basic Render Driver (v:1414, d:8C, r:0)
 
Hardware acceleration: True (default: True)
 
UI animations: True
 
UI DPI: 96.00 dpi (1.00x scale)
 
UI theme: Aero/Aero + DWM (Aero.msstyles)
 
Updates: True, 2015-08-12
 
Locale: pdnr.c: en-US, hklm: en-US, hkcu: en-US, cc: en-US, cuic: en-US
 
Flags: 
 
 
 
Exception details:
 
System.OverflowException: Overflow error.
 
   at System.Drawing.Graphics.CheckErrorStatus(Int32 status)
 
   at System.Drawing.Graphics.DrawImage(Image image, RectangleF destRect, RectangleF srcRect, GraphicsUnit srcUnit)
 
   at PaintDotNet.Controls.PanControl.DrawToGraphics(Graphics g) in d:\src\pdn\paintdotnet\src\PaintDotNet\Controls\PanControl.cs:line 368
 
   at PaintDotNet.Controls.PanControl.CheckRenderSurface() in d:\src\pdn\paintdotnet\src\PaintDotNet\Controls\PanControl.cs:line 258
 
   at PaintDotNet.Controls.PanControl.DoPaint(Graphics g) in d:\src\pdn\paintdotnet\src\PaintDotNet\Controls\PanControl.cs:line 266
 
   at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
 
   at System.Windows.Forms.Control.WmEraseBkgnd(Message& m)
 
   at System.Windows.Forms.Control.WndProc(Message& m)
 
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

Assuming the rotate operation is backed by an array or similar data type, the solution may involve setting this option:

 

https://msdn.microsoft.com/en-us/library/hh285054(v=vs.110).aspx

 

This would extend the limit 4 fold to 2^31 pixels per image (~46,000x46,000) which is likely more than even I would need. 

Edited by saratoga
Link to comment
Share on other sites

It's not. That's not going to be the solution. This is GDI+ not liking the size of an image I'm passing it. Paint.NET does not use managed arrays for large allocations like that.

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...