Access violation in TJPEGImage on W2K and XP



Hi!

The following code gives an access violation - when the programme is
being closed.
I can the file is a JPG file, it is converted into a bitmap.

I create the components locally, but having them globally does not make
any difference.
The Assign is causing the problem, by removing that, I can make it
work. But that looses the fuction.

I also found, using Canvas.Draw, that just setting both height and
witdh (and by that obtaining some memory) I get the error too without
drwaing at all.

I do get: the problem is by setting the Bitmap image, by setting the
size, or assigning something to it.
I must use some memory, which causes problem when the app is being
closed.
try-except in Form.OnDestroy or anywhere else do not catch it.

I added the dotmat, free, relase, but they do not change it.

I asume the TBitmap is a part of windows.... somehow.

Can anyone help?


if (LowerCase(ExtractFileExt(sFilename)) = '.jpg') or
(LowerCase(ExtractFileExt(sFilename)) = '.jpeg') then
begin
{ delete old bitmapfile }
DeleteFile(PChar(WindowsDir + sWinImgFile));
{ converts the image }
try
BitmapImage := TBitmap.Create;
JPEGImage := TJPEGImage.Create;
if FileExists(sFilename) then
JPEGImage.LoadFromFile(sFilename)
else
JPEGImage.LoadFromFile(WindowsDir + sFilename);
BitmapImage.Assign(JPEGImage);
BitmapImage.Dormant;
BitmapImage.FreeImage;
BitmapImage.SaveToFile(WindowsDir + sWinImgFile);
BitmapImage.ReleaseHandle;
BitmapImage.Free;
JPEGImage.Free;
except
BitmapImage.Free;
JPEGImage.Free;
end;
end;

.



Relevant Pages

  • Re: Exception in creating Bitmap
    ... When you create a Bitmap from a jpg file it is uncompressed in memory and ... will require considerably more memory. ... > I have some codes as follows and it always return Exception even if the ... > Bitmap bmp = new Bitmap; ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: windows Picture & Fax viewer error
    ... > When I double click an attached jpg file in outlook, ... > enough memory to open the file". ... The jpg file is only 2MB. ... also easily be that windows picture & fax viewer has no such problem. ...
    (microsoft.public.windowsxp.general)
  • Re: Can we view a picture from its memory data?
    ... we save all data into a .jpg file and use an Image ... > Is there a way that we can pass those memory .jpg data into Image ... ' Load a picture from a byte array ... ' The function loads the array in a memory stream and then uses the ...
    (microsoft.public.vb.general.discussion)
  • Re: Bitmap class problem
    ... > I'm using the Image.FromImagefunction to load a jpg file into a bitmap ... > class and then convert it to a lower resolution. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Image has wrong colors
    ... Each frame is just a jpg file. ... LockBits gives you high speed access to the raw data in a bitmap object. ...
    (microsoft.public.dotnet.languages.csharp)