Re: Out of Memory Exception on DrawImage
From: Bill Woodruff (billw)
Date: 11/12/04
- Previous message: Robert Misiak: "Re: Background drawing, BitBlt()"
- In reply to: Mark Redman: "Re: Out of Memory Exception on DrawImage"
- Next in thread: Mark Redman: "Re: Out of Memory Exception on DrawImage"
- Reply: Mark Redman: "Re: Out of Memory Exception on DrawImage"
- Reply: Bob Powell [MVP]: "Re: Out of Memory Exception on DrawImage"
- Reply: Mark Redman: "Re: Out of Memory Exception on DrawImage"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 12 Nov 2004 14:33:21 +0700
Mark,
I've been working on a project involving panning around in and zooming a fairly
large .png image (5500 x 9900) on a 1 gigabyte PIV.
I've had to put aside DrawImage and use lower level GDI calls through inter-op
to get satisfactory loading and performance, but internal memory use is still
very high, as you might expect. Justin Rogers has some good code for speeding up
bitmap loading :
http://weblogs.asp.net/justin_rogers/articles/131704.aspx
As I understand it when the raster is created internally it's converted to 32
bit pre-multiplied argb format : thus my 15 megabyte png file consumes up to 400
megs or so at run time depending on what I am doing. I have had no problems, in
spite of Bob Powell's dire warnings, creating the Graphics object off this
loaded image and re-using it. A friend of mine has examined what's going on
under the hood with the Graphics object passed in to the Paint event : he
concludes, unlike Bob's analysis, that this is the same Graphics object as one
created off the Image : it is in just a slightly different wrapper. Subjectively
I perceive performance increases by re-using the Graphics object : but I am
unable to quantify this yet : and take what I say with a grain of salt since I
personally am unable to verify and understand my friend's conclusions based on
using Reflector to examine the CLR.
At this point I have decided there is no way to construct a reasonably
performing large image viewer in .NET without going to some very lower level
code. If you are doing a project for the real world, it makes more sense to me
that you would prepare "slices" of the very large image and bring them into the
view area predictively or on-demand. Of course nothing would stop you from
loading in a big image, creating sub-sections of it and writing them out as
files, and then using those sub-sections after having disposed of the "big
image" if you've got the memory resources to do that.
best, Bill Woodruff
dotScience
- Previous message: Robert Misiak: "Re: Background drawing, BitBlt()"
- In reply to: Mark Redman: "Re: Out of Memory Exception on DrawImage"
- Next in thread: Mark Redman: "Re: Out of Memory Exception on DrawImage"
- Reply: Mark Redman: "Re: Out of Memory Exception on DrawImage"
- Reply: Bob Powell [MVP]: "Re: Out of Memory Exception on DrawImage"
- Reply: Mark Redman: "Re: Out of Memory Exception on DrawImage"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|