Example #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static void saveCompressedImage(java.awt.image.BufferedImage paramBufferedImage, String paramString, int paramInt) throws java.io.IOException
        public static void saveCompressedImage(BufferedImage paramBufferedImage, string paramString, int paramInt)
        {
            if (paramInt == 1)
            {
                throw new System.NotSupportedException("PNG compression not implemented");
            }
            ImageWriter imageWriter = null;

            System.Collections.IEnumerator iterator = ImageIO.getImageWritersByFormatName("jpg");
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            imageWriter = (ImageWriter)iterator.next();
            ImageOutputStream imageOutputStream = ImageIO.createImageOutputStream(new File(paramString));

            imageWriter.Output = imageOutputStream;
            JPEGImageWriteParam jPEGImageWriteParam = new JPEGImageWriteParam(Locale.Default);

            jPEGImageWriteParam.CompressionMode    = 2;
            jPEGImageWriteParam.CompressionQuality = 0.7F;
            imageWriter.write(null, new IIOImage(paramBufferedImage, null, null), jPEGImageWriteParam);
            imageOutputStream.flush();
            imageWriter.dispose();
            imageOutputStream.close();
        }