Re: Bitmap .net GDI+
Gyorgy Bozoki <[email protected]> Mon, 30 Jul 2007 00:26:29 -0500
| Newsgroups | gmane.comp.windows.devel.dotnet.web |
|---|---|
| Message-ID | <000001c7d26a$2efe90f0$9cfcbb4c@homepc> |
Andrew, I normally don't return bitmaps from a class. If potential callers need to perform some operations on a bitmap owned by a class, I add those methods to the class and callers can call them. The method implementations internally use the private bitmap object and make necessary changes. If I need to return a bitmap, I normally return a copy of it - when the owner class goes out of scope, it can safely dispose it. (I rarely return bitmaps, as all the copying around takes quite a bit of work for the processor.) If the bitmap needs to be shared, I create it on a higher level and pass it as a parameter to lower level classes. This way all lower level classes can use the same bitmap, but only the higher level class can free it up. From functions within a single class (when the caller is a member of the same class), I think it's ok to return Bitmap objects, as long as the functions know when to get rid of it. HTH, Gyorgy Bozoki > -----Original Message----- > From: Discussion of building .NET applications targeted for > the Web [mailto:[email protected]] On Behalf Of > Andrew Dunn > Sent: Monday, July 30, 2007 12:15 > To: [email protected] > Subject: [DOTNET-WEB] Bitmap .net GDI+ > > Hi, > > Does anyone have a reliable method of when to correctly > dispose of bitmap objects. ie - should i return a Bitmap > object as a class property? What is best practices? > > > Thank you > > > Andrew > > =================================== > This list is hosted by DevelopMentor. http://www.develop.com > > View archives and manage your subscription(s) at > http://discuss.develop.com > =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com