当前位置: 首页>>代码示例>>Java>>正文


Java WritableRaster.setSamples方法代码示例

本文整理汇总了Java中java.awt.image.WritableRaster.setSamples方法的典型用法代码示例。如果您正苦于以下问题:Java WritableRaster.setSamples方法的具体用法?Java WritableRaster.setSamples怎么用?Java WritableRaster.setSamples使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.image.WritableRaster的用法示例。


在下文中一共展示了WritableRaster.setSamples方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createOverview

import java.awt.image.WritableRaster; //导入方法依赖的package包/类
private static URL createOverview(GeoImageReader gir, boolean toFlip) throws IOException {
    File f = File.createTempFile("kmloverview", ".png");
    // generate a suitable size image
    double ratio = Math.max(((double) gir.getWidth()) / 1024., ((double) gir.getHeight()) / 1024.);
    // generate overview image
    BufferedImage temp = new BufferedImage((int) (gir.getWidth() * (1.0 / ratio)), (int) (gir.getHeight() * (1.0 / ratio)), gir.getType(true));
    // get a handle on the raster data
    WritableRaster raster = temp.getRaster();
    int[] data = gir.readAndDecimateTile(0, 0, gir.getWidth(), gir.getHeight(), 1.0 / ratio, true,0);
    raster.setSamples(0, 0, temp.getWidth(), temp.getHeight(), 0, data);

    float average = 0;
    for (int i = 0; i < data.length; i++) {
        average = average + data[i];
    }
    average = average / data.length;
    RescaleOp rescale = new RescaleOp(((1 << (8 * gir.getNumberOfBytes())) / 5f / average), 0, null);
    rescale.filter(temp, temp);

    ColorConvertOp bop = new ColorConvertOp(null);
    BufferedImage out = bop.createCompatibleDestImage(temp, new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_GRAY), false, false, ComponentColorModel.OPAQUE, DataBuffer.TYPE_BYTE));
    out = bop.filter(temp, out);

    //flip the image if necessary
    if (toFlip) {
        int w = out.getWidth();
        int h = out.getHeight();
        BufferedImage dimg = new BufferedImage(w, h, out.getType());
        Graphics2D g = dimg.createGraphics();
        g.drawImage(out, 0, 0, w, h, w, 0, 0, h, null);
        g.dispose();
        ImageIO.write(dimg, "png", f);
    } else {
        ImageIO.write(out, "png", f);
    }
    return f.toURI().toURL();

}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:39,代码来源:KmlIO.java

示例2: createFrame

import java.awt.image.WritableRaster; //导入方法依赖的package包/类
private static BufferedImage createFrame(int[] palette) {
    IndexColorModel icm = new IndexColorModel(getNumBits(palette.length),
        palette.length, palette, 0, false, -1, DataBuffer.TYPE_BYTE);
    WritableRaster wr = icm.createCompatibleWritableRaster(w, h);
    int[] samples = new int[w * h];
    Arrays.fill(samples, 0);
    wr.setSamples(0, 0, w, h, 0, samples);

    BufferedImage img = new BufferedImage(icm, wr, false, null);
    return img;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:12,代码来源:LUTCompareTest.java


注:本文中的java.awt.image.WritableRaster.setSamples方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。