java image loading with effects - java

I wanted to load java images with some effects like we have in power point like blinds or appear in Java swing when user clicks on the image.
I have these specific questions in mind:
1.Is there a way to do this in Java?
2.Also how will this behave when the image to load is huge like 25 Mega Pixel?
3.If we are dealing with large images being switched, what mechanism should be used for incorporating images in the application?
Thanks,
Sandeep

1.Is there a way to do this in Java?
Yes, but it won't be with a single command or anything like that. Unless you find a library for this, you'll have to code it up manually.
To do animations like these I suggest you have a look at SwingWorkers.
2.Also how will this behave when the image to load is huge like 25 Mega Pixel?
25 mega pixel is quite large. It depends on your computer of course but if you code it reasonable well it should work fine.
3.If we are dealing with large images being switched, what mechanism should be used for incorporating images in the application?
Unless you really want the program to zoom into the details of the image, I suggest you shrink them immediately after loading, so your drawing-routines can work with them efficiently.

You can experiment with your target images using ImageJ. I routinely use it to manipulate images having scores of megapixels containing 8-, 16- and 32-bit data.

Related

CodenameOne - Importing set of images in the theme

My CodenameOne app is mainly intended to be the iOS counterpart of an existing Android app. It is for older devices, in fact, as soon as possible, or in the future, a Swift app is going to replace it for OS 14>.
I need some customised icons and I have the svg code for it.
Initially I had to use the Flamingo tool, that converts svg files in Java classes.
I used it like
ScaleImageButton appButton=new ScaleImageButton(new AppIcon().scaled(doubleButtonSize,doubleButtonSize).toImage());
It is cumbersome but it does not even work on iOS.
So now I resorted to create png images for every icon in every dpi level, as it can also be done on Android.
I renamed the files so they follow the standard I think it is proposed in CodenameOne.
The possible names are:
verylow.png
low.png
medium.png
high.png
veryhigh.png
560.png
hd.png
2hd.png
4k.png
In the end it has to be used like
Image icon = theme.getImage("icon.png");
It seems that the images can be imported in the project in more than one way.
I was said to include them in the theme.
According to the CN1 developer guide I have to set the size for each.
If I import them as a whole (selecting the folder or selecting all images and hitting the "Open" button) in the theme editor a dialog appears with all wrong sizes (but they resemble a particular set of choice, although very unlikely).
They are not always the same sizes but neither they are defaulted according to the provided set of images.
I provide images as 24px, 36px, 48px, 72px, 96px, 144px, 192px, 288px, 384px for normal size icons, and also I provide double sized images for double size icons in my app (the values are not doubled as expected).
I also have to check "Square image" and "Preserve aspect ratio" options (my images are already square).
Then the strangest part is that there is a percentage, I see it is 20 for example.
The caption reads "will affect all entries". I understood that it is to scale images, that is what a developer just do not want, unless the developer has wrong sizes, but still proportioned among themselves, that cannot be the case I think.
However I do not need any scaling, the images are right as they are. I created them on purpose.
The developer guide is not enough clear to me.
So I am asking
is it right to tweak the wrong size to match the right ones, and what about the percentage?
This specific UI is a bit out of date by now and wasn't used much even when it was added. Most users opted to do desktop scaling for multi images.
The scale option is designed to scale down from a high resolution image on the desktop. You don't want/need that.
You don't need to edit the file. Just make sure to turn on the XML team mode and make sure your images use the right file names. Then once you save the images will appear in the resource file.
I suggest adding a multi-image using the standard method of add in the menu. Then replacing all the generated images with your copies and reopening the file, then saving again (the last save is important as it will override the res file).

Java - Image Processing Package

