本文整理汇总了Java中psd.parser.object.PsdDescriptor类的典型用法代码示例。如果您正苦于以下问题:Java PsdDescriptor类的具体用法?Java PsdDescriptor怎么用?Java PsdDescriptor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PsdDescriptor类属于psd.parser.object包,在下文中一共展示了PsdDescriptor类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: actionPerformed
import psd.parser.object.PsdDescriptor; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
FileDialog fileDialog = new FileDialog(frame, "Open psd file", FileDialog.LOAD);
// fileDialog.setDirectory("~/Downloads");
fileDialog.setFilenameFilter(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.toLowerCase().endsWith(".psd");
}
});
fileDialog.setVisible(true);
if (fileDialog.getFile() != null) {
File directory = new File(fileDialog.getDirectory());
File psdFile = new File(directory, fileDialog.getFile());
try {
Psd psd = new Psd(psdFile) {
@Override
protected Layer createLayer(LayerParser parser) {
parser.putAdditionalInformationParser(LayerTypeToolParser.TAG, new LayerTypeToolParser(new LayerTypeToolHandler() {
@Override
public void typeToolTransformParsed(Matrix transform) {
System.out.println("transform: " + transform);
}
@Override
public void typeToolDescriptorParsed(int version, PsdDescriptor descriptor) {
System.out.println("version: " + version + ", " + descriptor);
}
}));
return super.createLayer(parser);
}
};
treeLayerModel.setPsd(psd);
psdView.setPsd(psd);
} catch (IOException ex) {
throw new RuntimeException(ex);
}
}
}
示例2: parse
import psd.parser.object.PsdDescriptor; //导入依赖的package包/类
public void parse(PsdInputStream stream) throws IOException {
int length = stream.readInt();
int pos = stream.getPos();
while (length > 0) {
String tag = stream.readString(4);
if (!tag.equals(PSD_TAG) && !tag.equals("MeSa")) {
throw new IOException("Format error: Invalid image resources section.: " + tag);
}
length -= 4;
int id = stream.readShort();
length -= 2;
int sizeOfName = stream.readByte() & 0xFF;
if ((sizeOfName & 0x01) == 0)
sizeOfName++;
@SuppressWarnings("unused")
String name = stream.readString(sizeOfName);
length -= sizeOfName + 1;
int sizeOfData = stream.readInt();
length -= 4;
if ((sizeOfData & 0x01) == 1)
sizeOfData++;
length -= sizeOfData;
int storePos = stream.getPos();
// TODO FIXME Is id correct?
if (sizeOfData > 0 && tag.equals(PSD_TAG) && id >= 4000 && id < 5000) {
String key = stream.readString(4);
if (key.equals("mani")) {
stream.skipBytes(12 + 12); // unknown data
PsdDescriptor descriptor = new PsdDescriptor(stream);
if (handler != null) {
handler.imageResourceManiSectionParsed(descriptor);
}
}
}
stream.skipBytes(sizeOfData - (stream.getPos() - storePos));
}
stream.skipBytes(length - (stream.getPos() - pos));
}
示例3: parse
import psd.parser.object.PsdDescriptor; //导入依赖的package包/类
public int parse(PsdInputStream stream) throws IOException {
int length = stream.readInt();
int pos = stream.getPos();
int id = 0;
while (length > 0) {
String tag = stream.readString(4);
if (!tag.equals(PSD_TAG) && !tag.equals("MeSa")) {
throw new IOException("Format error: Invalid image resources section.: " + tag);
}
length -= 4;
// Save ID
id = stream.readShort();
length -= 2;
int sizeOfName = stream.readByte() & 0xFF;
if ((sizeOfName & 0x01) == 0)
sizeOfName++;
@SuppressWarnings("unused")
String name = stream.readString(sizeOfName);
length -= sizeOfName + 1;
int sizeOfData = stream.readInt();
length -= 4;
if ((sizeOfData & 0x01) == 1)
sizeOfData++;
length -= sizeOfData;
int storePos = stream.getPos();
// TODO FIXME Is id correct?
if (sizeOfData > 0 && tag.equals(PSD_TAG) && id >= 4000 && id < 5000) {
String key = stream.readString(4);
if (key.equals("mani")) {
stream.skipBytes(12 + 12); // unknown data
PsdDescriptor descriptor = new PsdDescriptor(stream);
if (handler != null) {
handler.imageResourceManiSectionParsed(descriptor);
}
}
}
stream.skipBytes(sizeOfData - (stream.getPos() - storePos));
}
stream.skipBytes(length - (stream.getPos() - pos));
return id;
}
示例4: getPsdDescriptor
import psd.parser.object.PsdDescriptor; //导入依赖的package包/类
public PsdDescriptor getPsdDescriptor() {
return psdDescriptor;
}
示例5: parse
import psd.parser.object.PsdDescriptor; //导入依赖的package包/类
public void parse(PsdInputStream stream) throws IOException {
int length = stream.readInt();
int pos = stream.getPos();
while (length > 0) {
String tag = stream.readString(4);
/**
* MeSa is not a valid signature anymore
* if (!tag.equals(PSD_TAG) && !tag.equals("MeSa")) {
*/
if (!tag.equals(PSD_TAG)) {
throw new IOException("Format error: Invalid image resources section.: " + tag);
}
length -= 4;
int id = stream.readShort();
length -= 2;
int sizeOfName = stream.readByte() & 0xFF;
if ((sizeOfName & 0x01) == 0)
sizeOfName++;
@SuppressWarnings("unused")
String name = stream.readString(sizeOfName);
length -= sizeOfName + 1;
int sizeOfData = stream.readInt();
length -= 4;
if ((sizeOfData & 0x01) == 1)
sizeOfData++;
length -= sizeOfData;
int storePos = stream.getPos();
// TODO FIXME Is id correct?
if (sizeOfData > 0 && tag.equals(PSD_TAG) && id >= 4000 && id < 5000) {
String key = stream.readString(4);
if (key.equals("mani")) {
stream.skipBytes(12 + 12); // unknown data
PsdDescriptor descriptor = new PsdDescriptor(stream);
if (handler != null) {
handler.imageResourceManiSectionParsed(descriptor);
}
}
}
stream.skipBytes(sizeOfData - (stream.getPos() - storePos));
}
stream.skipBytes(length - (stream.getPos() - pos));
}
示例6: imageResourceManiSectionParsed
import psd.parser.object.PsdDescriptor; //导入依赖的package包/类
public void imageResourceManiSectionParsed(PsdDescriptor descriptor);
示例7: metaDataMlstSectionParsed
import psd.parser.object.PsdDescriptor; //导入依赖的package包/类
public void metaDataMlstSectionParsed(PsdDescriptor descriptor);
示例8: typeToolDescriptorParsed
import psd.parser.object.PsdDescriptor; //导入依赖的package包/类
public void typeToolDescriptorParsed(int version, PsdDescriptor descriptor);