tags:

views:

830

answers:

6

i have tried to open some JPEG files in Delphi with TImage component. i also added the Jpeg unit. i can open most of jpg files and there is no problem.

but when i try to open some JPGs, the program just throw an exception.

i also tried to load that images in design mode, but there is some problem. in design mode the exception is:

Access violation at address 402672A1 in module 'vcljpeg70.bpl'. Write of address 08E84000

Why i cannot open that JPGs? they are not corrupted. i checked them in some tools like savantools EXIF viewer.

here is the URL of one of that images: http://xs842.xs.to/xs842/09340/backpic435.jpg

Thanks so much

PS: My Delphi version is 7. Borland Delphi 7

+1  A: 

I get the same error. This appears to be a bug in Delphi's JPEG lib. You should report it to QC.

Mason Wheeler
+2  A: 

Check out the Free Image library for alternative JPEG support in Delphi if the native one has problems. Free Image is an open source lib that lets you work with JPEG/PNG/... from Delphi/BCB/and others. Very nice library IMHO.

http://freeimage.sourceforge.net/

QAZ
Thanks but IMHO is really a big library. is there any simpler library/component for just showing images (just like TImage) ?
Isaac
+6  A: 

Interesting. Neither Internet Explorer nor Google Chrome will display that JPEG image you linked to. I do not get 404 Not Found errors, I simply get an image placeholder, indicating that the image could not be opened/displayed correctly.

FireFox does display the image.

Are you certain that there is not something fishy, or at least slightly unusual, about the JPG files involved?

UPDATE: The file linked to in the question opens in PaintShop Pro (an old version 6.0 installation) - if I then simply re-save as a Standard Encoding JPEG, IE and Chrome both display the newly saved image as I'd expect. There would definitely appear to be something a bit "odd-ball" about the encoding of the original JPEG that some JPEG apps can handle but not all, including some "major players", not just Delphi. :)

Deltics
Safari shows the image fine, too. Interesting problem. I think I've found this once or twice before with IE not showing certain jpegs, and always (incorrectly) assumed that there was a problem with the jpeg file itself.
robsoft
thanks for consideration!i asked this question is some "expert" forums, but nobody answered me. Stack Overflow is really great!about your answer:you are right. i also think there is something wrong with is jpeg! but there are many jpegs like this that i have to show. so, i cannot modify or fix them. i must show them as they are."Windows Picture and Fax Viewer" can show them, so why i cannot?
Isaac
+2  A: 

I've looked at the file with a hex editor, and found 3 JFIF headers. After extracting each part, I found 2 thumbnails and an image. Nothing special, because embedded thumbnails seem to be part of the EXIF2 standard.

The thumbnails themselves load fine in Delphi, and converting the file to something readable can be done with almost every piece of software that I've tried.

Anyway, this page will give you very detailed information about the picture, and what headers are inside (just paste the url of your image in the textbox):

http://www.monster-submit.com/resources/jpeganalyzer/

Wouter van Nifterick
Thanks very much. i read about EXIF2 standard that you told and it was very interesting.but i really don't want fall in details. i just want to find a way to show that JPEGs in Delphi. maybe a simple component would help me.
Isaac
+9  A: 

Hi.

The reason you may be encountering this problem is due to the file type. Delphi has issues displaying JPEG images that have been encoded using CMYK, rather than the default RGB encoding. CMYK is a format that is generally used for Print design, try and always encode your images to RGB format to avoid this issue with Delphi.

Patch for Delphi jpeg.dcu

Bye.

RRUZ
Commercial print shops are shifting to RGB (or flavors thereof such as sRGB) due to the dominance of the RGB format, and the increasing value they get from online display.
Argalatyr
+1 for the link to that patch - handy to know about.
robsoft
It really solved my problem! But the colors of images is a few different than what Microsoft Picture and Fax Viewer shows. I think this is because of Color Management stuff.
Isaac
A: 

SimDesign's NativeJpg can open that file. It's a JPEG library written entirely in Delphi, and the author has been good about adding support for new extensions and color spaces when we've run into them. In addition to a TGraphic descendant for TImage support it exposes lots of lower-level interfaces for manipulating JPEGs, though I haven't used them.

Craig Peterson
Maybe is this another good solution. But it is not a free library. i have to pay € 49,95 to show a jpeg correctly, while that jpeg could be shown by Microsoft Picture and Fax Viewer already!!Thanks however. At least i understand Delphi 7 really has problem in showing some JPEGs! ;)
Isaac