I have a .gif file with four frames, i used Ion library for animation but it doesn't show good result. Because this library shows previous frame along with animation. How can i fix that?
Here is a link to a relevant question Display Animated GIF that has already been answered. Essentially, it says that you can display .gifs with the android.graphics.Movie class. It has been available from API level 1. check out this code linked here https://code.google.com/p/apidemos/source/browse/trunk/ApiDemos/src/com/example/android/apis/graphics/BitmapDecode.java#103
and from line 103 down there is an implementation of it opening an gif resource
Related
I would like to load video from file, make some transformation on it and render it back into file. Said transformation is mainly two videos overlapping and shifting one of them in time. Grafika has some examples relevant to this issue. RecordFBOActivity.java contains some code for rendering video file from surface. I'm having trouble changing two things:
instead of rendering primitives in motion I need to render previously decoded and transformed video
I would like to render surface to file as fast as posible, not along with playback
My only success so far was to load .mp4 file and add some basic seeking features to PlayMovieActivity.java. In my reasearch I came across these examples, which are also using generated video. I didn't found them quite useful, because I couldn't swap this generated video with decoded one from file.
Is it posible to modify code of RecordFBOActivity.java so it can display video from file instead of generated animation?
You can try INDE Media for Mobile, tutorials are here: https://software.intel.com/en-us/articles/intel-inde-media-pack-for-android-tutorials
Sample code showing how to enable editing or make transformation is on github: https://github.com/INDExOS/media-for-mobile
It has transcoding\remuxing functionality in MediaComposer class and a possibility to edit or transform frames. Since it uses MediaCodec API inside encoding is done on GPU so is very battery friendly and works as fast as possible.
I am working on an application where i need to load the server images in list. But the way of displaying images is bit different. I need to display image as it gets downloaded i.e. pixel by pixel. Initially the image sets as blur image than as it gets downloaded, its gets more sharper and results into the original image. If you want to see what i am talking about than you can refer to the below link:
Progressive Image Rendering
In this you can see the demo of the superior PNG style two-dimensional interlaced rendering(the second one). I goggled a lot but did not find any relevant answer to my query.
Any sort of help would be appreciable.
Thanks in advance.
Try Facebook's Freso project: http://frescolib.org/#streaming
If you use Glide, the library recommended by Google for loading images in Android, you can achieve this kind of behavior with .thumbnail this receives the fraction of the resolution you'll like your image to show while the full resolution finishes loading.
Glide.with( context )
.load( "image url" )
.thumbnail( 0.1f ) //rate of the full resoultion to show while loading
into( imageView ); //ImageView where you want to display the image
Here is a more extensive explanation of the library and the thumbnails:
https://futurestud.io/blog/glide-thumbnails
Recently, I have taken java and now am heading into Android Java.
However, Android has quite a few different things to tackle when programming.
So as my title says, how can I Import an image from my /res folder and paint it on the screen?
Usually, I would do something like this.
import java.awt.*
And in main class
public Image img;
And in public void paint
case CASE:
g2d.drawimage(...)
break
This doesn't seem to work in android.
Can someone explain how you could import and display images in a location in android?
It's great to see someone new trying out android development.
As for your question you could use and ImageView though if you are looking for something more dynamic then you should use a canvas. It will allowing for drawing images and animations.
I highly recommend you check out these tutorials:
Here is a list of 200 android tutorials that really helped me start out. Though some go over features that are now deprecated.
Android Tutorials
Here is where the videos start going over basic game making. It goes from video #61 to about #80.
Android Tutorial #61
These videos can help you draw a basic image or make a simple game if that's what your looking for. Though I recommend you go learn as much of the basics as you can before going into anything really complicated.
Don't overextend yourself with something to difficult to begin with because it migh leave your frustrated with the entire android concept.
Hope this helps.
u can add images/picture in the res/drawables
http://developer.android.com/guide/topics/graphics/2d-graphics.html
Also different devices use different resolutions
http://developer.android.com/guide/practices/screens_support.html
use a ImageView widget to display the image
image = (ImageView) findViewById(R.id.imageView1);
image.setImageResource(R.drawable.android);
this is assuming you have a file name android.png|jpg|gif etc in your drawable folder. If you want to use a image that is selected at runtime check here. How to set the image from drawable dynamically in android?
I'm looking for a function that could process animated gif image to write text on top of it.
The working solution is probably provided by Gif4j lib, but I'm looking for open-source solution or advice how to implement it on my own.
How can I put text on a gif and save it as a new gif in Java?
You need to:
Split the animation into separate frames.
Write the text on each frame. For examples see answers like these (the first is more closely related, but the second source does the same, and is simpler).
Java Text on Image
How to resize text 1
Construct the frames into a new animated GIF. See Create animated GIF using imageio at the OTN, where I discuss the code used in a GIF animation tool.
Best reader,
I'm stuck on one of my concepts.
I'm making a program which classroom children can measure themselves with.
This is what the program includes;
- 1 webcam (only used for a simple webcam view.)
- 2 phidgets (don't mind these.)
So, this was my plan. I'll draw a rectangle on the webcamview and make it repaint itself constantly.
When the repainting is stopped by one of the phidgets, the rectangle's value will be returned in centimeters or meters.
I've already written the code of the rectangle that's repainting itself and this was my result:
(It's a roundRectangle, the lines are kind of hard to see in this image, sorry about that.)
As you can see, the background is now simply black.
I want to set the background of this JFrame as a webcam view (if possible) and then draw the
rectangle over the webcam view instead of the black background.
I've already looked into jmf, fmj and such but am getting errors even after checking my webcam path and adding the needed jar libraries. So I want to try other options.
So;
- I simply want to open my webcam, use it as background (yes live stream, if possible in some way).
And then draw this rectangle over it.
I'm thus wondering if this is possible, or if there's other options for me to achieve this.
Hope you understand my situation, and please ask if anything's unclear.
EDIT:
I got my camera to open now trough java. The running camera is of type "Process".
This is where I got the code for my camera to open: http://www.linglom.com/2007/06/06/how-to-run-command-line-or-execute-external-application-from-java/
I adjusted mine a little so it'll open my camera instead.
But now I'm wondering; is it possible to set a process as background of a JFrame?
Or can I somehow add the process to a JPanel and then add it to a JFrame?
I've tried several things without any succes.
My program as it is now, when I run it, opens the measuring frame and the camera view seperatly.
But the goal is to fuse them and make the repainting-rectangle paint over the camera view.
Help much appreciated!
I don't think it's a matter of setting a webcam stream as the background for your interface. More likely, you need to create a media player component, add it to your GUI, and then overlay your rectangles on top of that component.
As you probably know from searching for Java webcam solutions in Stack Overflow already, it's not easy, but hopefully the JMF Specs and API Guide will help you through it. The API guide is a PDF and has sections on receiving media streams, as well as sample code.