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

Coordinate out of bounds in BufferedImage.getRGB

I am trying to convert this PNG image by this method from an BufferedImage to an double array. public double[][] bufferedToArray(File pngImage) { double[][] imageMatrix= null; try { final BufferedImage image =…
JamesB
  • 569
  • 1
  • 9
  • 31
0
votes
1 answer

Drawing to a BufferedImage sometimes, but consistently, yields wrong colors

I've written a program to modify images. First, I get the image, and get its drawing context like this: BufferedImage image; try { image = ImageIO.read(inputFile); } catch (IOException ioe) { /* exception handling ... */ } Graphics g =…
0
votes
0 answers

Java pixel array reference to BufferedImage data

I have a little problem. I am learning to program games in Java , and I watched a tutorial on using BufferedImage to acess each pixel by array, I mean : int[] pixels = ((DataBufferInt) screen.getRaster().getDataBuffer()).getData(); It all works,…
Jacob
  • 111
  • 1
  • 2
  • 8
0
votes
2 answers

Draw grayscale image to another BufferedImage's alpha band using API only

I've got two BufferedImages: one is TYPE_INT_ARGB, and the other is TYPE_BYTE_GRAY. How to replace the entire color image's alpha band with the grayscale image using API only, and without disturbing the RGB values? final int width = 200; final int…
0
votes
0 answers

How do I size the BufferedImage needed to hold all of a Graphics2D text rotated to an arbitrary angle?

I create png Images from short pieces of text to be used as floating labels, prompts, speechbubbles, etc in a 3D graphics application. Occasionally some of my text needs to be rotated. Unfortunately the 3D application does not provide rotation for…
casgage
  • 529
  • 1
  • 7
  • 18
0
votes
2 answers

How to test if BufferedImage using ImageIO picks up a 'null'

I am trying to set my program (java using netbeans) to do one thing if it finds the image its looking for, and another thing if it doesn't... this is what I have got so far however it never completes the else statement. I believe this is because…
giddian
  • 3
  • 3
0
votes
1 answer

How do I make my WritableRaster and pixelsize bigger in java?

I have a txt file with nrows, ncols etc and ex elevation values as numbers which we are supposed to make a map image of. I have code (that works) but my problem is that the pixels are exactly one pixel big each, they actually have a cellsize also…
user3514461
  • 9
  • 1
  • 5
0
votes
0 answers

Java- printing image objects from an arrray

I have created a method which fills an array with 52 objects. Each object has a String suit, String face, int value, and a buffered image. Each object gets its image from a larger image and a getSubImage method. I am trying to make a GUI which…
user8889724
0
votes
1 answer

Creating a image indices converter

Method toVertical, which accepts two parameters parameters in the following order: (a) An image of type BufferedImage (b) A proportional y-coordinate of type double It returns as an int the pixel coordinate in the image that corresponds to the…
user8890315
0
votes
1 answer

BufferedImage disable dithering when reducing color using custom ColorModel?

I'm creating an image with a custom palette (in other words a custom colormodel): BufferedImage img = new BufferedImage(orgImg.getWidth(), orgImg.getHeight(), BufferedImage.TYPE_BYTE_INDEXED, cm); Graphics2D g2 = img.createGraphics(); …
Tinus Tate
  • 2,237
  • 2
  • 12
  • 33
0
votes
1 answer

BufferedImage causes a program freeze on MacOs but not on Windows

I'm using a piece of code to grab a screenshot of my application screen for a group project. On my Macbook Pro the code freezes the screen whereas on my teammates's PC's (all Windows) it runs just fine and exports a .png file in their root dir. The…
Arno C
  • 470
  • 4
  • 18
0
votes
1 answer

How can I edit a BufferedImage after it has been displayed?

I'm working with a 16bit grayscale image: BufferedImage bufferedImage = new BufferedImage(320, 240, BufferedImage.TYPE_USHORT_GRAY); I'm able to edit that image by grabbing a reference to its underlying storage. The data is stored in a linear…
Mr. Smith
  • 4,288
  • 7
  • 40
  • 82
0
votes
1 answer

Issues with using Java Method getImage() I created?

So I'm attempting to create a simple application in which I can click a button and allow the user to display an image of their choice using a jFIleChooser from the menu and display that image into a label. I wrote code that works for that, but I'm…
hnoel13
  • 58
  • 12
0
votes
2 answers

BufferedImage from 4-bit data buffer

Hello I have a problem with converting my 4-bit data buffer to WritableRaster. Image resolution: 1024x768 (786432) Here is description what I'm doing. 1) Create 4-bit BufferedImage bit4Image = new BufferedImage(width, height,…
GruchaAP
  • 53
  • 1
  • 10
0
votes
1 answer

Problems with BufferedImage in Java

I am making a game (like Civilization) that has different tile types that I want to render as images. I have 9 different 16x16 png images to load in (called Con1, Con2, etc.), and here is my image loading code: (img[] is my BufferedImage…
Spencer Lutz
  • 311
  • 1
  • 2
  • 14