本文整理匯總了Java中javax.imageio.metadata.IIOMetadataNode.setAttribute方法的典型用法代碼示例。如果您正苦於以下問題:Java IIOMetadataNode.setAttribute方法的具體用法?Java IIOMetadataNode.setAttribute怎麽用?Java IIOMetadataNode.setAttribute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.imageio.metadata.IIOMetadataNode
的用法示例。
在下文中一共展示了IIOMetadataNode.setAttribute方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getStandardChromaNode
import javax.imageio.metadata.IIOMetadataNode; //導入方法依賴的package包/類
protected IIOMetadataNode getStandardChromaNode() {
if ((palette != null) && (paletteSize > 0)) {
IIOMetadataNode node = new IIOMetadataNode("Chroma");
IIOMetadataNode subNode = new IIOMetadataNode("Palette");
int numComps = palette.length / paletteSize;
subNode.setAttribute("value", "" + numComps);
for (int i = 0, j = 0; i < paletteSize; i++) {
IIOMetadataNode subNode1 = new IIOMetadataNode("PaletteEntry");
subNode1.setAttribute("index", ""+i);
subNode1.setAttribute("red", "" + palette[j++]);
subNode1.setAttribute("green", "" + palette[j++]);
subNode1.setAttribute("blue", "" + palette[j++]);
if (numComps == 4 && palette[j] != 0)
subNode1.setAttribute("alpha", "" + palette[j++]);
subNode.appendChild(subNode1);
}
node.appendChild(subNode);
return node;
}
return null;
}
示例2: getNativeNode
import javax.imageio.metadata.IIOMetadataNode; //導入方法依賴的package包/類
/**
* Returns a tree of DOM nodes representing this object and any
* subordinate JFXX extension or ICC Profile segments.
*/
IIOMetadataNode getNativeNode() {
IIOMetadataNode node = new IIOMetadataNode("app0JFIF");
node.setAttribute("majorVersion", Integer.toString(majorVersion));
node.setAttribute("minorVersion", Integer.toString(minorVersion));
node.setAttribute("resUnits", Integer.toString(resUnits));
node.setAttribute("Xdensity", Integer.toString(Xdensity));
node.setAttribute("Ydensity", Integer.toString(Ydensity));
node.setAttribute("thumbWidth", Integer.toString(thumbWidth));
node.setAttribute("thumbHeight", Integer.toString(thumbHeight));
if (!extSegments.isEmpty()) {
IIOMetadataNode JFXXnode = new IIOMetadataNode("JFXX");
node.appendChild(JFXXnode);
for (Iterator<JFIFExtensionMarkerSegment> iter =
extSegments.iterator(); iter.hasNext();) {
JFIFExtensionMarkerSegment seg = iter.next();
JFXXnode.appendChild(seg.getNativeNode());
}
}
if (iccSegment != null) {
node.appendChild(iccSegment.getNativeNode());
}
return node;
}
示例3: gethISTNode
import javax.imageio.metadata.IIOMetadataNode; //導入方法依賴的package包/類
private IIOMetadataNode gethISTNode(BufferedImage bi) {
IndexColorModel icm = (IndexColorModel)bi.getColorModel();
int mapSize = icm.getMapSize();
int[] hist = new int[mapSize];
Arrays.fill(hist, 0);
Raster r = bi.getData();
for (int y = 0; y < bi.getHeight(); y++) {
for (int x = 0; x < bi.getWidth(); x++) {
int s = r.getSample(x, y, 0);
hist[s] ++;
}
}
IIOMetadataNode hIST = new IIOMetadataNode("hIST");
for (int i = 0; i < hist.length; i++) {
IIOMetadataNode n = new IIOMetadataNode("hISTEntry");
n.setAttribute("index", "" + i);
n.setAttribute("value", "" + hist[i]);
hIST.appendChild(n);
}
return hIST;
}
示例4: getStandardDataNode
import javax.imageio.metadata.IIOMetadataNode; //導入方法依賴的package包/類
protected IIOMetadataNode getStandardDataNode() {
IIOMetadataNode node = new IIOMetadataNode("Data");
String bits = "";
if (bitsPerPixel == 24)
bits = "8 8 8 ";
else if (bitsPerPixel == 16 || bitsPerPixel == 32) {
bits = "" + countBits(redMask) + " " + countBits(greenMask) +
countBits(blueMask) + "" + countBits(alphaMask);
}
IIOMetadataNode subNode = new IIOMetadataNode("BitsPerSample");
subNode.setAttribute("value", bits);
node.appendChild(subNode);
return node;
}
示例5: getNativeNode
import javax.imageio.metadata.IIOMetadataNode; //導入方法依賴的package包/類
IIOMetadataNode getNativeNode() {
IIOMetadataNode node = new IIOMetadataNode("sos");
node.setAttribute("numScanComponents",
Integer.toString(componentSpecs.length));
node.setAttribute("startSpectralSelection",
Integer.toString(startSpectralSelection));
node.setAttribute("endSpectralSelection",
Integer.toString(endSpectralSelection));
node.setAttribute("approxHigh",
Integer.toString(approxHigh));
node.setAttribute("approxLow",
Integer.toString(approxLow));
for (int i = 0; i < componentSpecs.length; i++) {
node.appendChild(componentSpecs[i].getNativeNode());
}
return node;
}
示例6: getNativeNode
import javax.imageio.metadata.IIOMetadataNode; //導入方法依賴的package包/類
IIOMetadataNode getNativeNode() {
IIOMetadataNode node = new IIOMetadataNode("app14Adobe");
node.setAttribute("version", Integer.toString(version));
node.setAttribute("flags0", Integer.toString(flags0));
node.setAttribute("flags1", Integer.toString(flags1));
node.setAttribute("transform", Integer.toString(transform));
return node;
}
示例7: paintToPng
import javax.imageio.metadata.IIOMetadataNode; //導入方法依賴的package包/類
/**
* Paints this panel to a PNG image with specified resolution and width.
* The image height is computed so that the image has the same aspect
* ratio as this panel.
* @param dpi the image resolution, in dots per inch.
* @param win the image width, in inches.
* @param fileName the name of the file to contain the PNG image.
* @throws IOException when unable to save to file.
*/
public void paintToPng(double dpi, double win, String fileName)
throws IOException
{
BufferedImage image = paintToImage((int)ceil(dpi*win));
// The two lines below are simple, but do not write resolution info to
// the PNG file. We want that info, especially for high-res images.
//File file = new File(fileName);
//ImageIO.write(image,"png",file);
Iterator<ImageWriter> i = ImageIO.getImageWritersBySuffix("png");
if (!i.hasNext())
throw new IOException("cannot get a PNG image writer");
ImageWriter iw = i.next();
FileOutputStream fos = new FileOutputStream(fileName);
ImageOutputStream ios = ImageIO.createImageOutputStream(fos);
iw.setOutput(ios);
ImageWriteParam iwp = iw.getDefaultWriteParam();
ImageTypeSpecifier its = new ImageTypeSpecifier(image);
IIOMetadata imd = iw.getDefaultImageMetadata(its,iwp);
String format = "javax_imageio_png_1.0";
IIOMetadataNode tree = (IIOMetadataNode)imd.getAsTree(format);
IIOMetadataNode node = new IIOMetadataNode("pHYs");
String dpm = Integer.toString((int)ceil(dpi/0.0254));
node.setAttribute("pixelsPerUnitXAxis",dpm);
node.setAttribute("pixelsPerUnitYAxis",dpm);
node.setAttribute("unitSpecifier","meter");
tree.appendChild(node);
imd.setFromTree(format,tree);
iw.write(new IIOImage(image,null,imd));
ios.flush();
ios.close();
fos.flush();
fos.close();
iw.dispose();
}
示例8: getNode
import javax.imageio.metadata.IIOMetadataNode; //導入方法依賴的package包/類
public IIOMetadataNode getNode() {
IIOMetadataNode iTXt = new IIOMetadataNode("iTXt");
IIOMetadataNode iTXtEntry = new IIOMetadataNode("iTXtEntry");
iTXtEntry.setAttribute("keyword", keyword);
iTXtEntry.setAttribute("compressionFlag",
isCompressed ? "true" : "false");
iTXtEntry.setAttribute("compressionMethod",
Integer.toString(compression));
iTXtEntry.setAttribute("languageTag", language);
iTXtEntry.setAttribute("translatedKeyword",
trasKeyword);
iTXtEntry.setAttribute("text", text);
iTXt.appendChild(iTXtEntry);
return iTXt;
}
示例9: getNativeNode
import javax.imageio.metadata.IIOMetadataNode; //導入方法依賴的package包/類
/**
* Returns an <code>IIOMetadataNode</code> containing the data array
* as a user object and a string encoded using ISO-8895-1, as an
* attribute.
*/
IIOMetadataNode getNativeNode() {
IIOMetadataNode node = new IIOMetadataNode("com");
node.setAttribute("comment", getComment());
if (data != null) {
node.setUserObject(data.clone());
}
return node;
}
示例10: getNativeNode
import javax.imageio.metadata.IIOMetadataNode; //導入方法依賴的package包/類
IIOMetadataNode getNativeNode() {
IIOMetadataNode node = new IIOMetadataNode("dqtable");
node.setAttribute("elementPrecision",
Integer.toString(elementPrecision));
node.setAttribute("qtableId",
Integer.toString(tableID));
node.setUserObject(new JPEGQTable(data));
return node;
}
示例11: getNativeNode
import javax.imageio.metadata.IIOMetadataNode; //導入方法依賴的package包/類
IIOMetadataNode getNativeNode() {
IIOMetadataNode node = new IIOMetadataNode("unknown");
node.setAttribute("MarkerTag", Integer.toString(tag));
node.setUserObject(data);
return node;
}
示例12: getNativeNode
import javax.imageio.metadata.IIOMetadataNode; //導入方法依賴的package包/類
IIOMetadataNode getNativeNode() {
IIOMetadataNode node = new IIOMetadataNode("componentSpec");
node.setAttribute("componentId",
Integer.toString(componentId));
node.setAttribute("HsamplingFactor",
Integer.toString(HsamplingFactor));
node.setAttribute("VsamplingFactor",
Integer.toString(VsamplingFactor));
node.setAttribute("QtableSelector",
Integer.toString(QtableSelector));
return node;
}
示例13: getStandardCompressionNode
import javax.imageio.metadata.IIOMetadataNode; //導入方法依賴的package包/類
protected IIOMetadataNode getStandardCompressionNode() {
IIOMetadataNode compression = new IIOMetadataNode("Compression");
// CompressionTypeName
IIOMetadataNode name = new IIOMetadataNode("CompressionTypeName");
name.setAttribute("value", "JPEG");
compression.appendChild(name);
// Lossless - false
IIOMetadataNode lossless = new IIOMetadataNode("Lossless");
lossless.setAttribute("value", "FALSE");
compression.appendChild(lossless);
// NumProgressiveScans - count sos segments
int sosCount = 0;
Iterator iter = markerSequence.iterator();
while (iter.hasNext()) {
MarkerSegment ms = (MarkerSegment) iter.next();
if (ms.tag == JPEG.SOS) {
sosCount++;
}
}
if (sosCount != 0) {
IIOMetadataNode prog = new IIOMetadataNode("NumProgressiveScans");
prog.setAttribute("value", Integer.toString(sosCount));
compression.appendChild(prog);
}
return compression;
}
示例14: createNativeMetadataNodeTree
import javax.imageio.metadata.IIOMetadataNode; //導入方法依賴的package包/類
public static IIOMetadataNode createNativeMetadataNodeTree() {
// Create a text node to hold tEXtEntries
IIOMetadataNode tEXtNode = new IIOMetadataNode("tEXt");
// Create tEXt entry to hold random date time
IIOMetadataNode randomTimeEntry = new IIOMetadataNode("tEXtEntry");
randomTimeEntry.setAttribute("keyword", "Creation Time");
randomTimeEntry.setAttribute("value", "21 Dec 2015,Monday");
tEXtNode.appendChild(randomTimeEntry);
// Create a tEXt entry to hold time in RFC1123 format
IIOMetadataNode rfcTextEntry = new IIOMetadataNode("tEXtEntry");
rfcTextEntry.setAttribute("keyword", "Creation Time");
rfcTextEntry.setAttribute("value", "Mon, 21 Dec 2015 09:04:30 +0530");
tEXtNode.appendChild(rfcTextEntry);
// Create a tEXt entry to hold time in ISO format
IIOMetadataNode isoTextEntry = new IIOMetadataNode("tEXtEntry");
isoTextEntry.setAttribute("keyword", "Creation Time");
isoTextEntry.setAttribute("value", "2014-12-21T09:04:30+05:30");
tEXtNode.appendChild(isoTextEntry);
// Create a root node append the text node
IIOMetadataNode root = new IIOMetadataNode("javax_imageio_png_1.0");
root.appendChild(tEXtNode);
return root;
}
示例15: getNativeNode
import javax.imageio.metadata.IIOMetadataNode; //導入方法依賴的package包/類
IIOMetadataNode getNativeNode() {
IIOMetadataNode node = new IIOMetadataNode("dri");
node.setAttribute("interval", Integer.toString(restartInterval));
return node;
}