Kodak Photo CD Library Fix


Description

Kodak's PhotoCD library is used by imaging programs like Paint Shop Pro, and ThumbsPlus to load PhotoCD images. This library has a flaw that causes highlight information to be lost in your images. The PhotoCD Library Fix is a new version of the library that fixes the problem.

The following is an image I got back on PhotoCD. When I opened it in Photoshop, I was extremely disappointed. You can see why:


Adobe Photoshop

Then I tried opening the same image in ThumbsPlus and had much better results. By fixing the PhotoCD library, I was able to get even better results as you can see here:


Standard PCDLIB32.DLL
Loaded with ThumbsPlus

Fixed PCDLIB32.DLL

See the "Problem Description" section below if you still aren't convinced. Also, see my description of the "Lost Highlights" problem on my PhotoCD page.

Once you install this fix, you will get darker images when you load PhotoCD files. This is because the extra highlight information pushes the rest of the image toward black. This is easily fixed by using Levels in Photoshop to set the white point you really want. Then if you really want to compress the highlights a bit, use Curves or adjust the gamma in Levels. The result will be much better than letting Kodak squash your highlights for you.

Note that this fix is not sanctioned by Kodak in any way. In fact, they deny there is a problem at all, at the same time that they admit there is a problem in PCD-042.

Special requirements

Download

PCDLIB32.DLL Installation

Note: If you use IrfanView, skip to the section on IrfanView below.

At this point, you'll have to manually install this fix, so you'll need to be familiar with using Windows Explorer to rename and copy files on your computer. Walk through these steps to make sure you understand what needs to be done. I will not be responsible for any damage that is done. If this seems too difficult, try Picture Window to get the same effect.

To uninstall:

Note that if you install a new imaging program or upgrade an old one, it might install its own PCDLIB32.DLL. This can be tricky to deal with. The new software might add a new DLL, or overwrite the fixed one. The right thing to do is to uninstall this fix before installing the new software. Then reinstall the fix after the new software has been installed.

I really would like to write an installer to make this an automated process. It would really help.

PCDLIB.DLL Installation

Installing the older PCDLIB.DLL is essentially the same as installing PCDLIB32.DLL. Just follow the above directions, but replace "PCDLIB32.DLL" with "PCDLIB.DLL" wherever it occurs.

Installation for Users of IrfanView

IrfanView (3.25) also uses PCDLIB32.DLL, but it has been renamed to PHOTOCD.DLL. You can safely do the same. Search for IrfanView's version of PHOTOCD.DLL on your hard drive, and rename it to PHOTOCD.DLL.ORIGINAL, then rename my fixed PCDLIB32.DLL to PHOTOCD.DLL. Note that IrfanView only uses PHOTOCD.DLL when loading PCD images at 1024x1536 and up. Thanks to Hari Vattyam for figuring this out.

Reported Issues

One user has reported that the patched DLL doesn't work well with ThumbsPlus 7. I've not verified this as I no longer use PhotoCD. Let me know if you have a similar experience.

Problem Description

I can understand that many people won't believe that some unknown guy fixed a previously unknown problem in a multi-billion dollar corporation's product. So here's a list of the facts so you can decide for yourself. Bear in mind that you can always go back to using the original PhotoCD Library that came with your imaging software at any time if you find the results unsatisfactory.

Version Information

There are several versions of Kodak's PhotoCD library. I think my version is very recent. If it causes trouble with your software, remove it and let me know so I can investigate.

The patched version of PCDLIB.DLL is based on the 4/20/93 version that can be found with Corel's Photo CD Lab.

Acknowledgements

Thanks to Jonathan G. Bressel for doing the PCDLIB.DLL patch.

Thanks to everyone who has emailed to say, "Gee, it works!". I'm glad I'm not alone in thinking Kodak is crazy.

Links

Technical Info

If you want to do the patch yourself, there are 3 lookup tables in the DLL version I have. They are really easy to find since the compression of the highlights appears as a string of hex 'ff' values at the end of the table. Two of the tables are 512 bytes long, and the other is 256 bytes long. The second of the 512 byte LUTs is the culprit. On mine, the contents are as follows (starting at offset 2eb58):

