Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / August 2007

Tip: Looking for answers? Try searching our database.

Graphics.DrawImage breaks with "Parameter is not valid"

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chris - 28 Aug 2007 15:42 GMT
Hello

I'm trying to draw a PictureBox with an image of size 40000 x 200 pixels.
Because the image width is larger or equal to 2^15, drawing the image will
crash.

Code snippet:
         Bitmap bmp = new Bitmap(40000, 200);
         pictureBox1.Image = bmp;

Exception Text:

System.ArgumentException: Parameter is not valid.
  at System.Drawing.Graphics.CheckErrorStatus(Int32 status)
  at System.Drawing.Graphics.DrawImage(Image image, Int32 x, Int32 y, Int32
width, Int32 height)
  at System.Drawing.Graphics.DrawImage(Image image, Rectangle rect)
  at System.Windows.Forms.PictureBox.OnPaint(PaintEventArgs pe)
  at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e,
Int16 layer, Boolean disposeEventArgs)
  at System.Windows.Forms.Control.WmPaint(Message& m)
  at System.Windows.Forms.Control.WndProc(Message& m)
  at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
  at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
  at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)

************** Loaded Assemblies **************
mscorlib
   Assembly Version: 2.0.0.0
   Win32 Version: 2.0.50727.832 (QFE.050727-8300)
   CodeBase:
file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
TestPbox
   Assembly Version: 1.0.2796.27090
   Win32 Version: 1.0.2796.27090
   CodeBase:
file:///C:/Documents%20and%20Settings/Christoph%20Stamm/Desktop/TestPbox/bin/Debug/TestPbox.exe
----------------------------------------
System.Windows.Forms
   Assembly Version: 2.0.0.0
   Win32 Version: 2.0.50727.832 (QFE.050727-8300)
   CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
   Assembly Version: 2.0.0.0
   Win32 Version: 2.0.50727.832 (QFE.050727-8300)
   CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
   Assembly Version: 2.0.0.0
   Win32 Version: 2.0.50727.832 (QFE.050727-8300)
   CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Configuration
   Assembly Version: 2.0.0.0
   Win32 Version: 2.0.50727.832 (QFE.050727-8300)
   CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
   Assembly Version: 2.0.0.0
   Win32 Version: 2.0.50727.832 (QFE.050727-8300)
   CodeBase:
file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
   <system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.

Signature

Thanks for help.
Chris

cody - 30 Aug 2007 16:50 GMT
> Hello
>
[quoted text clipped - 83 lines]
> will be sent to the JIT debugger registered on the computer
> rather than be handled by this dialog box.

I suppose the bitmap ist just too large for GDI. 40000 pixels is quite a
lot.
Maybe you can try to make multiple smaller bitmaps and draw one after
each other.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.