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


Java SinglePixelPackedSampleModel.getBitMasks方法代碼示例

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


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

示例1: getAlignedImage

import java.awt.image.SinglePixelPackedSampleModel; //導入方法依賴的package包/類
/**
 * Returns a width- and height-aligned image representation sharing data w/ {@link #image}.
 * @param width
 * @param height
 * @return
 * @throws IllegalArgumentException if requested size exceeds image size
 */
public BufferedImage getAlignedImage(final int width, final int height) throws IllegalArgumentException {
    if( width * height > image.getWidth() * image.getHeight() ) {
        throw new IllegalArgumentException("Requested size exceeds image size: "+width+"x"+height+" > "+image.getWidth()+"x"+image.getHeight());
    }
    if( width == image.getWidth() && height == image.getHeight() ) {
        return image;
    } else {
        final ColorModel cm = image.getColorModel();
        final WritableRaster raster0 = image.getRaster();
        final DataBuffer dataBuffer = raster0.getDataBuffer();
        final SinglePixelPackedSampleModel sppsm0 = (SinglePixelPackedSampleModel) raster0.getSampleModel();
        final SinglePixelPackedSampleModel sppsm1 = new SinglePixelPackedSampleModel(dataBuffer.getDataType(),
                    width, height, width /* scanLineStride */, sppsm0.getBitMasks());
        final WritableRaster raster1 = Raster.createWritableRaster(sppsm1, dataBuffer, null);
        return new BufferedImage (cm, raster1, cm.isAlphaPremultiplied(), null);
    }
}
 
開發者ID:jedwards1211,項目名稱:breakout,代碼行數:25,代碼來源:AWTGLPixelBuffer.java

示例2: transformS

import java.awt.image.SinglePixelPackedSampleModel; //導入方法依賴的package包/類
@Override
synchronized void transformS(WritableRaster iwr, WritableRaster ewr) {
    synchronized (this) {
        if (BMl == null) {// || BMm == null || BOl == null || BOm == null
            // initialization of raster band configuration (should only occur once)
            SinglePixelPackedSampleModel SMl = (SinglePixelPackedSampleModel)ewr.getSampleModel();
            SinglePixelPackedSampleModel SMm = (SinglePixelPackedSampleModel)iwr.getSampleModel();
            BMl = SMl.getBitMasks();
            BMm = SMm.getBitMasks();
            BOl = SMl.getBitOffsets();
            BOm = SMm.getBitOffsets();
        }
        // get source pixels in an array
        iwr.getDataElements(lurd[0], lurd[1], lensWidth, lensHeight, oPixelsS);
        // get magnified source pixels in a second array
        ewr.getDataElements(0, 0, mbw, mbh, mPixelsS);
        // transfer them to the target array taking the gain function into account
        for (int x = lurd[0]; x < lurd[2]; x++) {
            for (int y = lurd[1]; y < lurd[3]; y++) {
                /*
                 * SPATIAL DISTORTION
                 */
                /*
                 * gain is computed w.r.t main buffer pixels
                 * (we do not want to compute the gain for pixels that won't be in the output)
                 */
                this.gf(x, y, gain);
                ti = (y - lurd[1]) * (lensWidth) + (x - lurd[0]);
                tmPixelsS[ti] =
                    mPixelsS[Math.round(((y - lurd[1]) * MM - hmbh) / gain[1] + hmbh) * mbw + Math.round(((x - lurd[0]) * MM - hmbw) / gain[0] + hmbw)];
                toPixelsS[ti] =
                    oPixelsS[(Math.round((((float)y - sh - ly) / gain[1]) + sh + ly) - lurd[1]) * (lensWidth) + (Math.round((((float)x - sw - lx) / gain[0]) + sw + lx) - lurd[0])];
                /*
                 * ALPHA BLENDING
                 */
                // get pixel from lens raster
                Pl = tmPixelsS[ti];
                Rl = (Pl & BMl[0]) >>> BOl[0];
                Gl = (Pl & BMl[1]) >>> BOl[1];
                Bl = (Pl & BMl[2]) >>> BOl[2];
                // get pixel from main raster
                Pm = toPixelsS[ti];
                Rm = (Pm & BMm[0]) >>> BOm[0];
                Gm = (Pm & BMm[1]) >>> BOm[1];
                Bm = (Pm & BMm[2]) >>> BOm[2];
                // compute contribution from each pixel, for each band
                // Use the Porter-Duff Source Atop Destination rule to achieve our effect.
                // Fs = Ad and Fd = (1-As), thus:
                //   Cd = Cs*Ad + Cd*(1-As)
                //   Ad = As*Ad + Ad*(1-As) = Ad
                this.gfT(x, y, gainT);
                Rr = Math.round(Rl * gainT[0] + Rm * (1 - gainT[0]));
                Gr = Math.round(Gl * gainT[0] + Gm * (1 - gainT[0]));
                Br = Math.round(Bl * gainT[0] + Bm * (1 - gainT[0]));
                // set new pixel value in target raster
                tPixelsS[ti] = (short)((Rr << BOm[0]) | (Gr << BOl[1]) | (Br << BOl[2]));
            }
        }
        // transfer pixels in the target array back to the raster
        iwr.setDataElements(lurd[0], lurd[1], lensWidth, lensHeight, tPixelsS);
    }
}
 