I'm trying to make a maths inspired background image for my computer. What I've decided to do is a visualization of the Collatz Conjecture (video for explanation of the mathematical problem and method of visualization: https://www.youtube.com/watch?v=LqKpkdRRLZw&t=224s). Now I know that there are tons of different cool high resolution images on this very topic but half of the fun in it is making it myself.
So on to the problem. The tree structure is already implemented and took a couple of hours (I'm not a great Java programmer) so what I want to do now is create the actual image. I'm in essence looking for a simple image processing package or even some image processing software that can read information from a .txt file and will let me tell it what to do with it. I want to be able to draw lines, assign widths and colors and chose background colors etc. I had thoughts of doing the entire thing in Matlab instead so if you recommend I do it there I can do that as well. Also python is an option. But to clarify the problem isn't the actual making of the tree but rather the visualization and making a pretty image. Thanks for any help.
EDIT: I just found this (http://marvinproject.sourceforge.net/en/index.html). It seems to do what I want. Is it any good?

What is a good Java lib for image transformations and backbuffer rendering without need of front buffer for server side programming?

I'm trying to find a simple library to fit my needs, but because I am really unaware of Java libs (I use to do everything from scratch in any programming language that I work with) and the exactly thing that I need is complicated for a Google search query, it would be greatly appreciated any recomendation.
What I am trying to achieve is to do some image manipulation in server side using the sumitted info from a web browser. Is not simple scale or crop, but to be able to rotate, scale and crop every single sprite and draw it in the exactly order to compose the final hight resolution image in a backbuffer then save it in bmp and make some copies in lower resolution as png.
I have no problem with the interface from client side to the server, also I have experience in game programming, so I know how to work with double buffering. What I need is a library that let me do all these images transformation and backbuffer drawing without the need of a front buffer and graphics hardware, because the output will not be the screen, and to be able to access every pixel argb from memory, able to save in various image formats and as a plus but not requiered able to render text from different font.
Thanks for any reply and any recomendations to improve my question will be apreciated too (I am new around here).
A couple of libraries you may find helpful for server side image processing in Java:
JH Labs image filters : http://www.jhlabs.com/ip/filters/index.html
imgscalr image scaling library: https://github.com/thebuzzmedia/imgscalr
Also don't forget the good old BufferedImage API that is already in Java: it has quick a decent range of functionality for basic image manipulation (cropping etc.)
http://docs.oracle.com/javase/7/docs/api/java/awt/image/BufferedImage.html

Creating and drawing huge (Buffered) images in Java

I'm working on an application which draws out a matrix - using Java 2D - which can become quite large, for example 30000 x 30000 pixels.
At this moment I've experimented a bit with BufferedImage but creating such a huge BufferedImage causes out of memory exceptions, even when enlarging the heap.
Now I was thinking splitting the image up into several images/regions, and when I'm done in a certain region write it to disk and create a new region/BufferedImage and continue drawing.
I'm interested in thoughts of other people on how they would handle this. I've been away from Java for a while so any concrete examples are welcome.
I contribute to a new/small open source project which may be quite well suited to your needs.
The project is Glimpse. Its intended to aid in construction of 2D data visualizations in Java with a focus on handling large data sets well and making it easy to provide real-time interactivity to allow easy exploration of data.
It utilizes OpenGL to take advantage of hardware features on modern GPUs like texture memory and shaders to achieve the above goals. So if you're set on using Java2D then this won't work for you. However, Glimpse panels can be placed side-by-side with other Swing components, so it's easy to drop into your existing Swing GUI. The only caveat it that you'll need a decent graphics card.
The image is an example of a large matrix of data whose coloring is being dynamically adjusted via the color scale on the right (the matrix data is stored in a GPU texture and the dynamic re-coloring is accomplished via a custom shader). The source for this example is HeatMapExample.java. There's lots of other examples like that which provide starting points for working with Glimpse's other features.
You can learn more at glimpse.metsci.com. There's an intro video on the front page, along with Java WebStart examples. The source is hosted on GitHub.
if you just want to generate the image on disk, then look at pngj - it can generate big png images with no problems because it writes lines of pixels to disk as they are available. the api is a little png-specific, but it's not too complex (it might help to read a little background on the png image format before using it).

Create video from screen capture in java for 64-bit windows

I'm trying to capture a video of a currently running swing application from within the application (the user presses a record button to start recording). I'm not sure how to go about creating a video that records "live." I've looked into using Xuggler, but that isn't available for 64-bit windows (on a 64-bit jvm), and that is important for this application. I don't think it would be feasible to save each screen off as images and then stitch them together because the video could run for several minutes resulting in a very large number of images.
Does anyone have any experience with this and can point me to some ideas on how to do this?
thanks,
Jeff
I was also going to suggest using Robot to take screenshots, but as you said, you would need a way of limiting what is captured. Detecting input events like keys and mouse movement could hint at when is a good time to take another screenshot, and perhaps limiting it to 2 frames per second. When stitching the images back together, the only way you could determine the timing is if you named the files using a timestamp format (with milliseconds).

Categories

Resources