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


Java ColorConvertOp.createCompatibleDestImage方法代碼示例

本文整理匯總了Java中java.awt.image.ColorConvertOp.createCompatibleDestImage方法的典型用法代碼示例。如果您正苦於以下問題:Java ColorConvertOp.createCompatibleDestImage方法的具體用法?Java ColorConvertOp.createCompatibleDestImage怎麽用?Java ColorConvertOp.createCompatibleDestImage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.image.ColorConvertOp的用法示例。


在下文中一共展示了ColorConvertOp.createCompatibleDestImage方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: ICCProfileColorConverter

import java.awt.image.ColorConvertOp; //導入方法依賴的package包/類
/**
 * Creates a new ICCProfileColorConverter.
 *
 * @param img the image
 * @param cs  the color space
 */
public ICCProfileColorConverter(ConvenientBufferedImageWrapper img, ColorSpace cs) {
    ColorConvertOp transform = new ColorConvertOp(null);

    int[] bits = new int[cs.getNumComponents()];
    Arrays.fill(bits, SIGNIFICANT_BITS);
    BufferedImage temp = transform.createCompatibleDestImage(img.getBufferedImage(),
                                                             new ComponentColorModel(cs, bits,
                                                                                     img.getColorModel().hasAlpha(),
                                                                                     img.getColorModel().isAlphaPremultiplied(),
                                                                                     img.getColorModel().getTransparency(),
                                                                                     DataBuffer.TYPE_INT)
    );

    temp = transform.filter(img.getBufferedImage(), temp);

    this.img = new ConvenientBufferedImageWrapper(temp);
}
 
開發者ID:datascience,項目名稱:photohawk,代碼行數:24,代碼來源:ICCProfileColorConverter.java

示例2: createOverview

import java.awt.image.ColorConvertOp; //導入方法依賴的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

示例3: Context

import java.awt.image.ColorConvertOp; //導入方法依賴的package包/類
public Context(TestEnvironment env, Result res) {

            graphics = (Graphics2D)env.getGraphics();
            cs = getColorSpace(env);

            // TODO: provide rendering hints
            op_img = new ColorConvertOp(cs, null);
            ColorSpace sRGB = ColorSpace.getInstance(ColorSpace.CS_sRGB);
            op_rst = new ColorConvertOp(sRGB, cs, null);

            int size = env.getIntValue(sizeList);

            ImageContent content = (ImageContent)env.getModifier(contentList);
            ImageType srcType = (ImageType)env.getModifier(sourceType);

            src = createBufferedImage(size, size, content, srcType.type);
            rsrc = src.getRaster();

            ImageType dstType = (ImageType)env.getModifier(destinationType);
            if (dstType == ImageType.COMPATIBLE_DST) {
                dst = op_img.createCompatibleDestImage(src, null);
            } else {
                dst = createBufferedImage(size, size, content, dstType.type);
            }
            // raster always has to be comatible
            rdst = op_rst.createCompatibleDestRaster(rsrc);
        }
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:28,代碼來源:ColorConvertOpTests.java


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