JPEG image problem

I use TImage and JPEG components in Delphi to process image files (.jpg) (galerie.dll is "my" DLL when I do that stuff)
Everything is right except on a couple of such jpg files where I get an access violation
The stack trace is this
00fb00d3 +07b galerie.dll jpeg             jpeg_read_scanlines
00fae13d +315 galerie.dll jpeg             TJPEGImage.GetBitmap
00fadc7f +00b galerie.dll jpeg             TJPEGImage.Draw
00fa597a +02a galerie.dll Graphics         TCanvas.StretchDraw
When I "open" the jpg file with standard windows tool, it looks okay
LVL 1
LeTayAsked:
Who is Participating?
 
Emmanuel PASQUIERFreelance Project ManagerCommented:
I confirm that I have the same problem with your image when I load it from an app compiled with D2007 (that I no longer have).

I'll try recompiling the app with Delphi XE, and see if something has changed. And if not, maybe try to understand a bit better what is happening.

But I'm afraid that the conclusion will be as you say : that is a one-in-a-million fluke caused by something not compliant with Delphi JPEG algo, and there is little chance for a fix. If that was worth it, you'll then have to try other JPEG componants/Lib to load the image. But I think it's not worth the trouble. Just make sure you handle the exception properly in your code and maybe log an error to tell someone to treat the file manually
0
 
Emmanuel PASQUIERFreelance Project ManagerCommented:
Please tell us which Delphi version you use, post the image, and why not a small project reproducing that same error
0
 
LeTayAuthor Commented:
Delphi 2009
Not a small project, unfortunately, and difficult to extract that part of it
I will run the application in debug to locate precisely on which instruction it fails, because what the stack trace shows is the place where my function is referenced
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
Emmanuel PASQUIERFreelance Project ManagerCommented:
can't you create a small project with just one TImage (with the same properties as in your application) and load on a button the JPG that cause problems ?
Then you check that with such a simple app you have the problem as well, then you post everything (with the JPG file)
0
 
LeTayAuthor Commented:
Not easy, the TIMage is not on a form
We have a process, part of a large application that in fact resizes a set of JPEG (generally around 800 such files) and store resized JPEG (small size) in a database and in a (medium size) other directory, using a function call in one DLL that itself invokes another one etc...
My colleague will first debug it, it is easier to locate the guilty instruction
0
 
Emmanuel PASQUIERFreelance Project ManagerCommented:
hum. So the TImage is not trying to load the original JPG file but a transformed one, by your dll ?
0
 
LeTayAuthor Commented:
Something like that
It worked for years ! (10 years, 10.000 images per year)
0
 
LeTayAuthor Commented:
Hello,
The line that creates the exception is this one :
     BMP.Canvas.StretchDraw(Rect(0,0,BMP.Width,BMP.Height),Temp.Picture.Graphic);
I attach the JPG file that creates the problem
I have another small program that asks for a JPEG file and displays is simply on a form
Running it on this JPG file creates also the exception
I think that the JPG file, even if correctly displayed with other tool, contains something that can't be easily "digested" by some Delphi component
It would of course be nice to have a fix (fixing the JPG file for example) but this is not a major problem for me as this is the first time it happens since almost 10 years
1010-1.jpg
0
 
LeTayAuthor Commented:
More .... I open the "guilty" JPEG file with Paint ... I save it like that ... I rerun the program ... it works on it !
0
 
Emmanuel PASQUIERFreelance Project ManagerCommented:
I can load it with the new application compiled with Delphi XE...

Now you have yet another excuse to ask for an upgrade :o)
0
 
LeTayAuthor Commented:
Hello epasquier
I have Delphi 2009
What is Delphi XE ?
0
 
Emmanuel PASQUIERFreelance Project ManagerCommented:
it's the new name for "Delphi 2011"

Now they released XE2 (2012). I haven't had a look at it yet, nor its features list.
0
 
LeTayAuthor Commented:
Many thanks and of course you get the points
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.