Re: Bitmap .net GDI+

Andrew Dunn <[email protected]> Mon, 30 Jul 2007 16:24:25 +1000
Newsgroups gmane.comp.windows.devel.dotnet.web
Message-ID <5B2CE496DCCE2040B271D9417E72CB2822BD84@bdbdc2.corporate.hcn.com.au>
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