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

Add BufferedImage to PDFBox 2.0 document

First time poster, bear with me... I have two questions. First, I want to know how to add an image to a PDFBox 2.0 document using a BufferedImage. The question has been asked here: Add BufferedImage to PDFBox document PDFBox has since excluded the…
vath
  • 153
  • 1
  • 9
10
votes
3 answers

Possible memory leak when caching BufferedImage

We have an application which serve images, to speed up the response time, we cache the BufferedImage directly in memory. class Provider { @Override public IData render(String... layers,String coordinate) { int rwidth = 256 , rheight…
hguser
  • 35,079
  • 54
  • 159
  • 293
10
votes
4 answers

Java - Image Rotation

I am trying to rotate image. I am using this Java code: BufferedImage oldImage = ImageIO.read(new FileInputStream("C:\\workspace\\test\\src\\10.JPG")); BufferedImage newImage = new BufferedImage(oldImage.getHeight(), oldImage.getWidth(),…
liosha
  • 103
  • 1
  • 1
  • 5
10
votes
1 answer

Java BufferedImage, writing to underlying Raster, pixels are appearing offset in the final image

Apologies for thread necromancny, I've attempted to produce a cut down version for testing, it's available here https://www.dropbox.com/sh/y0wtlae37yltfz5/yRDSyKj2NY The largest part of the download is the 3 sample images in the src folder (2 of…
9
votes
6 answers

Change the alpha value of a BufferedImage?

How do I change the global alpha value of a BufferedImage in Java? (I.E. make every pixel in the image that has a alpha value of 100 have a alpha value of 80)
William
  • 8,630
  • 23
  • 77
  • 110
9
votes
2 answers

Conversion from BufferedImage to SWT Image

After much looking, I found a bit of code that converts a BufferedImage to a SWT Image (don't bother reading it yet): public static ImageData convertToSWT(BufferedImage bufferedImage) { if (bufferedImage.getColorModel() instanceof…
Jonah
  • 9,991
  • 5
  • 45
  • 79
9
votes
4 answers

How to convert Icon from JLabel into BufferedImage?

Simple, very straight forward but seems uncle google and me getting confused. I have single JLabel that already has its own Icon. How do I convert the Icon obtained from JLabel into a BufferedImage? Is there any way around: I tried to multiple…
gumuruh
  • 2,544
  • 4
  • 33
  • 56
9
votes
1 answer

How to create a BufferedImage from raw data

I'm trying to get a BufferedImage from raw samples, but I get exceptions about trying to read past the available data range which I just don't understand. What I'm trying to do is: val datasize = image.width * image.height val imgbytes =…
viraptor
  • 33,322
  • 10
  • 107
  • 191
9
votes
4 answers

Rotate an image in java

I am looking to rotate an image. I have a JInternalFrame which contains a JLabel. The label contains the image. After the image has been rotated, I need to resize the internal frame. The code I have currently rotates the image, but there is black…
user489041
  • 27,916
  • 55
  • 135
  • 204
9
votes
2 answers

Scala - how to explicitly choose which overloaded method to use when one arg must be null?

All, I'm doing some image manipulation in Scala by making use of BufferedImages and Raster objects. I am attempting to get all the pixels in the buffered image with the following code. val raster = f.getRaster() // Preallocating the array causes…
I82Much
  • 26,901
  • 13
  • 88
  • 119
9
votes
2 answers

Convert OpenCV Mat object to BufferedImage

I am trying to create a helper function using OpenCV Java API that would process an input image and return the output byte array. The input image is a jpg file saved in the computer. The input and output image are displayed in the Java UI using…
John Ng
  • 869
  • 3
  • 15
  • 28
9
votes
5 answers

Extract words in rectangles from text

I am struggling to extract fast and efficiently words that are in rectangles from a BufferedImage. For example I have the following page : ( edit! ) the image is scanned, so it can contain noise, skewing and distortion. How can I extract the…
Iulian Rosca
  • 1,005
  • 4
  • 15
  • 30
9
votes
2 answers

How to get scaled instance of a bufferedImage

I wanted to get scaled instance of a buffered image and I did: public void analyzePosition(BufferedImage img, int x, int y){ img = (BufferedImage) img.getScaledInstance(getWidth(), getHeight(), Image.SCALE_SMOOTH); .... } but I do get an…
Yoda
  • 17,363
  • 67
  • 204
  • 344
9
votes
1 answer

Getting a BufferedImage as a resource so it will work in JAR file

I'm trying to load an image into my java application as a BufferedImage, with the intent of having it work in a JAR file. I tried using ImageIO.read(new File("images/grass.png")); which worked in the IDE, but not in the JAR. I've also…
fvgs
  • 21,412
  • 9
  • 33
  • 48
9
votes
7 answers

casting parent to child - BufferedImage object

I'm get a ClassCastException whenever I try to cast a BufferedImage (parent) to an AdvancedBufferedImage (child) which I extended myself, I've not overridden any methods and I've implemented all the contractors without modifying them I'm gettign…
Kirill Kulakov
  • 10,035
  • 9
  • 50
  • 67