Re: Out of Memory Exception on DrawImage

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Bill Woodruff (billw)
Date: 11/12/04

  • Next message: Mark Redman: "Re: Out of Memory Exception on DrawImage"
    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


  • Next message: Mark Redman: "Re: Out of Memory Exception on DrawImage"

    Relevant Pages

    • Re: Out of Memory Exception on DrawImage
      ... I have looked at the ImageFast Library, are you suggesting, loading the file ... DrawImage) or re-write the crop/scale function using a unmanaged DrawImage ... > to get satisfactory loading and performance, but internal memory use is ... > spite of Bob Powell's dire warnings, creating the Graphics object off this ...
      (microsoft.public.dotnet.framework.drawing)
    • Common Music problem
      ... I cut and paste some sample code. ... No file or port class for ... Men on a lower level of understanding, when brought into contact with phenomena of a higher order, instead of making efforts to understand them, to raise themselves up to the point of view from which they must look at the subject, judge it from their lower standpoint, and the less they understand what they are talking about, the more confidently and unhesitatingly they pass judgment on it. ...
      (comp.lang.lisp)