Put image RGB data into the {@link ByteBuffer}. Please note that data from {@link ByteBuffer}
consumed by this method does not contain original JPEG data bytes, but bytes representing RGB
data of the image constructed from JPEG data.
179206
@Override
	public void getImageBytes(ByteBuffer buffer) {
		final BufferedImage bi = getImage();
		if (bi != null) {
			buffer.put(ImageUtils.imageToBytes(bi));
		}
	}
968248
static BufferedImage convertImage (BufferedImage image) {
    switch (image.getType()) {
    case BufferedImage.TYPE_INT_ARGB_PRE:
      return image; // Already good to go
    case BufferedImage.TYPE_4BYTE_ABGR:
      image.coerceData(true); // Just premultiply the alpha and it's fine
      return image;
    }

    // Didn't know an easy thing to do, so create a whole new image in our preferred format
    BufferedImage convertedImage = new BufferedImage(image.getWidth(), image.getHeight(),
                                                     BufferedImage.TYPE_INT_ARGB_PRE);
    Graphics g = convertedImage.getGraphics();
    g.setColor(new Color(0f, 0f, 0f, 0f));
    g.fillRect(0, 0, image.getWidth(), image.getHeight());
    g.drawImage(image, 0, 0, null);

    return convertedImage;
  }
1371464
public static BufferedImage createBufferedImage(int width, int height,
			String imageFormat) {

		int imageType;

		switch (imageFormat.toLowerCase()) {
		case IMAGE_FORMAT_JPG:
		case IMAGE_FORMAT_JPEG:
			imageType = BufferedImage.TYPE_INT_RGB;
			break;
		default:
			imageType = BufferedImage.TYPE_INT_ARGB;
		}

		BufferedImage image = new BufferedImage(width, height, imageType);

		return image;
	}
1009546
public static BufferedImage randomBufferedImage(final int width, final int height,
		final int imageType)
	{
		final BufferedImage img = new BufferedImage(width, height, imageType);
		for (int y = 0; y < height; y++)
		{
			for (int x = 0; x < width; x++)
			{
				img.setRGB(x, y, RandomExtensions.newRandomPixel());
			}
		}
		return img;
	}
586583
public WrappedByteBuffer putBufferAt(int index, WrappedByteBuffer v) {
        // TODO: I believe this method incorrectly moves the position!
        // Can't change it without a code analysis - and this is a public API!
        int pos = _buf.position();
        _buf.position(index);
        _buf.put(v._buf);
        _buf.position(pos);
        return this;
    }
257008
public BufferedImage put(IconRow iconRow, BufferedImage image) {
		return put(iconRow.getId(), image);
	}
1337010
public static byte[] bufferedImageToBMPByteArray(BufferedImage image, BufferedImage bufferedImage) {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        try {
            /* ImageTypeSpecifier type =
             ImageTypeSpecifier.createFromRenderedImage(image);
             Iterator<ImageWriter> iter = ImageIO.getImageWriters(type, "bmp");
             System.err.println(ImageIO.getWriterFormatNames());
             boolean sig=iter.hasNext();*/
            //BufferedImage bufferedImage = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_RGB);
            Graphics2D ngraphics = (Graphics2D) bufferedImage.getGraphics();
            /*ngraphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
             RenderingHints.VALUE_INTERPOLATION_BILINEAR);*/
            //ngraphics.drawImage(image, 0, 0,512,384,0,0,image.getWidth(),image.getHeight(), null);        	
            //ngraphics.drawImage(image.getScaledInstance(200, 300, BufferedImage.SCALE_FAST), 0, 0,null);        	
            ngraphics.drawImage(image, 0, 0, null);
            ImageIO.write(bufferedImage, "bmp", baos);
            baos.flush();
            byte[] imageInByte = baos.toByteArray();
            baos.close();
            return imageInByte;
        } catch (IOException ex) {
            Logger.getLogger(PHATImageUtils.class.getName()).log(Level.SEVERE, "bufferedImageToByteArray", ex);
        }
        return null;
    }
