当前位置: 首页>>代码示例>>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;未经允许,请勿转载。