473,765 Members | 2,070 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"Out of Memory" on Graphics.FromIm age()

Hello, all.

This line has been pestering me, and I can't seem to figure out why the
problem is occuring. I'm trying to paint a GraphicsPath onto a Bitmap,
using the Graphics class, but it always seems to crash, and throw the
"Out of Memory" exception when it comes to the point I need the create
the object. I've been fairly strict with IDisposable.Dis pose(), and
the 'using' as well. It always seems to be at this exact line, when
the exception is thrown, no matter how much memory I seem to have. I
have no recursive procedures, and this isn't at all deep within the
call stack (6 in, according to the debugger). The bitmap is pretty
large, at 6400x4800x16, but the same problem exists at 800x600x16.
Graphics g = Graphics.FromIm age(this.Bitmap )


Nov 17 '05 #1
2 15184

<yo****@gmail.c om> wrote in message
news:11******** **************@ g44g2000cwa.goo glegroups.com.. .
Hello, all.

This line has been pestering me, and I can't seem to figure out why the
problem is occuring. I'm trying to paint a GraphicsPath onto a Bitmap,
using the Graphics class, but it always seems to crash, and throw the
"Out of Memory" exception when it comes to the point I need the create
the object. I've been fairly strict with IDisposable.Dis pose(), and
the 'using' as well. It always seems to be at this exact line, when
the exception is thrown, no matter how much memory I seem to have. I
have no recursive procedures, and this isn't at all deep within the
call stack (6 in, according to the debugger). The bitmap is pretty
large, at 6400x4800x16, but the same problem exists at 800x600x16.
Graphics g = Graphics.FromIm age(this.Bitmap )


Guess your problem is due to the pixelformat, the PixelFormat16bp pARGB1555,
and PixelFormat16bp pGrayScale are not supported by GDI+.

excerp from Image.FromFile documentation:
Remarks:
If the file does not have a valid image format or if GDI+ does not support
the pixel format of the file, this method throws an OutOfMemoryExce ption
exception.


Willy.
Nov 17 '05 #2
Yep, that did it. Figures, PixelFormat16bp pARGB1555 was the perfect
format for what I'm trying to do. Any idea if, and when this (and the
other GDI+ glitches) will be corrected?

Willy Denoyette [MVP] wrote:
<yo****@gmail.c om> wrote in message
news:11******** **************@ g44g2000cwa.goo glegroups.com.. .
Hello, all.

This line has been pestering me, and I can't seem to figure out why the
problem is occuring. I'm trying to paint a GraphicsPath onto a Bitmap,
using the Graphics class, but it always seems to crash, and throw the
"Out of Memory" exception when it comes to the point I need the create
the object. I've been fairly strict with IDisposable.Dis pose(), and
the 'using' as well. It always seems to be at this exact line, when
the exception is thrown, no matter how much memory I seem to have. I
have no recursive procedures, and this isn't at all deep within the
call stack (6 in, according to the debugger). The bitmap is pretty
large, at 6400x4800x16, but the same problem exists at 800x600x16.
Graphics g = Graphics.FromIm age(this.Bitmap )


Guess your problem is due to the pixelformat, the PixelFormat16bp pARGB1555,
and PixelFormat16bp pGrayScale are not supported by GDI+.

excerp from Image.FromFile documentation:
Remarks:
If the file does not have a valid image format or if GDI+ does not support
the pixel format of the file, this method throws an OutOfMemoryExce ption
exception.


Willy.


Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
6665
by: Snake Djip | last post by:
Hi, I have a problem with a home-made DLL used in an ASP environment. It is coded in VB6, apartment-threaded. The DLL returns a binary PNG stream (an image). I use it with ASP's Response.BinaryWrite to display a dynamic image on a web page. The server is Windows 2000 SP4.
0
4070
by: John Bonds | last post by:
I have designed a multi-threaded application that manipulates images (CCITT Group 4 TIFF Images). I'm getting some strange behavior and I'm wondering if anyone else is seeing the same thing. I run a batch process that reads in pages of one of these TIFF files, separates them out into different TIFF files, saves them to a file (in a new thread) and disposes properly of all the memory that was used. I run this batch process and monitor the...
11
5277
by: Shane Suebsahakarn | last post by:
Hi all, This might be one of those things for which there is no workaround. I'm using A2K2, and using it to perform a very large batch ouput. Both the front and back ends are MDB files, so no SQL Server involved here. Both SP3 and Jet SP8 have been updated, and the platform is running on a dual-processor 3Ghz Xeon Win2K3 Server box with 2GB RAM. The batch run outputs 6 or 7 reports to approximately 16-17,000 snapshot files None of the...
10
4705
by: schears | last post by:
Why? Running on windows 2000 with all updates, 2G Memory, 117G Hard Drive space available. This was not an issue until I added some code to two of my c files. Any suggestions? Thanks
1
2276
by: Alex Chan | last post by:
Hi Group, I have written a window service wtih SAP.NET Connector which is to fulfil request from SAP client. SAP client will call a function exposed by my window service that has a big "out" parameter. That "out" parameter is of class SAPTable, you can regard that as DataTable. As everytime SAP client issue request to my window service, it will connect to oracle and do some searching and return the result in a SAPTable. I did a volume...
2
1914
by: WJScott69 | last post by:
C# - CSharp - WIN32 - WMI Progamming Issues with NT4 (Out of Memory) Hello, I am trying to inquire on servers ranging from Windows NT4 SP6a+ to Windows 2000-2003 I have the program working fine on all but the NT4 where I get a Out of Memory error. Please take a look at the enclosed project and let me know how I go about resolving this. I can get results from NT4 server but dont seem to be able to collect everything I need. I have even...
4
6876
by: Rachel McConnell | last post by:
Hello, I have a Java web application using Hibernate to connect to a PostgreSQL backend. I am seeing the below stack trace during processing of a set of data consisting of around 1000 objects; for a 200 object set I don't see the exception. I believe the salient point is the Out Of Memory bit - marked below by *****'s The fact that this exception occurs during a call to
4
6938
by: lawrence k | last post by:
I've a jpeg image that is 514k, which doesn't strike me as very large. Yet I'm running out of error when I try to resize it: Fatal error: Allowed memory size of 20971520 bytes exhausted (tried to allocate 12288 bytes) in /home/httpd/vhosts/monkeyclaus.org/httpdocs/media/audio/pdsIncludes/resizeImageToSquare.php on line 82 How can I protect against out-of-memory errors?
6
4499
by: Scott Gravenhorst | last post by:
Windows XP SP3 My application is set to open a SaveFile dialog when an exit is requested. When I click the app's close button, the save dialog opens, but when I click to change the folder, the exception occurs pointing to FileSaveDialog1.ShowDialog(). The exception also indicates some problem with system.drawing.dll. The exception text is: "Attempted to read or write protected memory. This is often an
0
9568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10164
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10007
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9959
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9835
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7379
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5277
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2806
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.