Examples of FileImageOutputStream


Examples of javax.imageio.stream.FileImageOutputStream

    @Override
    public ImageOutputStream createOutputStreamInstance(Object output, boolean useCache,
            File cacheDir) throws IOException {
        if (output instanceof RandomAccessFile) {
            return new FileImageOutputStream((RandomAccessFile) output);
        }
        throw new IllegalArgumentException("output is not instance of java.io.RandomAccessFile");
    }
View Full Code Here

Examples of javax.imageio.stream.FileImageOutputStream

    @Override
    public ImageOutputStream createOutputStreamInstance(Object output, boolean useCache,
            File cacheDir) throws IOException {
        if (output instanceof File) {
            return new FileImageOutputStream((File) output);
        }
        throw new IllegalArgumentException("output is not instance of File");
    }
View Full Code Here

Examples of javax.imageio.stream.FileImageOutputStream

            graphics.setColor(Color.WHITE);
            graphics.fillRect(0, 0, w, h);
            graphics.drawImage(srcSized, 0, 0, null);
            ImageWriter writer = ImageIO.getImageWritersByMIMEType(mimeType).next();
            ImageWriteParam params = writer.getDefaultWriteParam();
            FileImageOutputStream toFs = new FileImageOutputStream(to);
            writer.setOutput(toFs);
            IIOImage image = new IIOImage(dest, null, null);
            writer.write(null, image, params);
            toFs.flush();
            toFs.close();

        } catch (Exception e) {
            throw new RuntimeException(e);
        }
View Full Code Here

Examples of javax.imageio.stream.FileImageOutputStream

            graphics.setColor(Color.WHITE);
            graphics.fillRect(0, 0, width, height);
            graphics.drawImage(croppedImage, 0, 0, null);
            ImageWriter writer = ImageIO.getImageWritersByMIMEType(mimeType).next();
            ImageWriteParam params = writer.getDefaultWriteParam();
            writer.setOutput(new FileImageOutputStream(to));
            IIOImage image = new IIOImage(dest, null, null);
            writer.write(null, image, params);

        } catch (Exception e) {
            throw new RuntimeException(e);
View Full Code Here

Examples of javax.imageio.stream.FileImageOutputStream

                try
                {
                    if (!outputFile.exists() || (outputFile.canWrite() && outputFile.canRead()))
                    {
                      ImageOutputStream outputStream = new FileImageOutputStream(outputFile)
                      GalacticraftCore.jpgWriter.setOutput(outputStream);
                      GalacticraftCore.jpgWriter.write(null, new IIOImage(image, null, null), GalacticraftCore.writeParam);
                      outputStream.close();
                        success = true;
                    }
                }
                catch (IOException ex)
                {
View Full Code Here

Examples of javax.imageio.stream.FileImageOutputStream

public class ScreenshotUtil {

  private final static SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH.mm.ss.SSS");

  public static void saveScreenshot(BufferedImage screenshot, String format, float compressionQuality) {
    FileImageOutputStream output = null;
    ImageWriter writer = null;

    File screenshotDir = FileUtil.getScreenshotsDir();

    FileUtil.createDir(screenshotDir);

    File file = new File(screenshotDir, DATE_FORMAT.format(new Date()) + '.' + format.toLowerCase());

    try {
      // Instantiate an ImageWriteParam object with default compression options
      Iterator<ImageWriter> it = ImageIO.getImageWritersByFormatName(format);

      writer = (ImageWriter) it.next()
      ImageWriteParam iwp = writer.getDefaultWriteParam();

      // If compression is supported, then set the compression mode
      if (iwp.canWriteCompressed()) {
        // Use explicit compression mode
        iwp.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
 
        // Set compression quality, where 1 specifies minimum compression and maximum quality
        iwp.setCompressionQuality(compressionQuality); // float between 0 and 1
      }
      // Write the screen shot to file
      output = new FileImageOutputStream(file);
      writer.setOutput(output);
      IIOImage image = new IIOImage(screenshot, null, null);

      writer.write(null, image, iwp);
    } catch (IOException e) {
      e.printStackTrace();
    } finally {
      if (writer != null) {
        writer.dispose();
      }
      if (output != null) {
        try {
          output.close();
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
    }
View Full Code Here

Examples of javax.imageio.stream.FileImageOutputStream

      if (!destinationFile.exists()) {
       
        try {
          FileUtils.copyFileToDirectory(srcImage, this.imageDestinationPath);
          LOG.info("copying image: "+ srcImage.getPath());
          ImageOutputStream stream = new FileImageOutputStream(destinationFile);
         
          if (scale == null && Utilities.getImageWidth(srcImage) > PAGE_WIDTH) {
            scale = 1;
          }
          if (scale != null) {
            Utilities.resizeImage(srcImage, stream, Utilities.getFormatName(srcImage), PAGE_WIDTH, (double) scale/100);
            srcImage = destinationFile;
            stream.close();
            stream = new FileImageOutputStream(destinationFile);
          }
          Utilities.getImageWithLogo(srcImage, stream, Utilities.getFormatName(srcImage), logo);
        } catch (IOException e) {
          LOG.warn("Error while copying " + srcImage.getPath() + ":\n" +
              "\t\t" + e.getMessage());
View Full Code Here

Examples of javax.imageio.stream.FileImageOutputStream

//        }
//      }
//      out.flush();
//      out.close();

      image.write(new FileImageOutputStream(new File("/home/brad/Downloads/openexr-images-1.5.0/ScanLines/Test.exr")));
    } catch (FileNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (IOException e) {
      // TODO Auto-generated catch block
View Full Code Here

Examples of javax.imageio.stream.FileImageOutputStream

    try {
      ImageOutputStream out;
      HostService service = JdcpUtil.getHostService();
      if (service != null) {
        RandomAccessFile file = service.createRandomAccessFile(fileName);
        out = new FileImageOutputStream(file);
      } else {
        out = new FileImageOutputStream(new File(fileName));
      }
      image.write(out);
    } catch (IOException e) {
      throw new UnexpectedException(e);
    }
View Full Code Here

Examples of javax.imageio.stream.FileImageOutputStream

      }

      setDPI(metadata, DPI);

      File file = new File(fileName + "." + bitmapFormat.toString().toLowerCase());
      FileImageOutputStream output = new FileImageOutputStream(file);
      writer.setOutput(output);
      IIOImage image = new IIOImage(bufferedImage, null, metadata);
      writer.write(null, image, iwp);
      writer.dispose();
    }
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.