開發者ID:sharwell,項目名稱:zgrnbviewer,代碼行數:63,代碼來源:XLinearLens.java

示例3: transformI

import java.awt.image.SinglePixelPackedSampleModel; //導入方法依賴的package包/類
@Override
synchronized void transformI(WritableRaster iwr, WritableRaster ewr) {
    synchronized (this) {
        if (BMl == null) {
            // || BMm == null || BOl == null || BOm == null
            // initialization of raster band configuration (should only occur once)
            SinglePixelPackedSampleModel SMl = (SinglePixelPackedSampleModel)ewr.getSampleModel();
            SinglePixelPackedSampleModel SMm = (SinglePixelPackedSampleModel)iwr.getSampleModel();
            BMl = SMl.getBitMasks();
            BMm = SMm.getBitMasks();
            BOl = SMl.getBitOffsets();
            BOm = SMm.getBitOffsets();
        }
        // get source pixels in an array
        iwr.getDataElements(lurd[0], lurd[1], lensWidth, lensHeight, oPixelsI);
        // get magnified source pixels in a second array
        ewr.getDataElements(0, 0, mbw, mbh, mPixelsI);
        // transfer them to the target array taking the gain function into account
        if (BMl.length == 4) {
            // the sample model features four bands
            for (int x = lurd[0]; x < lurd[2]; x++) {
                for (int y = lurd[1]; y < lurd[3]; y++) {
                    this.gf(x, y, gain);
                    // get pixel from lens raster
                    Pl = mPixelsI[Math.round(((y - lurd[1]) * MM - hmbh) / gain[1] + hmbh) * mbw + Math.round(((x - lurd[0]) * MM - hmbw) / gain[0] + hmbw)];
                    Rl = (Pl & BMl[0]) >>> BOl[0];
                    Gl = (Pl & BMl[1]) >>> BOl[1];
                    Bl = (Pl & BMl[2]) >>> BOl[2];
                    // get pixel from main raster
                    Pm = oPixelsI[(y - lurd[1]) * (lensWidth) + (x - lurd[0])];
                    Rm = (Pm & BMm[0]) >>> BOm[0];
                    Gm = (Pm & BMm[1]) >>> BOm[1];
                    Bm = (Pm & BMm[2]) >>> BOm[2];
                    Am = (Pm & BMm[3]) >>> BOm[3];
                    // compute contribution from each pixel, for each band
                    // Use the Porter-Duff Source Atop Destination rule to achieve our effect.
                    // Fs = Ad and Fd = (1-As), thus:
                    //   Cd = Cs*Ad + Cd*(1-As)
                    //   Ad = As*Ad + Ad*(1-As) = Ad
                    this.gfT(x, y, gainT);
                    Rr = Math.round(Rl * gainT[0] + Rm * (1 - gainT[0]));
                    Gr = Math.round(Gl * gainT[0] + Gm * (1 - gainT[0]));
                    Br = Math.round(Bl * gainT[0] + Bm * (1 - gainT[0]));
                    // set new pixel value in target raster
                    tPixelsI[(y - lurd[1]) * (lensWidth) + (x - lurd[0])] = (Rr << BOm[0]) | (Gr << BOl[1]) | (Br << BOl[2]) | (Am << BOl[3]);
                }
            }
        } else {
            // the sample model probably features 3 bands
            for (int x = lurd[0]; x < lurd[2]; x++) {
                for (int y = lurd[1]; y < lurd[3]; y++) {
                    this.gf(x, y, gain);
                    // get pixel from lens raster
                    Pl = mPixelsI[Math.round(((y - lurd[1]) * MM - hmbh) / gain[1] + hmbh) * mbw + Math.round(((x - lurd[0]) * MM - hmbw) / gain[0] + hmbw)];
                    Rl = (Pl & BMl[0]) >>> BOl[0];
                    Gl = (Pl & BMl[1]) >>> BOl[1];
                    Bl = (Pl & BMl[2]) >>> BOl[2];
                    // get pixel from main raster
                    Pm = oPixelsI[(y - lurd[1]) * (lensWidth) + (x - lurd[0])];
                    Rm = (Pm & BMm[0]) >>> BOm[0];
                    Gm = (Pm & BMm[1]) >>> BOm[1];
                    Bm = (Pm & BMm[2]) >>> BOm[2];
                    // compute contribution from each pixel, for each band
                    // Use the Porter-Duff Source Atop Destination rule to achieve our effect.
                    // Fs = Ad and Fd = (1-As), thus:
                    //   Cd = Cs*Ad + Cd*(1-As)
                    //   Ad = As*Ad + Ad*(1-As) = Ad
                    this.gfT(x, y, gainT);
                    Rr = Math.round(Rl * gainT[0] + Rm * (1 - gainT[0]));
                    Gr = Math.round(Gl * gainT[0] + Gm * (1 - gainT[0]));
                    Br = Math.round(Bl * gainT[0] + Bm * (1 - gainT[0]));
                    // set new pixel value in target raster
                    tPixelsI[(y - lurd[1]) * (lensWidth) + (x - lurd[0])] = (Rr << BOm[0]) | (Gr << BOl[1]) | (Br << BOl[2]);
                }
            }
        }
        // transfer pixels in the target array back to the raster
        iwr.setDataElements(lurd[0], lurd[1], lensWidth, lensHeight, tPixelsI);
    }
}
 
