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


Java ImageConsumer.setDimensions方法代碼示例

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


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

示例1: initConsumer

import java.awt.image.ImageConsumer; //導入方法依賴的package包/類
private void initConsumer(ImageConsumer ic) {
    if (isConsumer(ic)) {
        ic.setDimensions(width, height);
    }
    if (isConsumer(ic)) {
        ic.setProperties(properties);
    }
    if (isConsumer(ic)) {
        ic.setColorModel(model);
    }
    if (isConsumer(ic)) {
        ic.setHints(animating
                    ? (fullbuffers
                       ? (ImageConsumer.TOPDOWNLEFTRIGHT |
                          ImageConsumer.COMPLETESCANLINES)
                       : ImageConsumer.RANDOMPIXELORDER)
                    : (ImageConsumer.TOPDOWNLEFTRIGHT |
                       ImageConsumer.COMPLETESCANLINES |
                       ImageConsumer.SINGLEPASS |
                       ImageConsumer.SINGLEFRAME));
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:23,代碼來源:MemoryImageSource.java

示例2: run

import java.awt.image.ImageConsumer; //導入方法依賴的package包/類
/**
 * The runnable method for this class. This will produce an image using
 * the current RenderableImage and RenderContext and send it to all the
 * ImageConsumer currently registered with this class.
 */
public void run() {
    // First get the rendered image
    RenderedImage rdrdImage;
    if (rc != null) {
        rdrdImage = rdblImage.createRendering(rc);
    } else {
        rdrdImage = rdblImage.createDefaultRendering();
    }

    // And its ColorModel
    ColorModel colorModel = rdrdImage.getColorModel();
    Raster raster = rdrdImage.getData();
    SampleModel sampleModel = raster.getSampleModel();
    DataBuffer dataBuffer = raster.getDataBuffer();

    if (colorModel == null) {
        colorModel = ColorModel.getRGBdefault();
    }
    int minX = raster.getMinX();
    int minY = raster.getMinY();
    int width = raster.getWidth();
    int height = raster.getHeight();

    Enumeration<ImageConsumer> icList;
    ImageConsumer ic;
    // Set up the ImageConsumers
    icList = ics.elements();
    while (icList.hasMoreElements()) {
        ic = icList.nextElement();
        ic.setDimensions(width,height);
        ic.setHints(ImageConsumer.TOPDOWNLEFTRIGHT |
                    ImageConsumer.COMPLETESCANLINES |
                    ImageConsumer.SINGLEPASS |
                    ImageConsumer.SINGLEFRAME);
    }

    // Get RGB pixels from the raster scanline by scanline and
    // send to consumers.
    int pix[] = new int[width];
    int i,j;
    int numBands = sampleModel.getNumBands();
    int tmpPixel[] = new int[numBands];
    for (j = 0; j < height; j++) {
        for(i = 0; i < width; i++) {
            sampleModel.getPixel(i, j, tmpPixel, dataBuffer);
            pix[i] = colorModel.getDataElement(tmpPixel, 0);
        }
        // Now send the scanline to the Consumers
        icList = ics.elements();
        while (icList.hasMoreElements()) {
            ic = icList.nextElement();
            ic.setPixels(0, j, width, 1, colorModel, pix, 0, width);
        }
    }

    // Now tell the consumers we're done.
    icList = ics.elements();
    while (icList.hasMoreElements()) {
        ic = icList.nextElement();
        ic.imageComplete(ImageConsumer.STATICIMAGEDONE);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:68,代碼來源:RenderableImageProducer.java


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