Re: Out of system resources



"Bart" <broersma.juda_ANTISPAM_@xxxxxxxxxx> schreef in bericht
news:s4trl2tnonkt76dkalobt46nefqadiulp9@xxxxxxxxxx
Op Thu, 16 Nov 2006 23:51:21 +0100 schreef "Tom de Neef"
<tdeneef@xxxxxxxx>:

procedure CopyImageToSize(sourceFile,destinationFile : string;
width,height
: integer);
// Read sourceFile and extract to bitmap in predetermined scale.
// Export to jpg.
var
ext : string;
bitmap : Tbitmap;
JPGimage : TjpegImage;
rect : Trect;
begin
bitmap:=Tbitmap.Create;

try
rect.Left:=0;
rect.Right:=width;
rect.Top:=0;
rect.Bottom:=height;

ext:=Uppercase(extractFileExt(sourceFile));
if (ext='.JPG') OR (ext='.JPEG') OR (ext='.BMP')
then CopyImageToBitmap(sourceFile,bitmap,rect)
else ; // skipped for this post


Just a wild guess here.
If you exit this procedure when extension is not jpg, jpeg or bmp,
then bitmap.free will not be called, so you have a memory leak???


The ELSE clause was omitted here. It handles other image extensions. No
leaks.


I've never worked with threads, so if the problem lies there, I won't
be able to give any reasonable answers...


I now think the problem is indeed related to the thread. One time I got a
different error message at the same spot: "unable to write file". That got
me thinking. The thread produces images that are called in html <img> tags.
While the thread is still active, the main thread's browser tries to load
the html, and thus it may try to read an image while it is being created or
modified.
I now redo the image at the end of the loop when it was involved in such an
error and the out of resources error never repeats.
Tom


.



Relevant Pages

  • Re: Converting a JPG to TIF in C#
    ... >> Bitmap jpgImage; ... >> BitmapData jpgBmd; ... >> BitmapData tifBmd; ... >> rows of the JPG ...
    (microsoft.public.dotnet.framework.drawing)
  • Converting a JPG to TIF in C#
    ... I needed to create a batch process to convert a large number of JPGs to TIF ... Bitmap jpgImage; ... // get the bytes of the jpg so we can read through them ... // Entries is a collection of Color objects that is generated each time ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: axWebBrowser not displaying images
    ... bitmap files still do not render but that's OK. ... Put a bitmap image in the c directory, ... Here's more...the HTML being sent to the axWebBrowser is a simple table ... Here's the code that loads the browser control: ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: for those that think jpgs are "safe"
    ... No, it wouldn't, unless you can explain how the JPG and the DLL ... you run the EXE from an unknown source, you're already screwed, JPEG ... create an HTML page, rename it to JPEG, and then open it in ... Internet Explorer, it would be rendered as a JPEG, not by it's HTML ...
    (alt.computer.security)
  • Re: Converting a JPG to TIF in C#
    ... Bob Powell ... >I needed to create a batch process to convert a large number of JPGs to TIF ... > Bitmap jpgImage; ... > // get the bytes of the jpg so we can read through them ...
    (microsoft.public.dotnet.framework.drawing)