How to use BufferedImage in android for apache.common.imaging - java

i am using a method from the apache.common.imaging in which the BufferedImage is used, i know that BufferedImage is not part of the android classes since awt package is not available but i need bufferedimage for that method any ways to achieve this?
The method is as follows:
JpegImageParser parser= Imaging.getBufferedImage(sourceFile);
you can find the source of the library here is there a way to port that project or any workaround to get this method working?

Android has other libraries that provide this functionality. In particular, Picaso is quite popular and easy to use.

Related

using FFmpeg for android without any C/C++ or make knowledge

I would like to use FFmpeg library on my android app.
I have no C/C++/Make knowledge and all the threads I've been reading about it talk about stuff I completely don't understand.
Is there any pre-compiled library which I can add to my project, then add a simple 'import' statement on my java class and then call it?
Thanks
Is there any particular reason why you need exactly FFmpeg? I guess it could be possible to get prebuilt binaries, but since it is a C library, you would also need a JNI wrapper code - I don't think anyone would generate that for the whole library since it's quite large, so even with a prebuilt library you still need to have some JNI knowledge to wire through the communication between Java and FFmpeg in C. Just for the purpose of demonstration - here is an example.
Apart from that if there is not a special reason to use FFmpeg, why can't you stick with MediaCodec that is a part of the Android API? It wraps the native StageFright library and could provide hardware support on devices where it is available, while FFmpeg would be a CPU only solution. Of course, if some unpopular codecs or muxers that are not available in MediaCodec are needed, then FFmpeg is the way.
You can use Xuggler for encoding and decoding audio and video. Their wesite says "Xuggler extensively uses FFmpeg to compress and uncompress media".
You could use precompiled libs from the JavaCPP Presets along with FFmpegFrameRecorder from JavaCV to compress images as well as audio samples, as shown in the RecordActivity sample, for example.

Is it possible to determine the type of png compression on Android bitmaps?

I know there are different types of png compression formats (using color palette for example). Is it possible to (programatically) determine the type I want to use when compressing a Bitmap in Android?
If the answer is no, can anyone suggest a method for doing so?
Thanks
In Android there's no client API to specify that, because Bitmap.compress() calls a native method which doesn't accept such a parameter.
However you can use libpng (which BTW is what I think Android uses in its native implementation) and it certainly allows the fine-grained control you need.
But I really don't think that saving a bunch of KBytes in a GB-sized drive is worth this effort.
You can also use PNGJ, it allows full control over the writing parameters.
Eventually I had to make changes to the Android's skia library, since I didn't want to add any Java code (I need to make png compressions fast).
If anyone needs such a solution,
I uploaded mine to:
https://github.com/androidcompile/Android_external_skia_pngCompression

Is there a java library for image?

I am new to image processing in java .
I was given a task to re-size and scale images image of a web site
Is there a simple Library that will do this task?
a library where i have to download a jar - added to my project ?
I prefer not to be forced to install codecs and files to the windows.
I need the library to support only the basic functions
Lib.cropImage();
Lib.resizImage();
Lib.scaleImage()
I already found a library called JAI but I can't find the jar to download it.
Am I missing something ?
You can use the standard Image class part of Java libraries.
Scaling images should be fairly easy by using Image.getScaledInstance(int width, int height, int hints)
For cropping, use BufferedImage.getSubimage() (see this StackOverflow Q&A for more details). For resizing, use Graphics.drawImage() (see this StackOverflow answer for more details). And for scaling, use Image.getScaledInstance().
Other options are:
JMagick (see this StackOverflow answer).
ImageJ
Use ProcessBuilder to execute ImageMagick commands.
The Java2D library ought to be sufficient enough.
For image processing puroses I would recommend a package from the following list.
In your case JAI would do the job, and you can download it here.
Have you tried imageJ which boasts to be world's fastest pure Java image processing program

Image Processing on Java

I'm working on a college project, where I need to handle images in java. Sometime ago I worked in math lab and it was so easy, so I would like to know if exits any java library that could let me play with the pixels values, color(by pixel), RGB model, gray-scale img, etc.
I don't know matlab, but I worked with Java image processing a lot... Java standard library provides tons of methods to work with images on low level. You can access image pixels through BufferedImage. Make sure to read and understand the classes BufferedImageOp, RasterOp and ConvolveOp otherwise you may end up reinventing stuff.
The best examples for java image processing are on http://www.jhlabs.com/ There you can also find open source image editor and the source code for all the image effect demos.
Look at BufferedImages. You can load/save/edit images with it
http://download.oracle.com/javase/6/docs/api/java/awt/image/BufferedImage.html
http://download.oracle.com/javase/tutorial/2d/images/index.html
You might want to take a look at the following classes:
java.awt.image.BufferedImage
java.awt.image.Raster
javax.imageio.ImageIO
Depending on the image formats you might also have to look (I hope not) at JAI and JAI-imageio.
Well, there is a library available in Java which can help to access Matlab code with in Java program. Please check http://code.google.com/p/matlabcontrol/
I tend to use DataBuffer objects for this kind of stuff. It's not very fast, but if you want to get out pixel information easily, it's the easiest way to do it. It's stored in the Raster of the BufferedImage.

Loading an image in Java without AWT

I am on an embedded platform without access to AWT. I was wondering if anyone knew of a standalone library to load images without any AWT involvement.
Thanks,
Braden McDorman
Perhaps AWT headless mode can help?
http://java.sun.com/developer/technicalArticles/J2SE/Desktop/headless/
I took the semi-easy way out and created a tool to convert images to RGB565 raw files. Then I have a custom loader.
Have a look at JIMI.
http://java.sun.com/products/jimi/
Easy to work with, bought by Sun, superceeded by JAI which is not as easy to work with.
(And now the page is Oracle-branded...)
Not a standalone library and not sure what your platform offers, but you can try the javax.imageio.ImageIO (Java SE 1.4 and later).
Just use one of the read methods to get a BufferedImage.

Categories

Resources