-3

After many cases of trial and error, I have concluded that the only solution to a problem of mine is to find an image library which supports a certain format of JPEG images. This particular format is of Adobe and Delphi cannot seem to recognize it properly (it always comes out blue). Otherwise, the image does properly show in most other applications (windows picture viewer, ms word, paint, photoshop, etc.). Just when loaded into Delphi, the TJpegImage mis-interprets it and turns the image blue.

I have already tried TWICImage which was very close to a solution, but when using TWICImage in Windows XP, the blue image problem persists.

So now, I am looking for a library which...

  • Properly supports this not-so-standard JPEG format of Adobe
  • is Free and full open-source for at least Delphi XE2
  • is as easy to use as the current VCL graphics in Delphi (based on TGraphic)

...and would be very nice if it could...

  • have built-in capabilities of automatically saving thumbnails (in some form of cache)
    • This is for performance - we maintain 400x400 thumbnails to correspond with all originals. If a thumbnail exists, this is loaded in most cases instead of original.
  • have built-in capabilities for basic manipulation, such as rotation and background erasing

Again, the most important thing is to properly support this Adobe format of JPEG images. Refer to my previous question. And please keep in mind that we do not want something that can do 100 times more capabilities than we need (such as layering, special fx, etc.) The only reason I need this library in the first place is to fix a very peculiar problem which has become wide-spread for our customer base.

Community
  • 1
  • 1
Jerry Dodge
  • 26,858
  • 31
  • 155
  • 327
  • 5
    It took a while, but we got there in the end – David Heffernan Jan 20 '12 at 19:19
  • @DavidHeffernan Hahaha Well let me put it this way: My boss likes a wide variety of options before we decide which is best. – Jerry Dodge Jan 20 '12 at 19:24
  • Delphi XE2 has no such file `Jpeg.pas` - can't see the code. – Jerry Dodge Jan 20 '12 at 19:37
  • No. Your previous question. The one where you wanted to know how to hack the 18 bytes at the start of the header. I'd like to know if that worked. I expect that, as everybody else said, it didn't. – David Heffernan Jan 20 '12 at 19:39
  • I knew it wouldn't *after* I asked the question - went to delete it but it was already answered. My point was just the ability to read/write bytes in the file. Not necessarily to *fix* the problem. – Jerry Dodge Jan 20 '12 at 19:41
  • Just FYI: `C:\Program Files (x86)\Embarcadero\RAD Studio\9.0\source\vcl\Vcl.Imaging.jpeg.pas` in a default XE2 installation. XE2 does, in fact, have a `Jpeg.pas`. – Ken White Jan 20 '12 at 19:43
  • @Jerry, see picture I added to your post. (You can edit and delete it afterward.) Perhaps you didn't install something? – Ken White Jan 20 '12 at 19:58
  • @Ken, I don't have it either in my XE2 (nor the C sources and obj files). I thought I installed everything though (and have update 3)... – Francesca Jan 20 '12 at 21:20
  • @François - that's strange. I did an installation of RAD Studio XE (and XE2) Professional SKUs, and the file is there. The only thing I chose not to install was the BDE related stuff and the Interbase Developer's Edition; everything else was installed. ?? The image I posted (that Jerry then deleted in his edit) clearly shows it in Windows Explorer on my machine. It's also in XE, in the same location (except 8.0 instead of 9.0, of course, and without the `VCL.Imaging` prefix. – Ken White Jan 20 '12 at 21:23
  • Can anyone explain why this question got -3 votes? – Jerry Dodge Jan 20 '12 at 22:07
  • 2
    I have not voted on this question, but my guess is that the way you conducted your most recent series of questions has led to some people down-voting. – David Heffernan Jan 20 '12 at 22:53
  • That I understand - but that's also why I asked a new question. – Jerry Dodge Jan 20 '12 at 23:09

2 Answers2

4

Try the NativeJpg v.1.30, this library detects the Adobe APP14 marker and decode the JPEG image correctly, I test this library against you brown/blue image and works perfectly. even comes with a demo application which you can use to load your jpeg images and test the library before to use it.

RRUZ
  • 134,889
  • 20
  • 356
  • 483
  • +1 but Craig explained it better :D – Jerry Dodge Jan 20 '12 at 19:22
  • 3
    @JerryDodge I really suggest you this library in a [comment](http://stackoverflow.com/questions/8915466/converting-jpeg-images-to-bmp-some-images-come-out-blue/comments#comment-11153547) in your original [question](http://stackoverflow.com/questions/8915466/converting-jpeg-images-to-bmp-some-images-come-out-blue). – RRUZ Jan 20 '12 at 19:28
  • Indeed, but there are so many libraries I had to make sure the one I got was the best match for my scenario. Asked new question because I had to point out specs more clearly. – Jerry Dodge Jan 20 '12 at 19:33
4

NativeJpg, by SimDesign satisfies the at least the first three criteria, and does support lossless 90° rotations. Your test image shows correctly (brown) when laoded using it, and it supports quite a few other color spaces besides the Adobe one. Some images can be slightly different colors than Photoshop, and according to the author that's due to ambiguities in the spec; Opera and various other image viewers decode them the same way.

Most of the JPEG properties and support are exposed through its own class structures, but there is a TGraphic descendant as well. It's 100% Delphi. It was previously commercial, but it's open source now, with a BSD license, and an option to purchase support and access to beta releases.

The current version (1.32) is available in the forums.

Zoë Peterson
  • 13,094
  • 2
  • 44
  • 64
  • +1 Accepted because a) I've heard this name at least a few times now (just as RRUZ below) and b) you provide much more info about how it helps my problem. Thanks! – Jerry Dodge Jan 20 '12 at 19:21
  • 1
    Its really hard to download it for BSD-licensed code. – OnTheFly Jan 20 '12 at 19:40
  • Tell me about it. I click the "Download" link and it takes me to a random forum page which has nothing to do with downloading it. – Jerry Dodge Jan 20 '12 at 19:43
  • Nils has been releasing updates via the forums. I added a link to the thread for the current release to my answer. Unfortunately he's had some health issues, so I think he's been giving priority to working on the source over the website. – Zoë Peterson Jan 20 '12 at 19:50
  • Just realized: He supports up to DXE - and I have DXE2. It crashes in `sdFileList.pas` on line 120: `[DCC Error] sdFileList.pas(120): E2010 Incompatible types: 'PWideChar' and 'PAnsiChar'` – Jerry Dodge Jan 20 '12 at 20:30
  • sdFileList.pas is just a helper unit; it isn't used by the JPEG decoder. If you only include `NativeJpg` in your uses clause and load images using `TsdJpegGraphic` it compiles fine with XE2 (aside from some implicit conversion warnings). – Zoë Peterson Jan 20 '12 at 21:00
  • @Craig, I hoped you would chime in at some point because BeyondCompare handles those files correctly... – Francesca Jan 20 '12 at 21:22