Examples of Raster


Examples of java.awt.image.Raster

     * {@inheritDoc}
     */
    public final Raster getRaster(int x, int y, int w, int h) {         
        // If working raster is big enough, reuse it. Otherwise,
        // build a large enough new one.
        Raster raster = saved;
        if (raster == null ||
            raster.getWidth() < w || raster.getHeight() < h)
        {
            raster = getCachedRaster(model, w, h);
            saved = raster;
        }

        // Access raster internal int array. Because we use a DirectColorModel,
        // we know the DataBuffer is of type DataBufferInt and the SampleModel
        // is SinglePixelPackedSampleModel.
        // Adjust for initial offset in DataBuffer and also for the scanline
        // stride.
        DataBufferInt rasterDB = (DataBufferInt)raster.getDataBuffer();
        int[] pixels = rasterDB.getBankData()[0];
        int off = rasterDB.getOffset();
        int scanlineStride = ((SinglePixelPackedSampleModel)
                              raster.getSampleModel()).getScanlineStride();
        int adjust = scanlineStride - w;
       
        fillRaster(pixels, off, adjust, x, y, w, h); // delegate to subclass
       
        return raster;
View Full Code Here

Examples of java.awt.image.Raster

    private static synchronized Raster getCachedRaster(ColorModel cm,
                                                       int w, int h)
    {
        if (cm == cachedModel) {
            if (cached != null) {
                Raster ras = (Raster) cached.get();
                if (ras != null &&
                    ras.getWidth() >= w &&
                    ras.getHeight() >= h)
                {
                    cached = null;
                    return ras;
                }
            }
View Full Code Here

Examples of java.awt.image.Raster

     */
    private static synchronized void putCachedRaster(ColorModel cm,
                                                     Raster ras)
    {
        if (cached != null) {
            Raster cras = (Raster) cached.get();
            if (cras != null) {
                int cw = cras.getWidth();
                int ch = cras.getHeight();
                int iw = ras.getWidth();
                int ih = ras.getHeight();
                if (cw >= iw && ch >= ih) {
                    return;
                }
View Full Code Here

Examples of java.awt.image.Raster

                    final BufferedImage i = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
                    try {
                        i.createGraphics().drawImage(scaled, 0, 0, width, height, null);
                        image = i;
                        // check outcome
                        final Raster raster = i.getData();
                        int[] pixel = new int[3];
                        pixel = raster.getPixel(0, 0, pixel);
                        if (pixel[0] != 0 || pixel[1] != 0 || pixel[2] != 0) image = i;
                    } catch (final Exception e) {
                        //java.lang.ClassCastException: [I cannot be cast to [B
                    }
View Full Code Here

Examples of java.awt.image.Raster

public Raster getData(Rectangle bounds) {
     int startX = XToTileX(bounds.x);
     int startY = YToTileY(bounds.y);
     int endX = XToTileX(bounds.x + bounds.width - 1);
     int endY = YToTileY(bounds.y + bounds.height - 1);
     Raster tile;

     if ((startX == endX) && (startY == endY)) {
         tile = getTile(startX, startY);
         return tile.createChild(bounds.x, bounds.y,
                                 bounds.width, bounds.height,
                                 bounds.x, bounds.y, null);
     } else {
         // Create a WritableRaster of the desired size
         SampleModel sm =
             sampleModel.createCompatibleSampleModel(bounds.width,
                                                    bounds.height);

         // Translate it
         WritableRaster dest =
             Raster.createWritableRaster(sm, bounds.getLocation());

         for (int j = startY; j <= endY; j++) {
             for (int i = startX; i <= endX; i++) {
                 tile = getTile(i, j);
                 Rectangle intersectRect =
                     bounds.intersection(tile.getBounds());
                 Raster liveRaster = tile.createChild(intersectRect.x,
                                                      intersectRect.y,
                                                      intersectRect.width,
                                                      intersectRect.height,
                                                      intersectRect.x,
                                                      intersectRect.y,
View Full Code Here

Examples of java.awt.image.Raster

  * @return a reference to the supplied WritableRaster, or to a
  *         new WritableRaster if the supplied one was null.
  */
public WritableRaster copyData(WritableRaster dest) {
     Rectangle bounds;
     Raster tile;
                
     if (dest == null) {
         bounds = getBounds();
         Point p = new Point(minX, minY);
         /* A SampleModel to hold the entire image. */
         SampleModel sm = sampleModel.createCompatibleSampleModel(
                                      width, height);
         dest = Raster.createWritableRaster(sm, p);
     } else {
         bounds = dest.getBounds();
     }
    
     int startX = XToTileX(bounds.x);
     int startY = YToTileY(bounds.y);
     int endX = XToTileX(bounds.x + bounds.width - 1);
     int endY = YToTileY(bounds.y + bounds.height - 1);
        
     for (int j = startY; j <= endY; j++) {
         for (int i = startX; i <= endX; i++) {
             tile = getTile(i, j);
             Rectangle intersectRect =
                 bounds.intersection(tile.getBounds());
             Raster liveRaster = tile.createChild(intersectRect.x,
                                                  intersectRect.y,
                                                  intersectRect.width,
                                                  intersectRect.height,
                                                  intersectRect.x,
                                                  intersectRect.y,
View Full Code Here

Examples of java.awt.image.Raster

        public void copyTo(BufferedImage image, double gamma, Rectangle roi) {
            boolean flip = origin() == IPL_ORIGIN_BL; // need to add support for ROI..

            ByteBuffer in  = getByteBuffer(roi == null ? 0 : roi.y*widthStep() + roi.x*nChannels());
            SampleModel sm = image.getSampleModel();
            Raster r       = image.getRaster();
            DataBuffer out = r.getDataBuffer();
            int x = -r.getSampleModelTranslateX();
            int y = -r.getSampleModelTranslateY();
            int step = sm.getWidth()*sm.getNumBands();
            int channels = sm.getNumBands();
            if (sm instanceof ComponentSampleModel) {
                step = ((ComponentSampleModel)sm).getScanlineStride();
                channels = ((ComponentSampleModel)sm).getPixelStride();
View Full Code Here

Examples of java.awt.image.Raster

        public void copyFrom(BufferedImage image, double gamma, Rectangle roi) {
            origin(IPL_ORIGIN_TL);

            ByteBuffer out = getByteBuffer(roi == null ? 0 : roi.y*widthStep() + roi.x);
            SampleModel sm = image.getSampleModel();
            Raster r       = image.getRaster();
            DataBuffer in  = r.getDataBuffer();
            int x = r.getSampleModelTranslateX();
            int y = r.getSampleModelTranslateY();
            int step = sm.getWidth()*sm.getNumBands();
            if (sm instanceof ComponentSampleModel) {
                step = ((ComponentSampleModel)sm).getScanlineStride();
            } else if (sm instanceof SinglePixelPackedSampleModel) {
                step = ((SinglePixelPackedSampleModel)sm).getScanlineStride();
View Full Code Here

Examples of java.awt.image.Raster

     */
    protected void computeRect(Raster[] sources,
                               WritableRaster dest,
                               Rectangle destRect) {

        Raster source = sources[0];
        int formatTag = MediaLibAccessor.findCompatibleTag(sources, dest);

  // For PointOpImages, the srcRect and the destRect are the same.
        MediaLibAccessor srcAccessor = new MediaLibAccessor(source, destRect,
                  formatTag);
View Full Code Here

Examples of java.awt.image.Raster

    }

    protected void computeRect(Raster[] sources,
                               WritableRaster dest,
                               Rectangle destRect) {
        Raster source = sources[0];
        Rectangle srcRect = source.getBounds();

        int formatTag = MediaLibAccessor.findCompatibleTag(sources,dest);

        MediaLibAccessor srcAccessor =
            new MediaLibAccessor(source,srcRect,formatTag);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.