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
22
votes
5 answers

Create an image from a non-visible AWT Component?

I'm trying to create an image (screen-shot) of a non-visible AWT component. I can't use the Robot classes' screen capture functionality because the component is not visible on the screen. Trying to use the following code: BufferedImage image = new…
Isaac Waller
  • 32,709
  • 29
  • 96
  • 107
21
votes
6 answers

Java: Filling a BufferedImage with transparent pixels

I have an off-screen BufferedImage, constructed with the type BufferedImage.TYPE_INT_ARGB. It can contain anything, and I'm looking for a way to (fairly efficiently) completely overwrite the image with transparent pixels, resulting in an…
JBenson
  • 293
  • 2
  • 5
  • 13
21
votes
4 answers

Rotating BufferedImage instances

I am having trouble getting a rotated BufferedImage to display. I think the rotation is working just fine, but I can't actually draw it to the screen. My code: Class extends JPanel { BufferedImage img; int rotation = 0; public void…
user577304
21
votes
2 answers

How to serialize an object that includes BufferedImages

I'm trying to create a simple image editing program in java. I made an ImageCanvas object that has all the information about the image that is being edited (some basic properties, list of effects being applied, a list of BufferedImage layers, etc.)…
scaevity
  • 3,991
  • 13
  • 39
  • 54
20
votes
5 answers

Convert a Graphics2D to an Image or BufferedImage

I have a little problem here. I have an applet, where user can "draw" inside it. To do that, I use the java.awt.Graphics2D. But, how can I do to save the user draw image as a JPEG image, or at least, convert it to a BufferedImage or something? I…
caarlos0
  • 20,020
  • 27
  • 85
  • 160
19
votes
1 answer

Java: how to do fast copy of a BufferedImage's pixels? (unit test included)

I want to do a copy (of a rectangle area) of the ARGB values from a source BufferedImage into a destination BufferedImage. No compositing should be done: if I copy a pixel with an ARGB value of 0x8000BE50 (alpha value at 128), then the destination…
SyntaxT3rr0r
  • 27,745
  • 21
  • 87
  • 120
19
votes
2 answers

What is an ImageObserver?

When you draw an image it requires an image observer. From what I understand so far a BufferedImage is an image observer. But my question is, what defines an image observer and what does it do? I'm quite confused.
Troubleshoot
  • 1,816
  • 1
  • 12
  • 19
19
votes
4 answers

How can I display a BufferedImage in a JFrame?

I want to display variations of the same image in the same JFrame, for example display an image in JFrame, then replace it with gray scale of the same image.
anon
  • 697
  • 3
  • 14
  • 19
19
votes
2 answers

Image vs. BufferedImage

Whenever dealing with the loading and rendering of images in Java, I have previously always used BufferedImages to store and manipulate the images in memory. However, I have recently come across a few different sites that use the Image class instead…
Jamie
  • 3,890
  • 3
  • 26
  • 35
19
votes
1 answer

Get RGB of a BufferedImage

Can anybody explain how to get an array of rgb value from a BufferedImage? I have a grey scale image in a BufferedImage and need to extract an array of 0 to 255 values that describe the image. I know the BufferedImage is correct because I can…
kotoko
  • 599
  • 2
  • 6
  • 22
18
votes
6 answers

How to calculate java BufferedImage filesize

I have a servlet based application that is serving images from files stored locally. I have added logic that will allow the application to load the image file to a BufferedImage and then resize the image, add watermark text over the top of the…
GregA100k
  • 1,385
  • 1
  • 11
  • 16
18
votes
5 answers

Load image from a filepath via BufferedImage

I have a problem with Java application, particular in loading a image from a location in my computer. Following this post I used a BufferedImage and a InputFileStream to load an image on my computer. First, I put the image (pic2.jpg) into the source…
Lup
  • 197
  • 1
  • 1
  • 7
18
votes
3 answers

Convert Data-URL to BufferedImage

I have a Data-URL from an image file and have to pass it through to another function. Along this path from Data-URL to the BufferedImage it needs to be a byteArray. my approach was the following: String dataUrl; byte[] imageData =…
Daniel
  • 293
  • 1
  • 6
  • 15
18
votes
1 answer

IllegalArgumentException: Numbers of source Raster bands and source color space components do not match For a color image Exception

The above answer that someone has suggest, converts my colored image to a black and white one. So it's not appropriate for my question. File file = new File("path"); BufferedImage bufferedImage = ImageIO.read( file ); here is the code and…
Shanaka Kuruwita
  • 689
  • 2
  • 6
  • 19
18
votes
2 answers

How do I draw an image to a JPanel or JFrame?

How do I draw an Image to a JPanel or JFrame, I have already read oracle's tutorial on this but I can't seem to get it right. I need the image "BeachRoad.png" to be displayed on a specific set of coordinates. Here is what I have so far. public class…
Saucymeatman
  • 587
  • 3
  • 6
  • 8