Fixed some alignment issues in the resources.

This commit is contained in:
Harald Kuhr 2009-09-16 00:10:45 +02:00
parent 4baafd2e4d
commit 40a5960a9f
4 changed files with 6 additions and 2 deletions

View File

@ -425,6 +425,7 @@ public class PSDImageReader extends ImageReaderBase {
if (mImageResources == null) { if (mImageResources == null) {
mImageResources = new ArrayList<PSDImageResource>(); mImageResources = new ArrayList<PSDImageResource>();
long expectedEnd = mImageInput.getStreamPosition() + length; long expectedEnd = mImageInput.getStreamPosition() + length;
while (mImageInput.getStreamPosition() < expectedEnd) { while (mImageInput.getStreamPosition() < expectedEnd) {
PSDImageResource resource = PSDImageResource.read(mImageInput); PSDImageResource resource = PSDImageResource.read(mImageInput);
mImageResources.add(resource); mImageResources.add(resource);

View File

@ -52,6 +52,7 @@ class PSDImageResource {
mSize = pInput.readUnsignedInt(); mSize = pInput.readUnsignedInt();
readData(pInput); readData(pInput);
// Data is even-padded // Data is even-padded
if (mSize % 2 != 0) { if (mSize % 2 != 0) {
pInput.read(); pInput.read();
@ -128,7 +129,7 @@ class PSDImageResource {
public static PSDImageResource read(final ImageInputStream pInput) throws IOException { public static PSDImageResource read(final ImageInputStream pInput) throws IOException {
int type = pInput.readInt(); int type = pInput.readInt();
if (type != PSD.RESOURCE_TYPE) { if (type != PSD.RESOURCE_TYPE) {
throw new IIOException("Wrong image resource type, expected 8BIM: " + PSDUtil.intToStr(type)); throw new IIOException(String.format("Wrong image resource type, expected '8BIM': '%s'", PSDUtil.intToStr(type)));
} }
// TODO: Process more of the resource stuff, most important are IPTC, EXIF and XMP data, // TODO: Process more of the resource stuff, most important are IPTC, EXIF and XMP data,

View File

@ -35,7 +35,7 @@ final class PSDPrintFlags extends PSDImageResource {
mInterpolate = pInput.readUnsignedByte() != 0; mInterpolate = pInput.readUnsignedByte() != 0;
mCaption = pInput.readUnsignedByte() != 0; mCaption = pInput.readUnsignedByte() != 0;
pInput.readUnsignedByte(); // Pad pInput.skipBytes(mSize - 8);
} }
@Override @Override

View File

@ -28,6 +28,8 @@ final class PSDPrintFlagsInformation extends PSDImageResource {
mField = pInput.readUnsignedByte(); mField = pInput.readUnsignedByte();
mBleedWidth = pInput.readUnsignedInt(); mBleedWidth = pInput.readUnsignedInt();
mBleedScale = pInput.readUnsignedShort(); mBleedScale = pInput.readUnsignedShort();
pInput.skipBytes(mSize - 10);
} }
@Override @Override