Re: DrawImage and Out Of Memory



Graphics g = Graphics.FromImage(firstBitmap);
Matrix m = new Matrix();
m.Scale(0.05, 0.05);
g.DrawImage(secondBitmap, 0, 0).

==>
g.Dispose();

after you don't use firstBitmap or secondBitmap,you should dispose them

firstBitmap.Dispose();
secondBitmap.Dispose();

"Peter Laurinc" <grbo@xxxxxxxxxx> wrote in message
news:echIgt9dFHA.3040@xxxxxxxxxxxxxxxxxxxxxxx
> Hi,
>
> I have problem with drawing large bitmaps.
>
> There is firstBitmap 32bppARGB for offscreen drawing sized cca 1000x700
> pixels.
> From file I load secondBitmap 1bppIndexed sized ccz 9000x14000. I want to
> draw second bitmap scaled to first bitmap.
>
> I get graphics from firstBitmap and set it appropiate transform matrix.
> then I use
>
> Graphics g = Graphics.FromImage(firstBitmap);
> Matrix m = new Matrix();
> m.Scale(0.05, 0.05);
> g.DrawImage(secondBitmap, 0, 0).
>
> I always get Out Of Memory on this line.
> Also in any operation with second bitmap.
> When I try to save second bitmap to BMP file, file is saved OK and is
> sized cca 16MB.
>
> Anybody helps?
>
> Thanks
>
> Peter
>


.



Relevant Pages

  • DrawImage and Out Of Memory
    ... >From file I load secondBitmap 1bppIndexed sized ccz 9000x14000. ... draw second bitmap scaled to first bitmap. ... I get graphics from firstBitmap and set it appropiate transform matrix. ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: The story: Painting bitmap to screen is slow
    ... The general "trick" behind great GDI+ performance is to do all drawing ... single bitmap to the screen. ... I heard Microsoft broke GDI acceleration for some operations in Vista. ... your configuration of Vista or graphics driver. ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: large bitmaps for printing (GDI+)
    ... None of the 16 bpp image formats work under GDI+. ... CAD drawings to plotters are usually defined in a vector graphics format ... If you have the possibility of breaking the drawing up into smaller chunks ... I allocate a 16bpp bitmap and then> draw to it. ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: Zoom in/ Zoom out images
    ... Picture control in the same dialog. ... As soon as you leave this function the destructor is called and the bitmap object is ... The drawing must be done in the OnPaint handler. ...
    (microsoft.public.vc.mfc)
  • Re: Question regarding drawing in thread and main thread.
    ... The main thread is drawing as well but isn't as important to update so ... bitmap, and post a message, and the main thread could render the bitmap, and ... handled at a higher priority than any main thread msgs, for idle, draws etc. ... > Windows API, ...
    (microsoft.public.vc.mfc)