Package com.google.code.appengine.awt.image

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


            int width = info.width;
            int height = info.height;

            boolean hasAlpha = false;
            BufferedImage result = getBufferedImageFactory(params)
                    .getColorBufferedImage(width, height, hasAlpha);

            info.readImage(result, is);

            return result;
View Full Code Here


        ArrayList dirs = exif.getDirectories();
        for (int i = 0; i < dirs.size(); i++) {
            TiffImageMetadata.Directory dir = (TiffImageMetadata.Directory) dirs
                    .get(i);
            // Debug.debug("dir", dir);
            BufferedImage image = dir.getThumbnail();
            if (null != image) {
                return image;
            }

//            JpegImageData jpegImageData = dir.getJpegImageData();
View Full Code Here

    {
        FormatCompliance formatCompliance = FormatCompliance.getDefault();
        TiffContents contents = new TiffReader(isStrict(params))
                .readFirstDirectory(byteSource, params, true, formatCompliance);
        TiffDirectory directory = (TiffDirectory) contents.directories.get(0);
        BufferedImage result = directory.getTiffImage(params);
        if (null == result)
            throw new ImageReadException("TIFF does not contain an image.");
        return result;
    }
View Full Code Here

            throw new ImageReadException("Tiff: samplesPerPixel ("
                    + samplesPerPixel + ")!=fBitsPerSample.length ("
                    + bitsPerSample.length + ")");

        boolean hasAlpha = false;
        BufferedImage result = getBufferedImageFactory(params)
                .getColorBufferedImage(width, height, hasAlpha);

        PhotometricInterpreter photometricInterpreter = getPhotometricInterpreter(
                directory, photometricInterpretation, bitsPerPixel,
                bitsPerSample, predictor, samplesPerPixel, width, height);
View Full Code Here

            int bitsPerPixel = bitsPerSample * samplesPerPixel;

            boolean hasAlpha = colorType == COLOR_TYPE_GREYSCALE_WITH_ALPHA
                    || colorType == COLOR_TYPE_TRUE_COLOR_WITH_ALPHA;

            BufferedImage result;
            if (isGrayscale)
                result = getBufferedImageFactory(params)
                        .getGrayscaleBufferedImage(width, height, hasAlpha);
            else
                result = getBufferedImageFactory(params).getColorBufferedImage(
View Full Code Here

    public BufferedImage getBufferedImage(){
        if(image == null){
            ColorModel model = getColorModel();
            WritableRaster wr = getRaster();
            if(model != null && wr != null) {
                image = new BufferedImage(model, wr, model.isAlphaPremultiplied(), null);
            }
        }
        return image;
    }
View Full Code Here

   */
  public static Image getInstance(com.google.code.appengine.awt.Image image, com.google.code.appengine.awt.Color color,
      boolean forceBW) throws BadElementException, IOException {
   
    if(image instanceof BufferedImage){
      BufferedImage bi = (BufferedImage) image;
      if(bi.getType()==BufferedImage.TYPE_BYTE_BINARY) {
        forceBW=true;
      }
    }
   
    com.google.code.appengine.awt.image.PixelGrabber pg = new com.google.code.appengine.awt.image.PixelGrabber(image,
View Full Code Here

        if (rimg instanceof Image) {
            img = (Image)rimg;
        } else {
            //TODO: Create new class to provide Image interface for RenderedImage or rewrite this method
            img = new BufferedImage(rimg.getColorModel(), rimg.copyData(null), false, null);
        }

        drawImage(img, xform, null);
    }
View Full Code Here

    }

    public BufferedImage createCompatibleDestImage(BufferedImage src, ColorModel destCM) {
        // If destination color model is passed only one line needed
        if (destCM != null) {
            return new BufferedImage(destCM,
                    destCM.createCompatibleWritableRaster(src.getWidth(), src.getHeight()),
                    destCM.isAlphaPremultiplied(),
                    null);
        }
       
        int nSpaces = conversionSequence.length;
       
        if (nSpaces < 1) {
            throw new IllegalArgumentException(Messages.getString("awt.261")); //$NON-NLS-1$
        }
       
        // Get destination color space
        Object destination = conversionSequence[nSpaces-1];
        ColorSpace dstCS =
            (destination instanceof ColorSpace) ?
                    (ColorSpace) destination :
                    new ICC_ColorSpace((ICC_Profile) destination);
       
        ColorModel srcCM = src.getColorModel();    
        ColorModel dstCM = new ComponentColorModel(dstCS,
                srcCM.hasAlpha(),
                srcCM.isAlphaPremultiplied(),
                srcCM.getTransparency(),
                srcCM.getTransferType());
       
        return new BufferedImage(dstCM,
                dstCM.createCompatibleWritableRaster(src.getWidth(), src.getHeight()),
                dstCM.isAlphaPremultiplied(),
                null);
    }
View Full Code Here

        if (srcCM instanceof IndexColorModel) {           
            src = ((IndexColorModel) srcCM).convertToIntDiscrete(src.getRaster(), false);
        }
        ColorSpace srcCS = srcCM.getColorSpace();       
               
        BufferedImage res;
        boolean isDstIndex = false;
        if (dst != null) {
         
          if (src.getWidth() != dst.getWidth() ||
             src.getHeight() != dst.getHeight()) {
              throw new IllegalArgumentException(Messages.getString("awt.263")); //$NON-NLS-1$
          }

            if (dst.getColorModel() instanceof IndexColorModel) {
                isDstIndex = true;
                res = createCompatibleDestImage(src, null);
            } else {               
                res = dst;
            }          
        } else {
            res = createCompatibleDestImage(src, null);
        }
        ColorModel dstCM = res.getColorModel();
        ColorSpace dstCS = dstCM.getColorSpace();
       
        ICC_Profile srcPf = null, dstPf = null;
        if (srcCS instanceof ICC_ColorSpace) {
            srcPf = ((ICC_ColorSpace)srcCS).getProfile();
        }
        if (dstCS instanceof ICC_ColorSpace) {
            dstPf = ((ICC_ColorSpace)dstCS).getProfile();
        }
       
        boolean isFullICC = isICC && srcPf != null && dstPf != null;
       
        if (isFullICC) {
            ICC_Transform t =
                    tCreator.getTransform(srcPf, dstPf, (ICC_Profile[]) conversionSequence);
            cc.translateColor(t, src, res);
        } else { // Perform non-ICC transform
            Object sequence[] = tCreator.getSequence(
                    srcPf == null ? (Object) srcCS : srcPf,
                    dstPf == null ? (Object) dstCS : dstPf);           
           
            int srcW = src.getWidth();
            int srcH = src.getHeight();
            int numPixels = srcW*srcH;

            // Load all pixel data into array tmpData
            float tmpData[][] =
                new float[numPixels][tCreator.maxComponents];
            for (int row=0, dataPos=0; row<srcW; row++) {
                for (int col=0; col<srcH; col++) {
                    tmpData[dataPos] =
                        srcCM.getNormalizedComponents(
                                src.getRaster().getDataElements(row, col, null),
                                tmpData[dataPos], 0);
                    dataPos++;
                }
            }

            // Copy alpha channel if needed
            float alpha[] = null;
            int alphaIdx = srcCM.numComponents - 1;
            if (srcCM.hasAlpha() && dstCM.hasAlpha()) {
                alpha = new float[numPixels];
                for (int i=0; i<numPixels; i++) {
                    alpha[i] = tmpData[i][alphaIdx];
                }
            }
           
            // Translate colors
            applySequence(sequence, tmpData, srcCS, dstCS);

            // Copy alpha if needed
            if (dstCM.hasAlpha()) {
                alphaIdx = dstCM.numComponents - 1;
                if (alpha != null) {
                    for (int i=0; i<numPixels; i++) {
                        tmpData[i][alphaIdx] = alpha[i];
                    }                  
                } else {
                    for (int i=0; i<numPixels; i++) {
                        tmpData[i][alphaIdx] = 1f;
                    }                                      
                }
            }
           
            // Store data back to the image           
            for (int row=0, dataPos=0; row<srcW; row++) {
                for (int col=0; col<srcH; col++) {
                    res.getRaster().setDataElements(row, col,
                            dstCM.getDataElements(tmpData[dataPos++], 0 , null));
                }
            }
        }              

View Full Code Here

TOP

Related Classes of com.google.code.appengine.awt.image.BufferedImage

Copyright © 2018 www.massapicom. 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.