Java Picture Processing Framework - java

1) Load picture from byte array.
2) Verify it's current picture size.
3) Resize Picture according to my needs.
Is there any out of the box Java Framework which can help me to do it?
Thanks in advance.

Actually, java's default packages should be enough:
To load an image use javax.imageio.ImageIO.read(...)
To get it's size use the getWidth() and getHeight() of the returned BufferedImage object
To resize the image, you can: Create a new image (BufferedImage), acquire it's Grahpics objects, set the transformation, and then draw the original image.
Refer to the java working with images tutorial

I found thumbnailator to be very good.

Related

javaxt.io.Image doubles in size when using saveAs()

In an application, I need to use javaxt.io.Image to rotate the image and then save it into a new file. This is the code:
Image image = new Image(input);
image.rotate();
image.saveAs(output);
While the image does lose the EXIF rotation, which is the reason I needed this functionality, the image almost doubles in size. input.jpg is at 2.8MB, while output.jpg becomes 4.3MB. I couldn't find a parameter or function for compression in javaxt.io.Image.
Did I miss a step or is this behaviour wanted by the library? What would be the most efficient way to re-reduce the size?
As Thomas commented, I missed the function setOutputQuality(float quality) in the library documentation. Using that enables you to compress your images.

Get a BufferedImage output composed of several image layers

for my current work, I need to add images on top of other images at runtime. I already searched and I don't want to draw it on a Swing component, I use it in an external API.
Ideally, I would like a library (or a java-native way) with which I can specify several images to "layer", and it would return me a BufferedImage (or any Image object by the way).
If you want a single image (BufferedImage) in return, then you need to compose your images.
This answer may help you stackoverflow.com/questions/2318020/merging-two-images.
Have a look at the documentation for method drawImage to control position and scaling of any drawing through the Graphics object.

how to scale splashcreen image in Java ME application created in Netbeans

I create Java ME application in Netbeans. I use a splashcreen and I put an image on it. I want this image to be scaled, so it has a right size on different screens - bigger ones and smaller ones. How can I do that?
If I remember correctly there is a method that you can call that will get the height and width of the screen that is currently in use. You can then use these values to re-size you image as needed. Here is an example of getting the height and width:
http://www.java-tips.org/java-me-tips/midp/how-to-get-the-size-of-mobile-screen.html
Hope this helps!
there is no image prossing api in midp 2.0 spec. so you should use 3rd library of function. you can use lwuit library. it has many image process functionality.
http://lwuit.java.net/
This is Simple One Example to show you Splash Screen in JavaME
Thanks

Create an Image out of a larger Image

For a game I'm making I am storing all the sprites for the map inside one large(er) image. I want to be able to create an instance of Image for each image inside of the larger image that has all the sprites.
So how would I create an instance of Image from a set position of another Image.
The basic solution (if all tiles in your tilesheet have the same size) is to use the getSubimage(xpos, ypos, XSIZE, YSIZE) method from the class BufferedImage.
Otherwise, you'll have to store a set of position and size for all sprites in another file.
Your question is similar to this others one.
Since you are using the java.awt.Image-class i am guessing you are trying to create a reasonable game using AWT? You really should take a look at a different technology like http://en.wikipedia.org/wiki/Java_OpenGL. The problem you ran into (partitioning a sprite-sheet) is typical for a lot of other problems (rotation...) you will run into if you try to develop a game without something like Open-GL.
Considering only the problem at-hand: you can easily solve this in Open-GL by binding the whole sprite-sheet as texture (glBindTexture()) and giving for each glVertex() a glTexCoord2f(), no need to cut-out parts of the sprite-sheet.

How to use Java and NetBeans to display data as an image

I am new to Java and NetBeans but have experience in C/C++. I will be working on an application which will have an area to display an image. The image will be created in memory as an array of unsigned bytes and considered to be monochrome.
I'm looking for a tutorial or examples of displaying data like this as an image. (The data will be read from an imaging radiometer - every few seconds) I've looked at some classes in AWT but I need an example.
Thanks
Have a look at Trail: 2D Graphics and BufferedImage.
Here's a very simple example of manipulating the pixels of an off-screen image directly. This more complex example examines several approaches to accumulating image data in a separate thread and viewing periodic updates.
It looks like you have two problems.
Creating a java Image object from an array:
Turn an array of pixels into an Image object with Java's ImageIO?
Displaying the java Image:
How to add an image to a JPanel?
More info on rendering with a JPanel can be found here:
http://java.sun.com/docs/books/tutorial/uiswing/painting/index.html

Categories

Resources