Example #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static java.awt.image.BufferedImage imageFromBytes(int paramInt, byte[] paramArrayOfByte) throws Exception
        public static BufferedImage imageFromBytes(int paramInt, sbyte[] paramArrayOfByte)
        {
            string str = "jpg";

            if (paramInt == 1)
            {
                str = "png";
            }
            else if (paramInt == 3)
            {
                str = "gif";
            }
            MemoryStream byteArrayInputStream1 = new MemoryStream(paramArrayOfByte);

            System.Collections.IEnumerator iterator = ImageIO.getImageReadersByFormatName(str);
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            ImageReader      imageReader           = (ImageReader)iterator.next();
            MemoryStream     byteArrayInputStream2 = byteArrayInputStream1;
            ImageInputStream imageInputStream      = ImageIO.createImageInputStream(byteArrayInputStream2);

            imageReader.setInput(imageInputStream, true);
            ImageReadParam imageReadParam = imageReader.DefaultReadParam;
            BufferedImage  bufferedImage  = imageReader.read(0, imageReadParam);

            return(createBufferedImage(bufferedImage, paramInt, bufferedImage.getWidth(null), bufferedImage.getHeight(null)));
        }