A codec to read Kodak Photo-CD (image pac) image files.
Typical file extension is
.pcd
.
PCD is designed to store the same image in several resolutions.
Not all resolutions are always present in a file.
Typically, the first five resolutions are available and the file size
is between four and six megabytes.
Lossless compression (Huffman encoding) is used to store the higher resolution images.
All images are in 24 bit YCbCr colorspace, with a component subsampling of 4:1:1 (Y:Cb:Cr)
in both horizontal and vertical direction.
Limitations
Only the lowest three resolutions are supported by this codec.
Sample PCD files
You can download sample PCD image files from
Kodak's
website.
MAGIC
private static final byte[] MAGIC
NO_ROTATION
private static final int NO_ROTATION
PCD_FILE_OFFSETS
private static final long[] PCD_FILE_OFFSETS
PCD_RESOLUTIONS
public static final int[][] PCD_RESOLUTIONS
This two-dimensional int array holds all possible pixel resolutions for
a PCD file. Use one of the PCD resolution constants (e.g.
PCD_RESOLUTION_3
as first index.
The second index must be 0 or 1 and leads to either width or
height.
Example:
PCD_RESOLUTION[PCD_RESOLUTION_3][1]
will evalute
as 512, which can be width or height, depending on the image being
in landscape or portrait mode.
You may want to use these resolution values in your program
to prompt the user which resolution to load from the file.
PCD_RESOLUTION_1
public static final int PCD_RESOLUTION_1
Base/16, the minimum pixel resolution, 192 x 128 pixels.
PCD_RESOLUTION_2
public static final int PCD_RESOLUTION_2
Base/4, the second pixel resolution, 384 x 256 pixels.
PCD_RESOLUTION_3
public static final int PCD_RESOLUTION_3
Base, the third pixel resolution, 768 x 512 pixels.
PCD_RESOLUTION_4
public static final int PCD_RESOLUTION_4
Base*4, the fourth pixel resolution, 1536 x 1024 pixels. Unsupported
PCD_RESOLUTION_5
public static final int PCD_RESOLUTION_5
Base*16, the fifth pixel resolution, 3072 x 2048 pixels. Unsupported
PCD_RESOLUTION_6
public static final int PCD_RESOLUTION_6
Base*64, the sixth pixel resolution, 6144 x 4096 pixels. Unsupported
PCD_RESOLUTION_DEFAULT
public static final int PCD_RESOLUTION_DEFAULT
ROTATE_180
private static final int ROTATE_180
ROTATE_90_LEFT
private static final int ROTATE_90_LEFT
ROTATE_90_RIGHT
private static final int ROTATE_90_RIGHT
SECTOR_SIZE
private static final int SECTOR_SIZE
data
private byte[][] data
in
private RandomAccessFile in
monochrome
private boolean monochrome
numChannels
private int numChannels
performColorConversion
private boolean performColorConversion
resolutionIndex
private int resolutionIndex
allocateMemory
private byte[][] allocateMemory()
convertToRgb
private void convertToRgb(int width,
int height)
createImage
private IntegerImage createImage(int width,
int height)
loadUncompressedImage
private void loadUncompressedImage(int resolution)
throws IllegalArgumentException,
IOException
Loads one of the three lowest resolution images from the file.
First skips as many bytes as there are between the current
stream offset and the offset of the image in the PCD file
(first three images are at fixed positions).
Then reads the pixels from in to data.
Note that there are
width
times
height
samples for Y, but only one fourth that many samples for each Cb and Cr
(because of the 4:1:1 subsampling of the two chroma components).
resolution
- one of PCD_RESOLUTION_1, PCD_RESOLUTION_2 or PCD_RESOLUTION_3
rotateArrays
private void rotateArrays(int rotationAngle,
int width,
int height)
setColorConversion
public void setColorConversion(boolean performColorConversion)
Specify whether color is converted from PCD's YCbCr color space to
RGB color space.
The default is
true
, and you should only change this
if you really know what you are doing.
If you simply want the luminance (gray) channel, use
setMonochrome(boolean)
with
true
as parameter.
performColorConversion
- boolean that determines whether color conversion is applied
setMonochrome
public void setMonochrome(boolean monochrome)
Specifies whether the image is to be loaded as gray or color image.
If argument is true, only the gray channel is loaded.
setResolutionIndex
public void setResolutionIndex(int resolutionIndex)