Re: Bitmap .net GDI+
Chris Anderson <[email protected]> Mon, 30 Jul 2007 22:11:25 +0100
| Newsgroups | gmane.comp.windows.devel.dotnet.web |
|---|---|
| Message-ID | <[email protected]> |
Is this an ASP.Net problem or a desktop one? The scenarios are *very* different, and although this is a web-based list, you seem to talking about a desktop app. I ask because I have done exactly what you are trying to do (Bitmap returned from a function, etc) in a web scenario and learnt a lot about how to dispose them at the right time, etc in that scenario. -----Original Message----- From: "Andrew Dunn"<[email protected]> Sent: 30/07/07 07:30:20 To: "[email protected]"<[email protected]> Subject: Re: [DOTNET-WEB] Bitmap .net GDI+ Yes, I should have mentioned that the picturebox is only one place I want to display an image. I need to display the same image in quite a few places. I may need to manipulate an image in a picturebox and then display it in another control which may need to manipulate it again. Andrew. -----Original Message----- From: Discussion of building .NET applications targeted for the Web [mailto:[email protected]] On Behalf Of Gyorgy Bozoki Sent: Monday, 30 July 2007 4:20 PM To: DOTNET-W [Message truncated. Tap Edit->Mark for Download to get remaining portion.] -----Unmodified Original Message----- Yes, I should have mentioned that the picturebox is only one place I want to display an image. I need to display the same image in quite a few places. I may need to manipulate an image in a picturebox and then display it in another control which may need to manipulate it again. Andrew. -----Original Message----- From: Discussion of building .NET applications targeted for the Web [mailto:[email protected]] On Behalf Of Gyorgy Bozoki Sent: Monday, 30 July 2007 4:20 PM To: [email protected] Subject: Re: [DOTNET-WEB] Bitmap .net GDI+ Andrew, Without knowing much detail about what you need, I'd probably derive from the picture box control and add all the necessary operations to the derived control. This way the extended picture box would have the bitmap as a private object and it could manage its lifetime. (Actually the base PictureBox would do it.) This would also ensure that whenever a caller calls the Image property, it receives it according to the original Image control. (I think callers are not supposed to call Dispose on the bitmap returned by PictureBox.Image, since the owner of the image is the control.) 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:57 > To: [email protected] > Subject: Re: [DOTNET-WEB] Bitmap .net GDI+ > > Hi, > > I read this: > http://blogs.msdn.com/ericgu/archive/2003/12/08/52964.aspx > > I need to do this quite a lot (assign picturebox.image > property) so I am worried about memory not being cleaned up. > > What I think I may do is create a class that encapsulates a > bitmap object (from your directions). From this class I can > scale, crop etc. > and when I need to assign a picturebox.image property I > return something like this... > > public class ImageWrapper:IDisposable{ > > private Bitmap _OriginalImg; > > public Bitmap OriginalImg > { > get{return new Bitmap(_OriginalImg);} > set{_OriginalImg = value;} > } > > public void Scale(){ > ....... > } > public void Crop(){ > ....... > } > > public void Dispose(){ > ....... > _OriginalImg.Dispose(); > } > > } > > Does this sound feasible? > > Regards, > > Andrew =================================== This list is hosted by DevelopMentor(r) 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 =================================== This list is hosted by DevelopMentor® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com