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

Using java.awt.image.BufferedImage for creating BIFF8 BITMAP record takes much time - Is there any better approach?

So I am creating a HSSFSheet having a background bitmap set using apache poi and own low level code. The https://www.openoffice.org/sc/excelfileformat.pdf declares for the Record BITMAP, BIFF8: Pixel data (array of height lines of the bitmap, from…
Axel Richter
  • 56,077
  • 6
  • 60
  • 87
4
votes
2 answers

Getting filename from BufferedImage

Is there a way to get the filename from a BufferedImage? I don't seem to see any methods for it.
user564873
  • 41
  • 1
  • 3
4
votes
3 answers

Part 2 - How do I get consistent rendering when scaling a JTextPane?

I submitted another version of this question and a sample program before: How do I get consistent rendering when scaling a JTextPane? Recapitulating the problem: I would like to allow users to zoom into or out of a non-editable JTextPane. Running…
jht
  • 125
  • 5
4
votes
1 answer

Java error creating BufferedImage from ByteArrayInputStream

I'm trying to create a BufferedImage from a ByteArrayInputStream with: byte[] imageData = getData(imageFile); // returns file as byte[] InputStream inputStream = new ByteArrayInputStream(imageData); String format =…
Rui
  • 5,900
  • 10
  • 38
  • 56
4
votes
1 answer

TYPE_4BYTE_ABGR to TYPE_3BYTE_BGR conversion

I have a BufferedImage of TYPE_4BYTE_ABGR imageType with transparency and I want to convert it into TYPE_3BYTE_BGR BufferedImage. I tried to draw TYPE_4BYTE_ABGR image on TYPE_3BYTE_BGR one, but it changed colors. The aim is to put transparent image…
4
votes
2 answers

Convert 2D pixel array into BufferedImage

I used the accepted answer's code from this SO question. Now, I want to convert in back to a BufferedImage (preferably not with setRGB()). I've tried this: private BufferedImage createImage(int[][] pixelData, BufferedImage outputImage){ final…
ack
  • 1,181
  • 1
  • 17
  • 36
4
votes
1 answer

Get bits per pixel of a BufferedImage

I'm currently working on comparing a filtered image to its original (unfiltered) image using the SSIM (Structural similarity) index using Java. My research brought me to a mathematical formula where the average, variance, covariance and the dynamic…
Walkaa
  • 65
  • 3
4
votes
4 answers

Write to 16 bit BufferedImage TYPE_USHORT_GRAY

I'm trying to write 16 bit grayscale imagedata to a png using BufferedImage.TYPE_USHORT_GRAY. Normally I write to an image like so: BufferedImage image = new BufferedImage(width, height,…
Erik Stens
  • 1,779
  • 6
  • 25
  • 40
4
votes
2 answers

JCodec Picture to BufferedImage

I am new to JCodec, but I am attempting to convert a JCodec Picture to a BufferedImage. Unfortunately, the methods to do so in JCodec have been deprecated, save for those methods converting a Picture to a Picture8Bit. However, I haven't found a…
tpm900
  • 271
  • 5
  • 11
4
votes
2 answers

Equivalent to imshow in Clojure?

I'm looking for a way to visualize a 2d java array that's being updated in a simulation written in clojure the same way I would use imshow in matplotlib to visualize a numpy array. What's the best way to do this? Alternatively I could save the…
2daaa
  • 2,788
  • 7
  • 33
  • 44
4
votes
1 answer

Serve a BufferedImage by a Ring handler

I'm looking for a way to let a ring server - by request - grab an image from an URL, process it and serve the modified version. This is how I got so far: (require '[clj-http.client :as client] '[ring.adapter.jetty :refer…
Anton Harald
  • 5,772
  • 4
  • 27
  • 61
4
votes
1 answer

Java Graphics2D Drawing into BufferedImage

I'm busy fiddling around with Java's Graphics2D and drawings and I although it works I am not sure how to create a BufferedImage from this graphic which it seems I need to do in order so save it somewhere. I have something very basic because I'm…
TheLovelySausage
  • 3,838
  • 15
  • 56
  • 106
4
votes
3 answers

How to solve java.lang.IllegalArgumentException: Width (-1) and height (-1) cannot be <= 0?

I've been spending the last hours trying to solve the stack trace below. With major research on here SO and also through Google, I understand the exception can mean several things: the program can't find the requested images with the provided…
Mark Doe
  • 125
  • 2
  • 2
  • 9
4
votes
1 answer

Manipulating pixels in BufferedImage

I wanted to manipulate pixels in a bufferedimage by doing this: BufferedImage screen = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); int[] pixels = ((DataBufferInt)screen.getRaster().getDataBuffer()).getData(); The problem is: It…
TheCreator
  • 63
  • 8
4
votes
2 answers

Converting ImageIcon to BufferedImage (how to set image type)

what I'm making is very simple image editing program and I have a problem with something. I saved the images in DB and converted it as a ImageIcon so that it can go through server sockets and such (serializable). So through the VO I get the…
SunSun
  • 129
  • 3
  • 15