開發者ID:sharwell,項目名稱:zgrnbviewer,代碼行數:81,代碼來源:HLinearLens.java

示例4: transformS

import java.awt.image.SinglePixelPackedSampleModel; //導入方法依賴的package包/類
@Override
synchronized void transformS(WritableRaster iwr, WritableRaster ewr) {
    synchronized (this) {
        if (BMl == null) {
            // || BMmS == null || BOlS == null || BOmS == null
            // initialization of raster band configuration (should only occur once)
            SinglePixelPackedSampleModel SMl = (SinglePixelPackedSampleModel)ewr.getSampleModel();
            SinglePixelPackedSampleModel SMm = (SinglePixelPackedSampleModel)iwr.getSampleModel();
            BMl = SMl.getBitMasks();
            BMm = SMm.getBitMasks();
            BOl = SMl.getBitOffsets();
            BOm = SMm.getBitOffsets();
        }
        // get source pixels in an array
        iwr.getDataElements(lurd[0], lurd[1], lensWidth, lensHeight, oPixelsS);
        // get magnified source pixels in a second array
        ewr.getDataElements(0, 0, mbw, mbh, mPixelsS);
        // transfer them to the target array taking the gain function into account
        for (int x = lurd[0]; x < lurd[2]; x++) {
            for (int y = lurd[1]; y < lurd[3]; y++) {
                this.gf(x, y, gain);
                // get pixel from lens raster
                Pl = mPixelsS[Math.round(((y - lurd[1]) * MM - hmbh) / gain[1] + hmbh) * mbw + Math.round(((x - lurd[0]) * MM - hmbw) / gain[0] + hmbw)];
                Rl = (Pl & BMl[0]) >>> BOl[0];
                Gl = (Pl & BMl[1]) >>> BOl[1];
                Bl = (Pl & BMl[2]) >>> BOl[2];
                // get pixel from main raster
                Pm = oPixelsS[(y - lurd[1]) * (lensWidth) + (x - lurd[0])];
                Rm = (Pm & BMm[0]) >>> BOm[0];
                Gm = (Pm & BMm[1]) >>> BOm[1];
                Bm = (Pm & BMm[2]) >>> BOm[2];
                // compute contribution from each pixel, for each band
                // Use the Porter-Duff Source Atop Destination rule to achieve our effect.
                // Fs = Ad and Fd = (1-As), thus:
                //   Cd = Cs*Ad + Cd*(1-As)
                //   Ad = As*Ad + Ad*(1-As) = Ad
                this.gfT(x, y, gainT);
                Rr = Math.round(Rl * gainT[0] + Rm * (1 - gainT[0]));
                Gr = Math.round(Gl * gainT[0] + Gm * (1 - gainT[0]));
                Br = Math.round(Bl * gainT[0] + Bm * (1 - gainT[0]));
                // set new pixel value in target raster
                tPixelsS[(y - lurd[1]) * (lensWidth) + (x - lurd[0])] = (short)((Rr << BOm[0]) | (Gr << BOl[1]) | (Br << BOl[2]));
            }
        }
        // transfer pixels in the target array back to the raster
        iwr.setDataElements(lurd[0], lurd[1], lensWidth, lensHeight, tPixelsS);
    }
}
 
