Note that there are some explanatory texts on larger screens.

plurals
  1. POBitmap creation gets all-black when generating lots of them
    text
    copied!<p>I'm working with Delphi 7 and I have to generate a lot of bitmaps from a FlashMovie embedded in my Delphi application. Definition of the pictures is 1010x720.</p> <p>When I generate more than 6000 pictures (the number is different everytime), I get an EOutOfResources exception. I've looked around and it seems that it could come from a lack of available handles.</p> <p>Here is the code:</p> <pre><code>var FFlashPlayerControlExport:TFlashPlayerControl; Bmp:TBitmap; pPNG:TPNGObject; begin Bmp := FFlashPlayerControlExport.CreateFrameBitmap; Bmp.Width := StrToInt(aArgs[5]); Bmp.Height := StrToInt(aArgs[6]); pPNG := TPNGObject.Create; pPNG.Assign(Bmp); pPNG.SaveToFile(sFileName); pPNG.Free; DeleteObject(Bmp.Handle); Bmp.Free; end; </code></pre> <p>I have tried CloseHandle(Bmp.Handle) just before Bmp.Free but I'm getting an EExternalException.</p> <p>Thank you all for your help!</p> <hr> <p>UPDATE 06 Dec 2012 :</p> <p>Thanks to Arioch'The's answer, I tried to set the Width and Height of FFlashPlayerControlExport directly instead of using Bmp.Width and Bmp.Height It helped because now I don't get a EOutOfResources exception but the CreateFrameBitmap saves an all-black picture after a while.</p> <p>FlashPlayerControl is still running because I see the picture on the screen.</p> <p>Code update : </p> <pre><code>var FFlashPlayerControlExport:TFlashPlayerControl; Bmp:TBitmap; pPNG:TPNGObject; begin FFlashPlayerControlExport.Width := StrToInt(aArgs[5]); FFlashPlayerControlExport.Height := StrToInt(aArgs[6]); Bmp := FFlashPlayerControlExport.CreateFrameBitmap; pPNG := TPNGObject.Create; pPNG.Assign(Bmp); pPNG.SaveToFile(sFileName); pPNG.Free; Bmp.Free; end; </code></pre> <hr> <p>UPDATE 20 Dec 2012 :</p> <p>After contacting the FlashPlayerControl developper team, I found out that the bitmaps become black when the application reaches 10.000 GDI objects. They provided an effective help with my problem, contacting them is efficient :)</p> <p>I eventually found out that the GDI objects leak comes from another parallel part of my code. This subject is close :)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload