473,804 Members | 3,722 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Out of memory when creating TextureBrush

Heya all!

I have a weird problem when creating a texture brush in a Paint event.
When program gets to the line where I'm creating a new TextureBrush object,
it crashes with OutOfMemory exception.

Here's the code:

private void pnl_DrawSurface _Paint(object sender,
System.Windows. Forms.PaintEven tArgs e)
{
// Set InterpolationMo de for image drawing
e.Graphics.Inte rpolationMode = InterpolationMo de.HighQualityB icubic;

base.OnPaint (e);

// Draw previewImage onto the panel
if(this.preview Image != null)
{
this.displayRec tangle = GetDisplayRecta ngle(this.previ ewImage);
this.CenterDisp layRectangle();

TextureBrush texBrush = new TextureBrush((I mage)this.previ ewImage);
e.Graphics.Fill Rectangle(texBr ush, this.displayRec tangle);
}
}

Every object is valid (displayRectang le, previewImage ... they are not
nulls).
What a heck could be a problem here ???

Thanks in advance!
Nov 16 '05 #1
2 4720
Look at your Call Stack window. I would look for your error to be caused by
some unexpected recursiveness. For instance, perhaps your
CenterDisplayRe ctangle() method is triggering another Paint event.

HTH

DalePres
MCAD, MCDBA, MCSE

"CroDude" <di***********@ zg.htnet.hr> wrote in message
news:d1******** **@news1.xnet.h r...
Heya all!

I have a weird problem when creating a texture brush in a Paint event.
When program gets to the line where I'm creating a new TextureBrush object, it crashes with OutOfMemory exception.

Here's the code:

private void pnl_DrawSurface _Paint(object sender,
System.Windows. Forms.PaintEven tArgs e)
{
// Set InterpolationMo de for image drawing
e.Graphics.Inte rpolationMode = InterpolationMo de.HighQualityB icubic;

base.OnPaint (e);

// Draw previewImage onto the panel
if(this.preview Image != null)
{
this.displayRec tangle = GetDisplayRecta ngle(this.previ ewImage);
this.CenterDisp layRectangle();

TextureBrush texBrush = new TextureBrush((I mage)this.previ ewImage); e.Graphics.Fill Rectangle(texBr ush, this.displayRec tangle);
}
}

Every object is valid (displayRectang le, previewImage ... they are not
nulls).
What a heck could be a problem here ???

Thanks in advance!

Nov 16 '05 #2
Thanks Dale! I'll look into that.

"Dale Preston" <da******@nospa m.nospam> wrote in message
news:Om******** ******@TK2MSFTN GP15.phx.gbl...
Look at your Call Stack window. I would look for your error to be caused by some unexpected recursiveness. For instance, perhaps your
CenterDisplayRe ctangle() method is triggering another Paint event.

HTH

DalePres
MCAD, MCDBA, MCSE

"CroDude" <di***********@ zg.htnet.hr> wrote in message
news:d1******** **@news1.xnet.h r...
Heya all!

I have a weird problem when creating a texture brush in a Paint event.
When program gets to the line where I'm creating a new TextureBrush

object,
it crashes with OutOfMemory exception.

Here's the code:

private void pnl_DrawSurface _Paint(object sender,
System.Windows. Forms.PaintEven tArgs e)
{
// Set InterpolationMo de for image drawing
e.Graphics.Inte rpolationMode = InterpolationMo de.HighQualityB icubic;

base.OnPaint (e);

// Draw previewImage onto the panel
if(this.preview Image != null)
{
this.displayRec tangle = GetDisplayRecta ngle(this.previ ewImage);
this.CenterDisp layRectangle();

TextureBrush texBrush = new

TextureBrush((I mage)this.previ ewImage);
e.Graphics.Fill Rectangle(texBr ush, this.displayRec tangle);
}
}

Every object is valid (displayRectang le, previewImage ... they are not
nulls).
What a heck could be a problem here ???

Thanks in advance!


Nov 16 '05 #3

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

Similar topics

5
2262
by: Jason Callas | last post by:
I was doing starting some experimenting with the GC and ran into the following odd result. I created an object and my used memory went up by almost 11k but when I cleared it and forced a collection the used memory only went down by 12 bytes. Any ideas on what else is being created or not cleaned up? Code ==> Sub Main() ' The following VB.NET code shows how memory is allocated and deallocated during object creation and destruction. ...
0
1613
by: foos | last post by:
Hello, Hopefully someone here can help me. I'm not sure what I am doing wrong, but I am getting an Out Of Memory exception when I try to use a TextureBrush. I have simplified my code to reproduce this error. Here is the code: private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { Bitmap bmp = new Bitmap(@"C:\myimage.gif");
2
2413
by: Ray Cassick \(Home\) | last post by:
I have been beating myself up over trying to locate what I thought was a memory leak in MY code but based upon what I have seen I can't be sure that it IS my fault or something strange with DOTNET. Someone here please feel free to enlighten me on this one. The code to reproduce is very simple. Done in VB.NET, One form with a button on it called cmdStart. Here is the code behind the form: Public Class Form1 Inherits...
6
2901
by: Michael Isaacs | last post by:
Regarding use of enum's, I am wondering what the cost of memory is when creating the enumeration on the calling side, and then using it on the function/method side. See example below. If I understand correctly, what is actually happening on the calling side is an instance of the enum class FavoriteSport is getting created and sent to the PrintFavorite routine with a default value of type int. Is this correct? Say I have a couple hundred uses...
7
1737
by: Jeffrey Melloy | last post by:
I have a couple users trying to install Postgres on OS X. To the best of my knowledge, both of them are using 7.4.5/10.3.5, and got identical errors while trying to init the database: Reducing the shared buffers didn't help. Any thoughts would be appreciated. Jeffrey Melloy jmelloy@visualdistortion.org
2
2374
by: Robert | last post by:
Hello javascript group readers, I have a question regarding how to prevent memory leaks in Internet Explorer when using closures. I already knew about the circular reference problem, and until now was able to prevent memory leak problems. But I needed to store DOM elements and can't solve it anymore. So I search the group archive to see if I missed any valuable information. I found some interesting articles, but somehow could not apply...
4
2797
by: Tomassus | last post by:
Hi there, I have a problem with dynamic memory allocation. I know that it would have been easier to use vectors methods, but i want to know what i do here wrong. This is one of my methods in t_Item class - I use it to store Item Objects (which are classes too). xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx class t_Item { public:
11
3188
by: Alex | last post by:
Hello all, I have a main form(say "form1") .i want to display another form(say "form2") on occuring of an event (say a button click) and want to hide it after some time so that it will again displays while occuring of the same event.I develop it by creating an object of the form2 and displays it in the event by calling form2.Show() and hide it by calling form2.Hide(). the problem is that while displaying the form2 the memory usage of...
0
1797
by: Mitch | last post by:
Im trying to do a simple 3d project and I dont want to use dx or xna. Im using DrawPoly to draw my meshes, and trying to use FillPolygon and a texturebrush to fill the polys with a image. The image do not seem to move with the poly properly, they behaive like a clipped region with the poly moving over them. I know theres a rotate method, but not sure how to track everything Any Ideas on how to setup this up? I basically do this in a loop ...
0
9704
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
10558
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...
1
10302
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
10069
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...
0
9130
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7608
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
6844
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
5503
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
2975
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.