Examples of SampleModel


Examples of ae.java.awt.image.SampleModel

        }

        // 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 icList;
        ImageConsumer ic;
        // Set up the ImageConsumers
        icList = ics.elements();
        while (icList.hasMoreElements()) {
            ic = (ImageConsumer)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()) {
View Full Code Here

Examples of com.google.code.appengine.awt.image.SampleModel

                maxBandOffset = bandOffsets[i];
            }
        }
        int pixelStride = maxBandOffset - minBandOffset + 1;
       
        SampleModel sampleModel = new PixelInterleavedSampleModel(dataType,
                                                                  1,
                                                                  1,
                                                                  pixelStride,
                                                                  pixelStride,
                                                                  bandOffsets);
View Full Code Here

Examples of com.jgraph.gaeawt.java.awt.image.SampleModel

    }

    if (fmt.cmmFormat == 0)
    {
      ColorModel cm = bi.getColorModel();
      SampleModel sm = bi.getSampleModel();

      if (sm instanceof SinglePixelPackedSampleModel)
      {
        SinglePixelPackedSampleModel sppsm = (SinglePixelPackedSampleModel) sm;
        fmt.cmmFormat = getFormatFromSPPSampleModel(sppsm,
View Full Code Here

Examples of com.pcmsolutions.device.EMU.E4.sample.SampleModel

        for (int i = 0, n = ca.length; i < n; i++) {
            if (ca[i].isInstance(baseClass))         // ca[i] guaranteed non-null by virtue of addSampleClass semantics
                candidate = mostDerived(ca[i], candidate);
        }
        if (candidate != baseClass.getClass()) {
            SampleModel pm = (SampleModel) candidate.newInstance();
            pm.setSample(baseClass.getSample());
            pm.setSampleContext(baseClass.getSampleContext());
            return pm;
        }
        return baseClass;
    }
View Full Code Here

Examples of java.awt.image.SampleModel

          return bi;
        }
        else if (bitsPerPixel == 8)
        {
          final DataBufferByte db = new DataBufferByte(new byte[][] {bytes}, bytes.length);
          final SampleModel sm = new SinglePixelPackedSampleModel(DataBuffer.TYPE_BYTE, w, h, lineStride, new int[] {redMask, greenMask, blueMask});
          final WritableRaster r = Raster.createWritableRaster(sm, db, new Point(0, 0));
                  final ColorModel colorModel = new DirectColorModel(bitsPerPixel, redMask, greenMask, blueMask);
                  final BufferedImage bi = new BufferedImage(colorModel, r, false, null);
          return bi;
        }
        else
        {
          final BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
          final int [] pixels = new int[w * h];
          int pixelIndex = 0;
          int lineOffset = 0;
          if (flipped)
            lineOffset = (h - 1) * lineStride;
         
          for (int y = 0; y < h; ++y)
          {
            int off = lineOffset;
            for (int x = 0; x < w; ++x)
            {
              final byte r = bytes[off + redMask - 1];
              final byte g = bytes[off + greenMask - 1];
              final byte b = bytes[off + blueMask - 1];
              int pixel = 0;
              pixel += r & 0xff// red
              pixel *= 256;
              pixel += g & 0xff; // green
              pixel *= 256;
              pixel += b & 0xff// blue
              pixels[pixelIndex++] = pixel;
              off += pixelStride;
            }
            if (flipped)
              lineOffset -= lineStride;
            else
              lineOffset += lineStride;
          }
         
          bi.setRGB(0,0,w,h,pixels,0,w);
          return bi;
        }

       
      }else if (dataType == Format.shortArray) {
        final short[] shorts = (short[]) buffer.getData();
        if (bitsPerPixel == 16)
        {
          final DataBufferUShort db = new DataBufferUShort(new short[][] {shorts}, shorts.length);
          final SampleModel sm = new SinglePixelPackedSampleModel(DataBuffer.TYPE_USHORT, w, h, lineStride, new int[] {redMask, greenMask, blueMask});
          final WritableRaster r = Raster.createWritableRaster(sm, db, new Point(0, 0));
                  final ColorModel colorModel = new DirectColorModel(bitsPerPixel, redMask, greenMask, blueMask);
                  final BufferedImage bi = new BufferedImage(colorModel, r, false, null);
          return bi;
        }else{
View Full Code Here

Examples of java.awt.image.SampleModel

         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 =
View Full Code Here

Examples of java.awt.image.SampleModel

                
     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();
     }
View Full Code Here

Examples of java.awt.image.SampleModel

            image.origin(template.origin());
            return image;
        }

        public static IplImage createFrom(BufferedImage image) {
            SampleModel sm = image.getSampleModel();
            int depth = 0, numChannels = sm.getNumBands();
            switch (image.getType()) {
                case BufferedImage.TYPE_INT_RGB:
                case BufferedImage.TYPE_INT_ARGB:
                case BufferedImage.TYPE_INT_ARGB_PRE:
                case BufferedImage.TYPE_INT_BGR:
                    depth = IPL_DEPTH_8U;
                    numChannels = 4;
                    break;
            }
            if (depth == 0 || numChannels == 0) {
                switch (sm.getDataType()) {
                    case DataBuffer.TYPE_BYTE:   depth = IPL_DEPTH_8U;  break;
                    case DataBuffer.TYPE_USHORT: depth = IPL_DEPTH_16U; break;
                    case DataBuffer.TYPE_SHORT:  depth = IPL_DEPTH_16S; break;
                    case DataBuffer.TYPE_INT:    depth = IPL_DEPTH_32S; break;
                    case DataBuffer.TYPE_FLOAT:  depth = IPL_DEPTH_32F; break;
                    case DataBuffer.TYPE_DOUBLE: depth = IPL_DEPTH_64F; break;
                    default: assert (false);
                }
            }
            IplImage i = create(sm.getWidth(), sm.getHeight(), depth, numChannels);
            i.copyFrom(image, 1.0, null);
            return i;
        }
View Full Code Here

Examples of java.awt.image.SampleModel

        }
        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();
            } else if (sm instanceof SinglePixelPackedSampleModel) {
                step = ((SinglePixelPackedSampleModel)sm).getScanlineStride();
View Full Code Here

Examples of java.awt.image.SampleModel

        }
        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();
            } else if (sm instanceof MultiPixelPackedSampleModel) {
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.