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
5
votes
1 answer

Using several bufferedImages in java

I'm making a game in a java applet and I'm trying to optimise my code to reduce flickering. I've already implemented double buffering, so I'm trying to use another BufferedImage in order to store a picture of the elements of the game's background…
Ryan Stull
  • 1,056
  • 14
  • 35
5
votes
1 answer

How to load BufferedImage in android?

I want to load BufferedImage in my application. For that I am using ImageIO but I am getting java.lang.NoClassDefFoundError: BufferedImage tgtImg = loadImage("ImageD2.jpg"); public static BufferedImage loadImage(String ref) { BufferedImage…
Monali
  • 1,966
  • 12
  • 39
  • 59
5
votes
3 answers

Create a buffered image from rgb pixel values

I have an integer array of RGB pixels that looks something like: pixels[0] = pixels[1] = pixels[2] = pixels[3] = ...etc... And I'm trying to…
Jeff Storey
  • 56,312
  • 72
  • 233
  • 406
5
votes
4 answers

how can I convert an RGB image to CMYK and vice versa in Java?

our web app let users download dynamically generated images in different formats (bmp, png and jpeg). Some of our users download the images for printing, thus we would like to allow them to choose between RGB or CMYK. Is there a way to specify the…
Olivier
  • 305
  • 1
  • 4
  • 17
5
votes
1 answer

Resizing TYPE_CUSTOM BufferedImages?

When I read a JPEG from disk, Java sometimes gives me a BufferedImage whose getType() returns TYPE_CUSTOM -- that is, it has a custom color model. I'd like to resize this BufferedImage but I'm not sure how to construct the destination object. Can…
Gili
  • 86,244
  • 97
  • 390
  • 689
5
votes
3 answers

Why does a BufferedImage require so much memory beyond the size of its data array?

I'm trying to determine how much heap any given TYPE_INT_ARGB BufferedImage will use so that, for a program which is doing some image processing, I can set a reasonable max heap based on the size of image we feed it. I wrote the following program as…
uckelman
  • 25,298
  • 8
  • 64
  • 82
5
votes
3 answers

BufferedImage unexpectedly changing color

I have following code, which creates grayscale BufferedImage and then sets random colors of each pixel. import java.awt.image.BufferedImage; public class Main { public static void main(String[] args) { BufferedImage right = new…
Glissinda
  • 169
  • 1
  • 9
5
votes
6 answers

Reliable way to check if image is Grey scale

I am currently working on one use case where i need to determine if uploaded image is Grey Scale or RGB. I found couple of ways to identify this, but not sure if they are reliable and can be used collectively to confirm image is grey scale or…
Dark Knight
  • 8,218
  • 4
  • 39
  • 58
5
votes
2 answers

Is there any way in Java to take image width and height without transfer or download?

In order to get image's height we can use ImageIO.read(new URL("…")).getHeight(). My questions: Do I understand correctly that this method downloads the image to the local computer prior size calculation? If yes, to where exactly the image is…
Mike
  • 14,010
  • 29
  • 101
  • 161
5
votes
0 answers

Is there the better way to resize the Buffered image without losing of quality?

To resize the Buffered Image I have the following method: BufferedImage resizeImage(BufferedImage img, int newW, int newH) { Image tmp = img.getScaledInstance(newW, newH, Image.SCALE_SMOOTH); BufferedImage dimg = new…
Dylan
  • 935
  • 1
  • 11
  • 24
5
votes
3 answers

Get average color on bufferedimage and bufferedimage portion as fast as possible

I am trying to find image in an image. I do this for desktop automation. At this moment, I'm trying to be fast, not precise. As such, I have decided to match similar image solely based on the same average color. If I pick several icons on my…
Tomáš Zato
  • 50,171
  • 52
  • 268
  • 778
5
votes
2 answers

How to convert BufferedImage to image to display on JSP

I would like to convert BufferedImage to an image that will display on JSP page. How can I achieve this?
user286004
  • 75
  • 1
  • 3
  • 8
5
votes
4 answers

Colorizing images in Java

I'm working on some code to colorize an image in Java. Basically what I'd like to do is something along the lines of GIMP's colorize command, so that if I have a BufferedImage and a Color, I can colorize the Image with the given color. Anyone got…
Paul Wicks
  • 62,960
  • 55
  • 119
  • 146
5
votes
1 answer

BufferedImage getScaledInstance changes brightness of picture

I use this piece of code to draw a Image into a Graphics component. It should size the image to the maximum space available, if it is big enough: // getWidth() = component width, image.getWidth() = image width double w = getWidth() * 1.0 /…
Sebastian
  • 1,873
  • 4
  • 25
  • 57
5
votes
1 answer

How to convert a BufferedImage to black and white?

How can I convert an existing colored BufferedImage to monochrome? I want the image to be completely split between only two rgb codes, black and white. So if there's a border around the image which is a lighter or darker shade of the background, and…
user2790209
  • 339
  • 2
  • 5
  • 17