Solved

JPEG image problem

Posted on 2011-09-08
13
398 Views
Last Modified: 2012-05-12
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
0
Comment
Question by:LeTay
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 6
13 Comments
 
LVL 25

Expert Comment

by:epasquier
ID: 36502187
Please tell us which Delphi version you use, post the image, and why not a small project reproducing that same error
0
 

Author Comment

by:LeTay
ID: 36502209
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
 
LVL 25

Expert Comment

by:epasquier
ID: 36502450
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:LeTay
ID: 36502525
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
 
LVL 25

Expert Comment

by:epasquier
ID: 36502593
hum. So the TImage is not trying to load the original JPG file but a transformed one, by your dll ?
0
 

Author Comment

by:LeTay
ID: 36502632
Something like that
It worked for years ! (10 years, 10.000 images per year)
0
 

Author Comment

by:LeTay
ID: 36503418
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
 

Author Comment

by:LeTay
ID: 36503445
More .... I open the "guilty" JPEG file with Paint ... I save it like that ... I rerun the program ... it works on it !
0
 
LVL 25

Accepted Solution

by:
epasquier earned 500 total points
ID: 36507731
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
 
LVL 25

Expert Comment

by:epasquier
ID: 36507749
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
 

Author Comment

by:LeTay
ID: 36508658
Hello epasquier
I have Delphi 2009
What is Delphi XE ?
0
 
LVL 25

Expert Comment

by:epasquier
ID: 36510360
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
 

Author Comment

by:LeTay
ID: 36510515
Many thanks and of course you get the points
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question