Re: Out of system resources



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???



JPGimage:=TjpegImage.Create;
try
JPGimage.Assign(bitmap);
JPGimage.CompressionQuality:=60;
JPGimage.SaveToFile(destinationFile); // <------- if ERROR, then it
will happen here
except
end;
JPGimage.free

finally
bitmap.free
end;
end;


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

Bart
--
Bart Broersma
broersma.juda_ANTISPAM_@xxxxxxxxxx
(ff _ANTISPAM_ wegpoetsen uit dit adres natuurlijk)
.



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: 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)
  • Re: Out of system resources
    ... // Read sourceFile and extract to bitmap in predetermined scale. ... If you exit this procedure when extension is not jpg, jpeg or bmp, ... I've never worked with threads, so if the problem lies there, I won't ... The thread produces images that are called in html tags. ...
    (comp.lang.pascal.delphi.misc)
  • Re: Problem saving a bitmap object to a .bmp file in Visual .NET C++
    ... But won't this simply save a bitmap with extension .jpg? ... The program that gives me an error message is Corel PhotoPaint, ...
    (sci.image.processing)