當前位置: 首頁>>代碼示例>>Java>>正文


Java IIOMetadataNode.setAttribute方法代碼示例

本文整理匯總了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;
    }
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:25,代碼來源:BMPMetadata.java

示例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;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:29,代碼來源:JFIFMarkerSegment.java

示例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;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:26,代碼來源:ShortHistogramTest.java

示例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;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:18,代碼來源:BMPMetadata.java

示例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;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:19,代碼來源:SOSMarkerSegment.java

示例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;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:10,代碼來源:AdobeMarkerSegment.java

示例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();
}
 
開發者ID:MinesJTK,項目名稱:jtk,代碼行數:44,代碼來源:IPanel.java

示例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;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:16,代碼來源:ITXtTest.java

示例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;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:14,代碼來源:COMMarkerSegment.java

示例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;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:10,代碼來源:DQTMarkerSegment.java

示例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;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:8,代碼來源:MarkerSegment.java

示例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;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:13,代碼來源:SOFMarkerSegment.java

示例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;
    }
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:32,代碼來源:JPEGMetadata.java

示例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;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:29,代碼來源:PngCreationTimeTest.java

示例15: getNativeNode

import javax.imageio.metadata.IIOMetadataNode; //導入方法依賴的package包/類
IIOMetadataNode getNativeNode() {
    IIOMetadataNode node = new IIOMetadataNode("dri");
    node.setAttribute("interval", Integer.toString(restartInterval));
    return node;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:6,代碼來源:DRIMarkerSegment.java


注:本文中的javax.imageio.metadata.IIOMetadataNode.setAttribute方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。