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
9
votes
2 answers

How to get the format(ex:jpen,png,gif) of image file (BufferedImage) in java

i want to get the buffered image format or type of image using java, InputStream stream = request.getResponseStream(); BufferedImage image= ImageIO.read(stream); LOGGER.info(image);
VICKY-TSC
  • 405
  • 2
  • 5
  • 19
9
votes
4 answers

BufferedImage producing black background

Alright so I'm making a game, and I'm trying to modify the original hit marker image by adding text on it, and I'm using the following code: import javax.swing.ImageIcon; import javax.swing.Timer; import java.awt.Color; import java.awt.Font; import…
Josh M
  • 11,611
  • 7
  • 39
  • 49
8
votes
2 answers

Java BufferedImage how to know if a pixel is transparent

I'm going to use the getRGB method of BufferedImage. I want to check the pixels of an image and see which of them have transparency (in general the pixels I will have that are transparent will be totaly transparent). How can I get it from the int…
Panos
  • 7,227
  • 13
  • 60
  • 95
8
votes
3 answers

Add BufferedImage to PDFBox document

In my current project, I try to add a BufferedImage to a PDFBox document. More specificly, I use an image from a JFreeChart. My code looks like this: public void exportToPDF(JFreeChart chart, String filePath){ PDDocument doc = null; PDPage…
Oglop
  • 260
  • 1
  • 3
  • 11
8
votes
3 answers

Sending a screenshot (bufferedImage) over a socket in java

I am sending a bufferedImage over a socket and I am using the example found in this post: Sender BufferedImage image = ....; ImageIO.write(image, "PNG", socket.getOutputStream()); Receiver BufferedImage image =…
David
  • 15,652
  • 26
  • 115
  • 156
8
votes
2 answers

Small pdf files results with huge BufferdImage

I'm trying to perform OCR on pdfs. There are 2 steps in the code: Convert pdf to tiff files Convert tiff to text I used ghost4j for the first step, and then tess4j for the second one. all worked great, until I started to do run it multi-threaded,…
Lior Y
  • 250
  • 1
  • 3
  • 13
8
votes
2 answers

BufferedImage to BMP in Java

I have a BufferedImage object and I want to encode it to the BMP format and save it to disk. How do I do this? In JPEG it's ok: BufferedImage img; //here is an image ready to be recorded into the hard disk FileOutputStream fout = new…
Eduardo Abreu
  • 245
  • 2
  • 3
  • 9
8
votes
1 answer

Java BufferedImage JPG compression without writing to file

I've seen several examples of making compressed JPG images from Java BufferedImage objects by writing to file, but is it possible to perform JPG compression without writing to file? Perhaps by writing to a ByteArrayOutputStream like…
JeffThompson
  • 1,538
  • 3
  • 24
  • 47
8
votes
1 answer

java Buffered Image : Detecting black pixels

I have this simple code to go through a 24bit color windows bmp file BufferedImage mapa = BMPDecoder.read(new File("maps/map.bmp")); final int xmin = mapa.getMinX(); final int ymin = mapa.getMinY(); final int ymax = ymin +…
Tom
  • 43,810
  • 29
  • 138
  • 169
8
votes
1 answer

Image changes color when saved with java

When I save this image: with this method: private final static Path ROOT_PATH = Paths.getPath("C:/images"); private static void saveImageFromWebSimple(final String url) { URL u = null; try { u = new URL(url); } catch…
Franz Ebner
  • 4,951
  • 3
  • 39
  • 57
8
votes
3 answers

How to draw part of a large BufferedImage?

I have a 10000x10000 BufferedImage and I'm looking to draw only part of it to a Canvas, is there a way to do this using args such as: x, y, width, height ? So for example, drawImage(img, x, y, width, height) would draw a rectangle from the image…
Shaun Wild
  • 1,237
  • 3
  • 17
  • 34
8
votes
2 answers

Exporting a JPanel to an image

So I've been trying to export an image that I've drawn on a JPanel into an image. I've been using this method: BufferedImage image = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_RGB); Graphics2D g =…
user2589692
  • 83
  • 1
  • 3
8
votes
5 answers

Java TGA loader

I am looking for a small and free TGA image loading class or library for java. Ideally the result is a BufferedImage. Yes, I have already googled, but most results are outdated, or are quite big libraries that contain a lot of other stuff i dont…
clamp
  • 33,000
  • 75
  • 203
  • 299
8
votes
1 answer

How to convert color image to pure black and white image(0-255 format)

public class BlackWhite { public static void main(String[] args) { try { BufferedImage original = ImageIO.read(new File("colorimage")); BufferedImage binarized = new BufferedImage(original.getWidth(),…
Yogesh
  • 91
  • 1
  • 2
  • 7
8
votes
2 answers

Java getSubimage() outside of raster

I'm trying to take an image and store it in an array of 16x16 subimages. The image I am using is 512x512 pixels. However, while iterating through the loop, getSubimage() is stopped by a Raster exception. Here is the code: public class TileList…
Emily
  • 111
  • 1
  • 1
  • 8