開發者ID:sharwell,項目名稱:zgrnbviewer,代碼行數:49,代碼來源:HLinearLens.java

示例5: transformI

import java.awt.image.SinglePixelPackedSampleModel; //導入方法依賴的package包/類
@Override
synchronized void transformI(WritableRaster iwr, WritableRaster ewr) {
    synchronized (this) {
        if (BMl == null) {
            // || BMm == null || BOl == null || BOm == null
            // initialization of raster band configuration (should only occur once)
            SinglePixelPackedSampleModel SMl = (SinglePixelPackedSampleModel)ewr.getSampleModel();
            SinglePixelPackedSampleModel SMm = (SinglePixelPackedSampleModel)iwr.getSampleModel();
            BMl = SMl.getBitMasks();
            BMm = SMm.getBitMasks();
            BOl = SMl.getBitOffsets();
            BOm = SMm.getBitOffsets();
        }
        // get source pixels in an array
        iwr.getDataElements(lurd[0], lurd[1], lensWidth, lensHeight, oPixelsI);
        // get magnified source pixels in a second array
        ewr.getDataElements(0, 0, mbw, mbh, mPixelsI);
        // transfer them to the target array taking the gain function into account
        if (BMl.length == 4) {
            // the sample model features four bands
            for (int x = lurd[0]; x < lurd[2]; x++) {
                for (int y = lurd[1]; y < lurd[3]; y++) {
                    //this.gf(x,y,gain);
                    // get pixel from lens raster
                    Pl = mPixelsI[Math.round(((y - lurd[1]) * MM - hmbh) / MM + hmbh + dy) * mbw + Math.round(((x - lurd[0]) * MM - hmbw) / MM + hmbw + dx)];
                    Rl = (Pl & BMl[0]) >>> BOl[0];
                    Gl = (Pl & BMl[1]) >>> BOl[1];
                    Bl = (Pl & BMl[2]) >>> BOl[2];
                    // get pixel from main raster
                    Pm = oPixelsI[(y - lurd[1]) * (lensWidth) + (x - lurd[0])];
                    Rm = (Pm & BMm[0]) >>> BOm[0];
                    Gm = (Pm & BMm[1]) >>> BOm[1];
                    Bm = (Pm & BMm[2]) >>> BOm[2];
                    Am = (Pm & BMm[3]) >>> BOm[3];
                    // compute contribution from each pixel, for each band
                    // Use the Porter-Duff Source Atop Destination rule to achieve our effect.
                    // Fs = Ad and Fd = (1-As), thus:
                    //   Cd = Cs*Ad + Cd*(1-As)
                    //   Ad = As*Ad + Ad*(1-As) = Ad
                    this.gfT(x, y, gainT);
                    Rr = Math.round(Rl * gainT[0] + Rm * (1 - gainT[0]));
                    Gr = Math.round(Gl * gainT[0] + Gm * (1 - gainT[0]));
                    Br = Math.round(Bl * gainT[0] + Bm * (1 - gainT[0]));
                    // set new pixel value in target raster
                    tPixelsI[(y - lurd[1]) * (lensWidth) + (x - lurd[0])] = (Rr << BOm[0]) | (Gr << BOl[1]) | (Br << BOl[2]) | (Am << BOl[3]);
                }
            }
        } else {
            // the sample model probably features 3 bands
            for (int x = lurd[0]; x < lurd[2]; x++) {
                for (int y = lurd[1]; y < lurd[3]; y++) {
                    //this.gf(x,y,gain);
                    // get pixel from lens raster
                    Pl = mPixelsI[Math.round(((y - lurd[1]) * MM - hmbh) / MM + hmbh + dy) * mbw + Math.round(((x - lurd[0]) * MM - hmbw) / MM + hmbw + dx)];
                    Rl = (Pl & BMl[0]) >>> BOl[0];
                    Gl = (Pl & BMl[1]) >>> BOl[1];
                    Bl = (Pl & BMl[2]) >>> BOl[2];
                    // get pixel from main raster
                    Pm = oPixelsI[(y - lurd[1]) * (lensWidth) + (x - lurd[0])];
                    Rm = (Pm & BMm[0]) >>> BOm[0];
                    Gm = (Pm & BMm[1]) >>> BOm[1];
                    Bm = (Pm & BMm[2]) >>> BOm[2];
                    // compute contribution from each pixel, for each band
                    // Use the Porter-Duff Source Atop Destination rule to achieve our effect.
                    // Fs = Ad and Fd = (1-As), thus:
                    //   Cd = Cs*Ad + Cd*(1-As)
                    //   Ad = As*Ad + Ad*(1-As) = Ad
                    this.gfT(x, y, gainT);
                    Rr = Math.round(Rl * gainT[0] + Rm * (1 - gainT[0]));
                    Gr = Math.round(Gl * gainT[0] + Gm * (1 - gainT[0]));
                    Br = Math.round(Bl * gainT[0] + Bm * (1 - gainT[0]));
                    // set new pixel value in target raster
                    tPixelsI[(y - lurd[1]) * (lensWidth) + (x - lurd[0])] = (Rr << BOm[0]) | (Gr << BOl[1]) | (Br << BOl[2]);
                }
            }
        }
        // transfer pixels in the target array back to the raster
        iwr.setDataElements(lurd[0], lurd[1], lensWidth, lensHeight, tPixelsI);
    }
}
 
