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

This code won't display a rectangle, but it should

I am making a JFrame and drawing a rectangle onto it. It doesn't work, sometimes it is completely black and sometimes completely white, here are my methods. So the render method is called twice because the first time it creates the buffer, also…
0
votes
3 answers

Why isn't my method for removing this color working?

I'm trying to make a Mario game clone, and right now, in my constructor, I have a method that is supposed to make a certain color transparent instead of the current pinkish (R: 255, G: 0, B: 254). According to Photoshop, the hex value is ff00fe. My…
Derry
  • 371
  • 1
  • 13
0
votes
2 answers

how to hide 2^12 binary bit in RGB layer

i want to hide 2^12 binary bit into a RGB layer. Example 000011010000 this value i want to hide in RGB layer. the 2^12 bit must devide into 3 layer like 0000 hide in R layer 1101 in G layer and 0000 in B layer. anyone know how to do this in java..
kan
  • 1
0
votes
1 answer

Java BufferedImage Rotate

I need to rotate a jpg image so I wrote this function: BufferedImage rotate(BufferedImage bufferedImage) { AffineTransform tx = new AffineTransform(); tx.rotate(Math.PI/2.0, bufferedImage.getWidth() / 2, bufferedImage.getHeight() / 2); …
user1941319
  • 375
  • 3
  • 19
0
votes
0 answers

Difference between SampleModels in Java?

So It took me quite some time solving one problem I had in my code and I'm very interested in some details. I've written a part what exactly I was doing down at the end. So i was reading an image which I wanted to use with static BufferedImage img…
0
votes
0 answers

My pixels won't draw in the places I've put them

I'm trying to draw individual pixels to the screen using a BufferStrategy but when I run the program all the pixels are displayed werid, it's supposed to make 1 square in the top left, but it makes multiple squares that have black lines in between…
0
votes
2 answers

BufferedImage in java larger than 2^31 pixels

I need to create a very large image in java and so far I've been using the java.awt.image.BufferedImage class. But it seems that this class stores it's pixels with an int as it can not go past 2^31 pixels. I've thought about creating smaller images…
0
votes
1 answer

Byte array of 3/3/2 RGB samples to BufferedImage in Java

I have a byte array, where each byte describes one pixel (256 colors). Here is bitmask that I use: 0xRRRGGGBB So there are 3 bits for R and G components and 2 bits for B component. How can I construct BufferedImage from that array assuming that I…
ddms
  • 50
  • 6
0
votes
1 answer

Java - Create a BufferedImage clone which has no reference to the original

I'm working for a swing project and I have to display the same image multiple times, by changing pixels color every time. For example : the first image must be displayed in blue and the second one must be displayed in orange, but the problem is that…
kazrak
  • 3
  • 6
0
votes
1 answer

Saving custom BufferedImage

I have raw grayscale image pixels represented by short[]. I would like to create BufferedImage from it and save it as PNG. Since there is no TYPE_SHORT_GRAY defined for BufferedImage I'm creating one myself this way: short[] myRawImageData; //…
JobNick
  • 473
  • 1
  • 6
  • 18
0
votes
0 answers

Polygon color overlay

If I draw a new polygon on the buffered image, the color between the polygon and the background should overlay, like on the picture below. Currently my code looks like this. Graphics graphics =…
user6723683
0
votes
0 answers

Load Buffered Image in Java

My Game Class: public class Game implements Runnable{ ..... private BufferedImage test; private void initial(){ test=ImageLoader.loadImage("/img/back.jpg"); } ...... } My ImageLoader Class: public class ImageLoader { …
Zuo Ksr
  • 21
  • 3
0
votes
0 answers

Java - How to change opacity on BufferedImage in java.awt.Graphics?

Can anyone tell me how to change opacity on the drawImage() function from the regular Graphics object, not the Graphics2D object? Most threads on here suggest using Graphics2D, but in my game, rendering is done through regular Graphics objects, so…
iPsych0
  • 19
  • 3
0
votes
1 answer

Why can't I erase my Sprite

I've been trying for a while now to get a game working in Java, after much anguish over other peoples Sprite functions I made my own and don't understand why I can't erase it. I know it's changing the pixels of the background to display my archer…
0
votes
1 answer

Compare rotated images in java

I have a picture and a rotated picture to compare. if (this.img.getHeight() == img1.getWidth() && this.img.getWidth() == img1.getHeight()) { for (int i = 0; i < this.img.getWidth(); i++) { for (int j = 0; j <…
derfium
  • 173
  • 1
  • 3
  • 15