Package javax.imageio.stream

Examples of javax.imageio.stream.ImageOutputStream


      }
      ifdptr=ifd.write(out,ifdptr);                              // write ifd contents, entries and set ifd linked list pointer
  }

  public void endWriteSequence()throws IOException{
    ImageOutputStream out=(ImageOutputStream)getOutput();
  }
View Full Code Here


      String url, List<BufferedImage> images) throws MalformedURLException, IOException {
    log.info("createDocument(" + token + ", " + path + ", " + fileName + ", " + fileType +
        ", " + url + ", " + images + ")");
    File tmpDir = createTempDir();
    File tmpFile = new File(tmpDir, fileName + "." + fileType);
    ImageOutputStream ios = ImageIO.createImageOutputStream(tmpFile);
    String response = "";
   
    try {
      if ("pdf".equals(fileType)) {
        ImageUtils.writePdf(images, ios);
      } else if ("tif".equals(fileType)) {
        ImageUtils.writeTiff(images, ios);
      } else {
        if (!ImageIO.write(images.get(0), fileType, ios)) {
          throw new IOException("Not appropiated writer found!");
        }
      }
     
      ios.flush();
      ios.close();
     
      if (token != null) {
        // Send image
        HttpClient client = new DefaultHttpClient();
        MultipartEntity form = new MultipartEntity();
View Full Code Here

  public void endWriteSequence()throws IOException{
try{
    ByteArrayOutputStream baos=new ByteArrayOutputStream();
    pdffile.write(baos);
    ImageOutputStream ios=(ImageOutputStream)getOutput();
    ios.write(baos.toByteArray());
}catch(Exception e){
  e.printStackTrace();
}
  }
View Full Code Here

       
        Iterator iterator = javax.imageio.ImageIO.getImageWritersByMIMEType(mimeType);
        if (iterator.hasNext()) {
          imageWriter = (ImageWriter) iterator.next();
        }
        ImageOutputStream ios = javax.imageio.ImageIO.createImageOutputStream(os);
        imageWriter.setOutput(ios);

        imageWriter.write(new IIOImage(bufferedImage, null, null));
        ios.flush();
        imageWriter.dispose();
    }
View Full Code Here

        Iterator<ImageWriter> writers = ImageIO.getImageWritersByMIMEType(mimeType);
        if (writers.hasNext()) {
            ImageWriter writer = writers.next();
           
            BufferedImage bimg = convertToBufferedImage((Image)obj);
            ImageOutputStream out = ImageIO.createImageOutputStream(os);
            writer.setOutput(out);
            writer.write(bimg);
            writer.dispose();
            out.flush();
            out.close();
        } else {
            throw new IOException("Attachment type not spported " + obj.getClass());                   
        }

    }
View Full Code Here

            // Find a writer for that file extensions
            ImageWriter writer = null;
            Iterator iter = ImageIO.getImageWritersByFormatName( ftype );
            if (iter.hasNext()) writer = (ImageWriter)iter.next();
            if (writer != null) {
                ImageOutputStream ios = null;
                try {
                    // Prepare output file
                    ios = ImageIO.createImageOutputStream( file );
                    writer.setOutput(ios);
                    // Set some parameters
                    ImageWriteParam param = writer.getDefaultWriteParam();
                    // if bi has type ARGB and alpha is false, we have
                    // to tell the writer to not use the alpha
                    // channel: this is especially needed for jpeg
                    // files where imageio seems to produce wrong jpeg
                    // files right now...
//                    if (exportImage.getType() == BufferedImage.TYPE_INT_ARGB ) {
//                        // this is not so obvious: create a new
//                        // ColorModel without OPAQUE transparency and
//                        // no alpha channel.
//                        ColorModel cm = new ComponentColorModel(exportImage.getColorModel().getColorSpace(),
//                                false, false,
//                                Transparency.OPAQUE, DataBuffer.TYPE_BYTE);
//                        // tell the writer to only use the first 3 bands (skip alpha)
//                        int[] bands = {0, 1, 2};
//                        param.setSourceBands(bands);
//                        // although the java documentation says that
//                        // SampleModel can be null, an exception is
//                        // thrown in that case therefore a 1*1
//                        // SampleModel that is compatible to cm is
//                        // created:
//                        param.setDestinationType(new ImageTypeSpecifier(cm,
//                                cm.createCompatibleSampleModel(1, 1)));
//                    }
                    // Write the image
                    writer.write(null, new IIOImage(exportImage, null, null), param);
                   
                    // Cleanup
                    ios.flush();
                } finally {
                    if (ios != null) ios.close();
                    writer.dispose();
                    if ( exportImage != null & exportImage instanceof PlanarImage ) {
                        ((PlanarImage)exportImage).dispose();
                        System.gc();
                    }
View Full Code Here

        Iterator i = ImageIO.getImageWritersByMIMEType(type);
        if (i.hasNext()) {
            writer = (ImageWriter)i.next();
        }
        if (writer != null) {
            ImageOutputStream stream = null;
            stream = ImageIO.createImageOutputStream(baos);
            writer.setOutput(stream);
            writer.write(bufImage);
            stream.close();
            return baos.toByteArray();
        }
        return null;
    }
View Full Code Here

                if (writers.hasNext()) {
                    ImageWriter writer = writers.next();
                   
                    try {
                        BufferedImage bimg = convertToBufferedImage((Image) o);
                        ImageOutputStream out = ImageIO.createImageOutputStream(bos);
                        writer.setOutput(out);
                        writer.write(bimg);
                        writer.dispose();
                        out.flush();
                        out.close();
                        bos.close();
                    } catch (IOException e) {
                        throw new Fault(e);
                    }
                } else {
View Full Code Here

                if (writers.hasNext()) {
                    ImageWriter writer = writers.next();
                   
                    try {
                        BufferedImage bimg = convertToBufferedImage((Image) o);
                        ImageOutputStream out = ImageIO.createImageOutputStream(bos);
                        writer.setOutput(out);
                        writer.write(bimg);
                        writer.dispose();
                        out.flush();
                        out.close();
                        bos.close();
                    } catch (IOException e) {
                        throw new Fault(e);
                    }
                } else {
View Full Code Here

       
        Iterator iterator = javax.imageio.ImageIO.getImageWritersByMIMEType(mimeType);
        if (iterator.hasNext()) {
          imageWriter = (ImageWriter) iterator.next();
        }
        ImageOutputStream ios = javax.imageio.ImageIO.createImageOutputStream(os);
        imageWriter.setOutput(ios);

        imageWriter.write(new IIOImage(bufferedImage, null, null));
        ios.flush();
        imageWriter.dispose();
    }
View Full Code Here

TOP

Related Classes of javax.imageio.stream.ImageOutputStream

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.