Questions tagged [bufferedimage]

The Java class BufferedImage is used to read and manipulate images and assist in double-buffering in desktop GUI applications.

The java.awt.image.BufferedImage Java class is part of the Abstract Windowing Toolkit group of classes that form part of the standard JDK.

The BufferedImage class contains methods to manipulate pixel values and is also used for double-buffering in applications that have a Java Swing GUI.

2150 questions
13
votes
2 answers

Copy two BufferedImages into one image side by side

I have two images and I'd like to copy these two images to a new image where the second image is beside the first image and not on top of it. BufferedImage imgb1 = img1; BufferedImage imgb2 = img2; BufferedImage imgResult = new…
oooss
  • 151
  • 1
  • 1
  • 7
13
votes
4 answers

Convert BufferedImage into byte[] without I/O

Hi I have a BufferedImage instance in memory and want to convert it into byte[] to encode as base64 string without I/O operation for performance consideration. I was using the following API: ByteArrayOutputStream baos = new ByteArrayOutputStream…
user1344933
  • 131
  • 1
  • 4
12
votes
2 answers

Clear a transparent BufferedImage as fast as possible

I have a transparent BufferedImage created with the following code(not relevant how it is created, I think): GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gs =…
adrian.tarau
  • 3,124
  • 2
  • 26
  • 29
12
votes
6 answers

How to flip BufferedImage in java

I get RGB24 byte array and want to show it in Java. public void getByteArray(byte byteArray[]){ int count1 = 0; byte temp1 = 0; for (int i = 0; i < byteArray.length; i++) { //The order of RGB24 is red,green and…
Eugene
  • 10,627
  • 5
  • 49
  • 67
12
votes
3 answers

java print screen two monitors

I'm trying to use print screen image area to get 2 monitors, but only works for one monitor. Can you advise me how to get figure 2 monitors? Robot robot = new Robot(); Rectangle screenRect = new…
Faken143
  • 209
  • 1
  • 4
  • 10
12
votes
3 answers

Converting an ImageIcon to a BufferedImage

I've been trying to convert a ImageIcon to BufferedImage... And I've had no luck. I have a pre-existing ImageIcon that needs to be converted to a Buffered Image for the vast amount of BufferedImage operations that exist. I have found a few ways, but…
Caelum
  • 801
  • 2
  • 10
  • 19
12
votes
2 answers

Can I create a BufferedImage from a JPanel without rendering in a JFrame?

Is it possible to create a BufferedImage from a JPanel without first rendering it in a JFrame? I've searched everywhere I can think of and cannot find an answer. Can anyone help? Here is some sample code. If I don't un-comment the JFrame code, my…
Brooke
  • 175
  • 1
  • 1
  • 8
11
votes
3 answers

Check how much memory bufferedImage in java uses?

I have a bufferedImage in Java. How do I see how much memory it takes up? Thanks in advance.
rustybeanstalk
  • 2,722
  • 9
  • 37
  • 57
11
votes
4 answers

Java : BufferedImage to Bitmap format

I have a program in which i capture the screen using the code : robot = new Robot(); BufferedImage img = robot.createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize())); Now i want to convert this BufferedImage into Bitmap…
Anand S Kumar
  • 88,551
  • 18
  • 188
  • 176
11
votes
2 answers

Fast loading and drawing of RGB data in BufferedImage

In some Java code running on Windows, I'm reading some large blocks of RGB data from disk and want to display this to screen as quickly as possible. The RGB data is 8 bits per channel without any alpha. Currently I have code like the following to…
awinbra
  • 694
  • 1
  • 7
  • 19
11
votes
3 answers

Java error on bilinear interpolation of 16 bit data

I'm having an issue using bilinear interpolation for 16 bit data. I have two images, origImage and displayImage. I want to use AffineTransformOp to filter origImage through an AffineTransform into displayImage which is the size of the display…
Jon
  • 3,985
  • 7
  • 48
  • 80
11
votes
1 answer

Convert a tiff into a buffered image (Java)

I need to convert a tiff file into a BufferedImage. I wrote the following code: String filepath = "C:\\tiffFolder\\"; String filename = "myTiffImage.tif"; File myFile = new File (filepath + filename); BufferedImage img = ImageIO.read(myFile); I…
Daniele Milani
  • 553
  • 2
  • 7
  • 26
11
votes
1 answer

How to read pixel color in a java BufferedImage with transparency

I am reading pixel color in a BufferedImage as follows: ..... InputStream is = new BufferedInputStream(conn.getInputStream()); BufferedImage image = ImageIO.read(is); int color = image.getRGB(x, y); int red = (colour & 0x00ff0000) >> 16; int …
Richard H
  • 38,037
  • 37
  • 111
  • 138
11
votes
3 answers

How to convert a BufferedImage to 8 bit?

I was looking at the ImageConverter class, trying to figure out how to convert a BufferedImage to 8-bit color, but I have no idea how I would do this. I was also searching around the internet and I could find no simple answer, they were all talking…
Zach Sugano
  • 1,567
  • 5
  • 22
  • 41
10
votes
4 answers

Rotate a buffered image in Java

I am trying to rotate a buffered image in java. Here is the code I am using: public static BufferedImage rotate(BufferedImage bimg, double angle) { int w = bimg.getWidth(); int h = bimg.getHeight(); Graphics2D graphic =…
Zugor
  • 133
  • 1
  • 2
  • 9