bufferedimage

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 any ideas? My current best guess at doing something like this is to get the rgb value of eac...

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 someone please provide sample code for using the following constructor? BufferedImage(Color...

MemoryCacheImageOutputStream To BufferedImage

I have some image constrain code that allows you to output to a MemoryCacheImageOutputStream, but I need to get this back into a BufferedImage, any suggestions? ...

How do I properly load a BufferedImage in java?

Okay, so I've been trying to load a BufferedImage using this code: URL url = this.getClass().getResource("test.png"); BufferedImage img = (BufferedImage) Toolkit.getDefaultToolkit().getImage(url); This gives me a type cast error when I run it though, so how do I properly load a BufferedImage? ...

How to calculate java BufferedImage filesize

I have a servlet based application that is serving images from files stored locally. I have added logic that will allow the application to load the image file to a BufferedImage and then resize the image, add watermark text over the top of the image, or both. I would like to set the content length before writing out the image. Apart f...

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) ...

Load a PNG image into Java as BufferedImage through JNI C code

Hi, I have the following problem. I have C code that acquires a PNG image as basically raw data and keeps it in memory. I would like this raw data to be translated to a BufferedImage in Java, through the use of JNI. Does anyone know any way of doing this or has done this before? ...

Trying to read raw image data into Java through JNI.

I'm using JNI to obtain raw image data in the following format: The image data is returned in the format of a DATA32 (32 bits) per pixel in a linear array ordered from the top left of the image to the bottom right going from left to right each line. Each pixel has the upper 8 bits as the alpha channel and the lower 8 bits are the blue ...

Java Convert ColorSpace of BufferedImage to CS_GRAY without using ConvertColorOp

I know its possible to convert an image to CS_GRAY using public static BufferedImage getGrayBufferedImage(BufferedImage image) { BufferedImageOp op = new ColorConvertOp(ColorSpace .getInstance(ColorSpace.CS_GRAY), null); BufferedImage sourceImgGray = op.filter(image, null); return sourceImgGray; } however, this is a chokepoint...

Creating very large image files with BufferedImage, strange issues depending on compilation and computer

I'm attempting to create a very large image in Java like so: BufferedImage bi = new BufferedImage(58240, 1664, BufferedImage.TYPE_INT_RGB); obviously the image is very large. Now the issue I'm having is that it seems to work fine 100% on some computers but really slowly on others (and no this has NOTHING to do with specs). My most m...

Render to BufferedImage in Java3D

Is there a simple way of rendering to a BufferedImage in Java3D? I know you can extend Canvas3D, but it seems cumbersome if I just want to render directly. ...

Why does my off screen rendering Canvas3D not work?

I've been trying to make off screen rendering to work, using Java3D 1.5.2. In my source code I've been trying to attach an extended Canvas3D that will do off-screen rendering to SimpleUniverse, but doing so will break the render: 62. // FOR SOME REASON THIS BREAKS RENDERING 63. universe.getViewer().getView().addCanvas3D(canvas); The...

Set bufferedimage to be a color in Java

I need to create a rectangular BufferedImage with specified color as a background, draw some pattern on the background and save it to file. My problem comes from how to create the background,I am using nexted loop: BufferedImage b_img = ... for every row for every column setRGB(r,g,b); But it's very slow when the image is large. How ...

Java TGA loader

Hello, I am looking for a small and free TGA image loading class or library for java. Ideally the result is a BufferedImage. Yes, I have already googled, but most results are outdated, or are quite big libraries that contain a lot of other stuff i dont need. I am looking for something small and simple that reads just TGA images. Thanks...

Obtaining a screen shot of an Applet?

Given an Applet object, is it possible to programatically obtain a "screen shot" of the applet window (represented as say a BufferedImage)? JApplet applet = this; // ... code here ... BufferedImage screenshotOfApplet = ...; ...

IOException while changing from File to BufferedImage

Error: Unhandled exception type IOException. File imgLoc = new File("player.png"); BufferedImage img = ImageIO.read(imgLoc); How do I get a bufferedImage from a file location? ...

How to read pixel color in a java BufferedImage with transparency

Hi, I am reading pixel color in a BufferedImage as follows: ..... InputStream is = new BufferedInputStream(conn.getInputStream()); BufferedImage image = ImageIO.read(is); int color = image.getGRB(x, y); int red = (colour & 0x00ff0000) >> 16; int green = (colour & 0x0000ff00) >> 8; int blue = colour & 0x000000ff; Now this works f...

loading BufferedImage with ClassLoader.getResource()

Hello, I am trying to load an image file (gif) which is stored locally in the same directory as my Eclipse java project: ref is the relative path where the gif image is stored. public Sprite getSprite(String ref) { BufferedImage sourceImage = null; try { URL url = this.getClass().getClassLoader().getResource(ref); ...

Turning Image object into BufferedImage object

Given an Image object, how do I turn that into a BufferedImage object without using any of the graphics stuff? Thanks. (P.S. I'm using Java ImageIO library) ...

Fastest way to compare pixel values between two BufferedImages?

I have a BufferedImage of type TYPE_INT_BGR. I need to do a pixel-by-pixel comparison to another BufferedImage to compute the "distance" between the two images. I have something that works, but is slow. I get a pixel from the "reference" image, break it up into RGB bytes with: int pixel = referenceImage.getRGB(col, row); int ...