2eb50 72 00 00 00 00 00 00 00 02 03 04 05 06 07 08 09     r...............
2eb60 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 17 18     ................
2eb70 19 1a 1b 1c 1d 1e 20 21 22 23 24 25 26 27 28 29     ...... !"#$%&'()
2eb80 2a 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 35 36 37     **+,-./012345567
2eb90 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 44 45 46     89:;<=>?@ABCDDEF
2eba0 47 48 49 4a 4a 4b 4c 4d 4e 4f 50 50 51 52 53 54     GHIJJKLMNOPPQRST
2ebb0 55 56 57 58 59 5a 5a 5b 5c 5d 5e 5f 60 61 62 62     UVWXYZZ[\]^_`abb
2ebc0 63 64 65 66 67 68 69 6a 6a 6b 6c 6d 6e 6f 70 71     cdefghijjklmnopq
2ebd0 71 72 73 74 75 76 77 77 78 79 7a 7b 7c 7d 7e 7e     qrstuvwwxyz{|}~~
2ebe0 7f 80 81 82 83 84 84 85 86 87 88 89 8a 8b 8b 8c     ................
2ebf0 8d 8e 8f 90 91 91 92 93 94 95 96 97 98 98 99 9a     ................
2ec00 9b 9c 9d 9e 9e 9f a0 a1 a2 a3 a4 a4 a5 a6 a7 a8     ................
2ec10 a9 aa aa ab ac ad ae af b0 b0 b1 b2 b3 b4 b5 b6     ................
2ec20 b6 b7 b8 b9 ba bb bc bc bd be bf c0 c1 c2 c3 c3     ................
2ec30 c4 c5 c6 c7 c8 c9 ca ca cb cc cd ce cf d0 d0 d1     ................
2ec40 d2 d3 d4 d5 d6 d6 d7 d8 d9 da db db dc dd de df     ................
2ec50 e0 e0 e1 e2 e3 e3 e4 e5 e6 e6 e7 e8 e9 ea ea eb     ................
2ec60 eb ec ed ed ee ef ef f0 f0 f1 f2 f2 f3 f3 f4 f4     ................
2ec70 f5 f5 f5 f6 f6 f7 f7 f7 f8 f8 f9 f9 f9 fa fa fa     ................
2ec80 fa fb fb fb fb fb fc fc fc fc fc fc fd fd fd fd     ................
2ec90 fd fd fd fd fe fe fe fe fe fe fe fe fe fe fe fe     ................
2eca0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff     ................
2ecb0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff     ................
2ecc0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff     ................
2ecd0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff     ................
2ece0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff     ................
2ecf0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff     ................
2ed00 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff     ................
2ed10 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff     ................
2ed20 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff     ................
2ed30 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff     ................
2ed40 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff     ................
2ed50 ff ff ff ff ff ff ff ff 00 00 00 00 00 00 00 00     ................

I then wrote a short piece of code to generate a new linear 512 byte LUT and cut and pasted it into the DLL. The table maps 0-346 to 0-255. The rest of the table is blown to 255 since it is unlikely you will get values beyond 346 from the conversion from YCC to RGB. Here's a C++ code snippet to generate the linear LUT:

FILE *pFile = fopen("temp.lut", "wb");

// Create and fill the LUT
unsigned char aLUT[512];
memset(aLUT, 255, 512);
for (int I = 0; I < 346; I++)
{
	aLUT[I] = (unsigned char)((long)I * 255 / 346);
}

// Write the LUT
fwrite(aLUT, 512, 1, pFile);

fclose(pFile);

It is possible to get values beyond 346 from the YCC to RGB conversion, so it might be a good idea if your images are still blown out to change the two "346" values in the code above to something larger. I really should have made a constant, I know.

Oh, and if anyone wants to write an installer, please do. Here are my requirements so that it is super-simple for everyone to use:

<- Back to SupaSoft.

Disclaimers: This software is provided AS-IS without warranty of any kind. Including suitability for a purpose, merchantability, or anything else you can think of. It's not even my software, it's a hack to someone else's. In fact, I don't recommend you use this software at all. I'd rather keep it as my own little secret way to get the most out of PhotoCD. You can't have it. Nyah nyah! Kodak probably hates me for this, so you should hate me too. I'm not even remotely affiliated with Kodak in any way. Well, except that I get a ton of PhotoCD's done at their lab in Gaithersburg, MD. So, forget that you ever read this page. I'll create really amazing digital images, and you will suffer. (that should cover me)

Copyright ©2007, Ted Felix. Disclaimer