questions about resource reusing
Last post 05-11-2008 9:45 PM by CaCO3. 2 replies.
Sort Posts:
05-11-2008 12:02 AM
questions about resource reusing

what does the BitmapImage class do?is it load a stream and create an image in memory,or it`s just adapt a stream to a control?

i mean,after these code be executed: 

            StreamResourceInfo png = ...
            BitmapImage bmp = new BitmapImage();
            bmp.SetSource(png.Stream);
            BitmapImage bmp2 = new BitmapImage();
            bmp2.SetSource(png.Stream);

            image1.Source = bmp;
            image2.Source = bmp2;

now how many memory have been cost?size of png.Stream,or twice size?

CaCO3

Joined on 04-27-2008
Posts 22
05-11-2008 9:37 PM
Marked as Answer
Re: questions about resource reusing

CaCO3,

Looking in Reflector, it appears that the SetSource method on BitmapImage actually runs through the stream and copies it to a byte array.  So, in your example, two separate byte arrays would be allocated.  One for bmp and one for bmp2.

If this has answered your question, please click on "Mark as Answer" on this post.

Thanks,
Page Brooks, MCSD, MCAD
PageBrooks.com | RSS Feed

pbrooks

Joined on 03-23-2006
Florence, SC
Posts 116
05-11-2008 9:45 PM
Re: Re: questions about resource reusing

thanks pbrooks.

that`s mean i can not work this way because i`m trying make multiple Images share a same bitmap.

now i have no idea about this,can you help?

CaCO3

Joined on 04-27-2008
Posts 22