bufferedimage

Resize JComponent for file export

I have a JPanel upon which I draw a number of custom-written JComponents using the usual 'paintComponent(Graphics g)' method. I use a JLayeredPane to control the display order of the custom components, as follows: public Class MyPanel extends JPanel { private JLayeredPane layeredPane = new JLayeredPane(); private JComponent com...

Will Perl be the bottleneck in this kind of image processing?

The processing I have in mind is this: there are thousands of png files each of them should be loaded, and its pixels accessed each pixel's channels will be processed in some way, and then written to a binary file I was thinking of using some sort of module, like ImageMagick wrappers, or some other wrapper for a C image processing ba...

Clear a transparent BufferedImage as fast as possible

I have a transparent BufferedImage created with the following code(not relevant how it is created, I think): GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gs = ge.getDefaultScreenDevice(); GraphicsConfiguration gc = gs.getDefaultConfiguration(); ...

Java: Send BufferedImage through Socket with a low bitdepth

Hi, The title says enough I think. I have a full quality BufferedImage and I want to send it through an OutputStream with a low bitdepth. I don't want an algorithm to change pixel by pixel the quality, so it is still a full-quality. So, the goal is to write the image (with the full resolution, full size) through the OuputStream which t...

Grails: write BufferedImage into response

Hi. I have ImageController with resize method: def resize = { def pht = Photos.findByTypeAndPhotourl(params.type, params.photourl) if (pht != null) { BufferedImage source = ImageIO.read(new File(pht.photo)) ImageResizer imageResizer = new ImageResizer() BufferedImage result = imageResizer.resize(source, Intege...

Java error on bilinear interpolation of 16 bit data

I'm having an issue using bilinear interpolation for 16 bit data. I have two images, origImage and displayImage. I want to use AffineTransformOp to filter origImage through an AffineTransform into displayImage which is the size of the display area. origImage is of type BufferedImage.TYPE_USHORT_GRAY and has a raster of type sun.awt.im...

How to convert BufferedImage to Image to display on JSP.

Hello friends, I want to convert BufferedImage to Image so that it will display on JSP page. ...

What's the best way to fill or paint around an image in Java?

I have a set of images that I'm combining into a single image mosaic using JAI's MosaicDescriptor. Most of the images are the same size, but some are smaller. I'd like to fill in the missing space with white - by default, the MosaicDescriptor is using black. I tried setting the the double[] background parameter to { 255 }, and that fill...

Playing a .wav sound file in JPanel/JFrame using Java (Swing)

I need some code example on how I would use a filepath from a harddrive location to then play a .wav sound file when opened in swing GUI. I don't need it to show a play button, or pause or stop. I just want it to play when I select the 'Sound' option from my 'Files' in my window (I know how to do that already, no need to explain that). ...

Best approach to storing image pixels in bottom-up order in Java

I have an array of bytes representing an image in Windows BMP format and I would like my library to present it to the Java application as a BufferedImage, without copying the pixel data. The main problem is that all implementations of Raster in the JDK store image pixels in top-down, left-to-right order whereas BMP pixel data is stored ...

Calculating rgb vals for BufferedImage

I am using following snippet to build a 32 bit integer to use with setRGB of BufferedImage (bit-or (bit-shift-left a 24) (bit-or (bit-shift-left r 16) (bit-or (bit-shift-left g 8) b))) after writing colors reading them back reveals wrong colors is there a fault in my logic? ...

Getting Greyscale pixel value from RGB colourspace in Java using BufferedImage

Anyone know of a simple way of converting the RGBint value returned from <BufferedImage> getRGB(i,j) into a greyscale value? I was going to simply average the RGB values by breaking them up using this; int alpha = (pixel >> 24) & 0xff; int red = (pixel >> 16) & 0xff; int green = (pixel >> 8) & 0xff; int blue = (pixel) & 0xff; and the...

how to run/compile java code from JTextArea at Runtime? ----urgent!!! college project

I have a JInternalFrame painted with a BufferedImage and contained in the JDesktopPane of a JFrame.I also have a JTextArea where i want to write some java code (function) that takes the current JInternalFrame's painted BufferedImage as an input and after doing some manipulation on this input it returns another manipulated BufferedImage t...

Java paint speed relative to color model

I have a BufferedImage with an IndexColorModel. I need to paint that image onto the screen, but I've noticed that this is slow when using an IndexColorModel. However, if I run the BufferedImage through an identity affine transform it creates an image with a DirectColorModel and the painting is significantly faster. Here's the code I'm...

How to save file using JFileChooser??

Hi, I have a method in my application called "Save as" which Saves the image of my application on computer my into a file. I used the JFileChooser to let the users choose their desired location for saving the file. The problem is unless user explicitly types in the file format, it saves the file with no extension. How can I have formats...

How to specify behavior of Java BufferedImage resize: need min for pixel rows instead of averaging

I would like to resize a Java BufferedImage, making it smaller vertically but without using any type of averaging, so that if a pixel-row is "blank" (white) in the source image, there will be a white pixel-row in the corresponding position of the destination image: the "min" operation. The default algorithms (specified in getScaledInstan...

Can a BufferedImage be written to file any format?

Is it correct that if we have a BufferedImage object in java, we could potentially write it out in ANY format using ImageIO.write (if we have a Writer object for the same)? I tried writing a BufferedImage object into a jpg file, it outputted an empty image file however when i tried writing it in to a png file, it worked fine. ...

Saving an BufferedImage to raw bytes

Hello i want to Saving an BufferedImage to raw bytes i do this for the moment InputStream in = new ByteArrayInputStream(fileData); BufferedImage image = javax.imageio.ImageIO.read(in); BufferedImage imageModifier = ResizeImage.resize(image, 10, 10); but know i want to save my file so i don(t know how to convert for do this FileOutput...

Is there an equivalence of MapRGB for a BufferedImage in Java?

I'm trying to color individual pixels in a BufferedImage (TYPE_INT_RGB) using setRGB(), but I'm not sure how to format the RGB values. I want the result as a single integer. Is there a method that will take three int values (red, green, blue) and return a correctly formatted integer for setRGB()? ...

Move multiple BufferedImage in Java2D?

How can I mousedrag different BufferedImages in Java2D? For instance, if I have ten or more images, how can I move that images which my mouse is over? Now I'm importing an BufferedImage with BufferedImage img = new BufferdImage(new File("filename")); And I'm painting this with Graphics2D with public void paintComponent(Graphics g) ...