1027643
public int writeTo(ByteBuffer bb) throws IOException
    {
        return writeTo((srcs, offset, len)->ByteBuffers.move(srcs, offset, len, bb), writeToSplitter);
    }
1085245
def parse_buffer_to_jpeg(data):
    

    return [
        Image.open(BytesIO(image_data + b'\xff\xd9'))
        for image_data in data.split(b'\xff\xd9')[:-1] # Last element is obviously empty
    ]
1098382
private void writeImageDataHexEncoded(final OutputStream bab) throws IOException
    {
    	int cnt = 0;
    	for(int k = 0; k < imageData.length; k++) {
    		final byte[] chunk = imageData[k];
			for(int x = 0; x < chunk.length; x++) {
				bab.write(byte2charLUT, (chunk[x]&0xff)*2, 2);
				if(++cnt == 64) {
					bab.write('\n');
					cnt = 0;
				}
			}
		}    	
   		if(cnt > 0) bab.write('\n');
    }
278977
public static void binary(Image srcImage, OutputStream out, String imageType) {
		binary(srcImage, getImageOutputStream(out), imageType);
	}
476725
public static InputStream byteBufferToInputStream(final ByteBuffer byteBuffer) {
        // https://stackoverflow.com/questions/4332264/wrapping-a-bytebuffer-with-an-inputstream/6603018#6603018
        return new InputStream() {
            /** The intermediate buffer. */
            final ByteBuffer buf = byteBuffer;

            @Override
            public int read() {
                if (!buf.hasRemaining()) {
                    return -1;
                }
                return buf.get() & 0xFF;
            }

            @Override
            public int read(final byte[] bytes, final int off, final int len) {
                if (!buf.hasRemaining()) {
                    return -1;
                }

                final int bytesRead = Math.min(len, buf.remaining());
                buf.get(bytes, off, bytesRead);
                return bytesRead;
            }
        };
    }
97960
private void createImageBuffer() throws JavaAVException {
		int format = pixelFormat.value();
		int width = avContext.width();
		int height = avContext.height();

		picture = new AVPicture();

		if (avpicture_alloc(picture, format, width, height) < 0)
			throw new JavaAVException("Could not allocate picture.");
	}
617183
public static final void decodeBuffer(byte[] data, byte encryptionCode)
   {
      for (int i = 0; i < data.length; i++)
      {
         data[i] = (byte) (data[i] ^ encryptionCode);
      }
   }
759504
public final BufferedImage decode() throws IOException {
		if (!validPNG) {
			return null;
		}
		ColorModel cmodel = new ComponentColorModel(COLOR_SPACE, BITS, false, false, Transparency.OPAQUE, DATA_TYPE);
		SampleModel smodel = new ComponentSampleModel(DATA_TYPE, width, height, 3, width * 3, BAND_OFFSETS);

		byte[] bytes = new byte[width * height * 3];// must new each time!
		byte[][] data = new byte[][] { bytes };
		ByteBuffer buffer = ByteBuffer.wrap(bytes);
		decode(buffer, TextureFormat.RGB);
		DataBufferByte dbuf = new DataBufferByte(data, bytes.length, OFFSET);
		WritableRaster raster = Raster.createWritableRaster(smodel, dbuf, null);

		BufferedImage bi = new BufferedImage(cmodel, raster, false, null);
		bi.flush();
		return bi;
	}
1028780
public void addByte(int b)
    throws IOException
  {
    int nextHead = (_byteHead + 1) % _byteBuffer.length;

    while (nextHead == _byteTail) {
      int ch = readChar();

      if (ch < 0) {
        break;
      }

      outputChar(ch);
    }

    _byteBuffer[_byteHead] = (byte) b;
    _byteHead = nextHead;
  }
397302
public static BufferedImage toImage(BitMatrix matrix, int foreColor, int backColor) {
		final int width = matrix.getWidth();
		final int height = matrix.getHeight();
		BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
		for (int x = 0; x < width; x++) {
			for (int y = 0; y < height; y++) {
				image.setRGB(x, y, matrix.get(x, y) ? foreColor : backColor);
			}
		}
		return image;
	}