Re: Access violation in TJPEGImage on W2K and XP
- From: Nicholas Sherlock <n_sherlock@xxxxxxxxxxx>
- Date: Fri, 16 Sep 2005 19:50:59 +1200
jodleren wrote:
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;
Ugh. Why are you doing so many weird and wonderful calls on your bitmapimage before you save it? Your code could try to free your bitmaps/jpegs more than once. Try this:
BitmapImage := TBitmap.Create;
JPEGImage := TJPEGImage.Create;
try
if FileExists(sFilename) then
JPEGImage.LoadFromFile(sFilename)
else
JPEGImage.LoadFromFile(WindowsDir + sFilename);
BitmapImage.Assign(JPEGImage);
BitmapImage.SaveToFile(WindowsDir + sWinImgFile);
finally
BitmapImage.Free;
JPEGImage.Free;
end;You never need to touch BitmapImage/etc again, and certainly do not make them global.
Cheers, Nicholas Sherlock .
- Follow-Ups:
- Re: Access violation in TJPEGImage on W2K and XP
- From: jodleren
- Re: Access violation in TJPEGImage on W2K and XP
- References:
- Access violation in TJPEGImage on W2K and XP
- From: jodleren
- Access violation in TJPEGImage on W2K and XP
- Prev by Date: Access violation in TJPEGImage on W2K and XP
- Next by Date: Re: MSAccess CreateOLEObject problem
- Previous by thread: Access violation in TJPEGImage on W2K and XP
- Next by thread: Re: Access violation in TJPEGImage on W2K and XP
- Index(es):