tags:

views:

71

answers:

1

Hi. I have this piece of code that works with all images in the world (I have tried thousands - for real) except one JPG. When I try to load that image (it opens in IrfanView without problems) I get an access violation.

aBitmap.Assign(aGraphic.Graphic)

Any ideas?


Using: Delphi 7, Win 7 32bit

A: 

It is not my code faulty.

I just opened the image in PaintShop Pro 7 and saved it back (also as JPG). No it works. It can be something wrong in Borland's code. Maybe it doesn't handle well images that are no following JPG standard? Anyway, the thing is it doesn't crash on LoadFromFile. I already secured that piece of code with TRY EXCEPT. It crashes on Assign.

Update: Looks like it was the CMYK bug: http://cc.embarcadero.com/item/19723

Altar
Borland's code is official C code from the independant JPEG group. Perhaps you went through a random issue, which is fixed since the time it was released with Delphi 7. You could use other code to load and save jpeg, for example our open source SynGdiPlus unit which could be used as a replacement for the standard jpeg unit: it allows you to read and save jpeg pictures using GDI+, shipped since Windows XP. See http://blog.synopse.info/tag/GDIPlus
A.Bouchez