開發者ID:sharwell,項目名稱:zgrnbviewer,代碼行數:81,代碼來源:BlendingLens.java

示例6: transformS

import java.awt.image.SinglePixelPackedSampleModel; //導入方法依賴的package包/類
@Override
synchronized void transformS(WritableRaster iwr, WritableRaster ewr) {
    synchronized (this) {
        if (BMl == null) {
            // || BMmS == null || BOlS == null || BOmS == null
            // initialization of raster band configuration (should only occur once)
            SinglePixelPackedSampleModel SMl = (SinglePixelPackedSampleModel)ewr.getSampleModel();
            SinglePixelPackedSampleModel SMm = (SinglePixelPackedSampleModel)iwr.getSampleModel();
            BMl = SMl.getBitMasks();
            BMm = SMm.getBitMasks();
            BOl = SMl.getBitOffsets();
            BOm = SMm.getBitOffsets();
        }
        // get source pixels in an array
        iwr.getDataElements(lurd[0], lurd[1], lensWidth, lensHeight, oPixelsS);
        // get magnified source pixels in a second array
        ewr.getDataElements(0, 0, mbw, mbh, mPixelsS);
        // transfer them to the target array taking the gain function into account
        for (int x = lurd[0]; x < lurd[2]; x++) {
            for (int y = lurd[1]; y < lurd[3]; y++) {
                //this.gf(x,y,gain);
                // get pixel from lens raster
                Pl = mPixelsS[Math.round(((y - lurd[1]) * MM - hmbh) / MM + hmbh + dy) * mbw + Math.round(((x - lurd[0]) * MM - hmbw) / MM + hmbw + dx)];
                Rl = (Pl & BMl[0]) >>> BOl[0];
                Gl = (Pl & BMl[1]) >>> BOl[1];
                Bl = (Pl & BMl[2]) >>> BOl[2];
                // get pixel from main raster
                Pm = oPixelsS[(y - lurd[1]) * (lensWidth) + (x - lurd[0])];
                Rm = (Pm & BMm[0]) >>> BOm[0];
                Gm = (Pm & BMm[1]) >>> BOm[1];
                Bm = (Pm & BMm[2]) >>> BOm[2];
                // compute contribution from each pixel, for each band
                // Use the Porter-Duff Source Atop Destination rule to achieve our effect.
                // Fs = Ad and Fd = (1-As), thus:
                //   Cd = Cs*Ad + Cd*(1-As)
                //   Ad = As*Ad + Ad*(1-As) = Ad
                this.gfT(x, y, gainT);
                Rr = Math.round(Rl * gainT[0] + Rm * (1 - gainT[0]));
                Gr = Math.round(Gl * gainT[0] + Gm * (1 - gainT[0]));
                Br = Math.round(Bl * gainT[0] + Bm * (1 - gainT[0]));
                // set new pixel value in target raster
                tPixelsS[(y - lurd[1]) * (lensWidth) + (x - lurd[0])] = (short)((Rr << BOm[0]) | (Gr << BOl[1]) | (Br << BOl[2]));
            }
        }
        // transfer pixels in the target array back to the raster
        iwr.setDataElements(lurd[0], lurd[1], lensWidth, lensHeight, tPixelsS);
    }
}
 
開發者ID:sharwell,項目名稱:zgrnbviewer,代碼行數:49,代碼來源:BlendingLens.java


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