HI,
I am currently studying how Android decode and image file. When I checked the code, it seems like it is calling the SKIA library. But, how do I know what are the image file format supported by android/skia basing on the source code?
I am not an expert in programming, so I am still trying to understand C++ and Java language.
I am now lost at SkImageDecoder* decoder = SkImageDecoder::Factory(stream); inside the BitmapFactory.cpp (JNI file). SkImageDecoder::Factory(stream) seems to be a template.
Anyone can explain me what is happening inside SKImageDecoder::Factory()? Any feedback will be greatly appreciated.
Thanks,
artsylar
In skia/include/images/SkImageDecoder.h file, there is the image list decoding supported by Skia:
enum Format {
kUnknown_Format,
kBMP_Format,
kGIF_Format,
kICO_Format,
kJPEG_Format,
kPNG_Format,
kWBMP_Format,
kWEBP_Format,
kLastKnownFormat = kWEBP_Format
};
In SkImageDecoder::Factory(stream) function, it will new a decoder instance according to analyze the Stream's header.
By looking at the source codes of Android, I think the following image formats are supported.
ICO (Windows ICON image format), BMP, JPEG, WBMP, GIF, and PNG.
Please correct me if I am wrong. Thank you.
PNG, JPEG, and GIF are the supported formats. The primary formats used on Android are PNG and JPEG.
Related
I want to use google's API for displaying panoramas. Apparently I need for input a jpg with the panorama, in which I embed the metadata in XMP format. How can this be done? is it my job as a developer or the one's who creates the panorama? can this be done with a tool? ie photoshop?
Ok this is how I did it, I used photoshop which has an option to pass metadata from a custom template so I created an XMP file using the metadata mentioned in google documentation page. Hope it helps anyone who finds this post!
<?xpacket begin='' id=''?><x:xmpmeta xmlns:x='adobe:ns:meta/'>
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
<rdf:Description rdf:about="" xmlns:GPano="http://ns.google.com/photos/1.0/panorama/">
<GPano:UsePanoramaViewer>True</GPano:UsePanoramaViewer>
<GPano:CaptureSoftware>Photo Sphere</GPano:CaptureSoftware>
<GPano:StitchingSoftware>Photo Sphere</GPano:StitchingSoftware>
<GPano:ProjectionType>equirectangular</GPano:ProjectionType>
<GPano:PoseHeadingDegrees>350.0</GPano:PoseHeadingDegrees>
<GPano:InitialViewHeadingDegrees>90.0</GPano:InitialViewHeadingDegrees>
<GPano:InitialViewPitchDegrees>0.0</GPano:InitialViewPitchDegrees>
<GPano:InitialViewRollDegrees>0.0</GPano:InitialViewRollDegrees>
<GPano:InitialHorizontalFOVDegrees>75.0</GPano:InitialHorizontalFOVDegrees>
<GPano:CroppedAreaLeftPixels>0</GPano:CroppedAreaLeftPixels>
<GPano:CroppedAreaTopPixels>0</GPano:CroppedAreaTopPixels>
<GPano:CroppedAreaImageWidthPixels>4000</GPano:CroppedAreaImageWidthPixels>
<GPano:CroppedAreaImageHeightPixels>2000</GPano:CroppedAreaImageHeightPixels>
<GPano:FullPanoWidthPixels>4000</GPano:FullPanoWidthPixels>
<GPano:FullPanoHeightPixels>2000</GPano:FullPanoHeightPixels>
<GPano:FirstPhotoDate>2012-11-07T21:03:13.465Z</GPano:FirstPhotoDate>
<GPano:LastPhotoDate>2012-11-07T21:04:10.897Z</GPano:LastPhotoDate>
<GPano:SourcePhotosCount>50</GPano:SourcePhotosCount>
<GPano:ExposureLockUsed>False</GPano:ExposureLockUsed>
</rdf:Description>
</rdf:RDF>
I know it is possible to save bitmap to png or jpg
now i want to save bitmap to .tiff,anybody can help?
Android does not have native support for saving TIFF files.
You best bet would be to get the raw byte array, and then using either a Java or NDK library (like libtiff) to save it as a TIFF.
I believe this is is a repost from here:
Convert a bitmap image to an uncompressed tif image in Java
To answer the question, the above answer suggested the following using the Java Advanced Imaging (JAI) library:
TIFFImageWriterSpi spi = new TIFFImageWriterSpi();
ImageWriter writer = spi.createWriterInstance();
ImageWriteParam param = writer.getDefaultWriteParam();
param.setCompressionMode(ImageWriteParam.MODE_DISABLED);
ImageOutputStream ios = ImageIO.createImageOutputStream(new File("output.tif"));
writer.setOutput(ios);
writer.write(null, new IIOImage(bmp, null, null), param);
You always can save the Bitmap as .png and convert it to .tiff
Android hasn't support for tiff images. You should use some library for working with tiff. For example my: https://github.com/Beyka/Android-TiffBitmapFactory
Background
We have just swapped to the UIL library, which seems fantastic. Unfortunately we have to support CMYK images (against our will) and have attempted to modify an existing ImageDecoder called BaseImageDecoder.
The code for this can be found here. http://pastebin.com/NqbSr0w3
We had an existing AsyncTask http://pastebin.com/5aq6QrRd that used an ImageMagick wrapper described in this SO post (Convert Image byte[] from CMYK to RGB?). This worked fine before in our setup.
The Problem
The current decoder fails to load the cached image from the file system and this results in a decoding error. We have looked through the source code and believe we are using the right functions. We also thought that adding our extra level of decoding at this point in the process was ideal, as the image may have been resized and stored on the file system.
File cachedImageFile = ImageLoader.getInstance().getDiscCache().get(decodingInfo.getImageUri());
if (!cachedImageFile.exists()) {
Log.v("App", "FILE DOES NOT EXIST");
return null;
}
The above lines always return that the file does not exist.
The Question
Are we incorrect to process our CMYK images at this point, and if not why can't we get the image from the cache on file system?
I need a (really fast) way to check if a JPG file is in RGB format (or any other format that Android can show).
Actually, at this moment, I just know if a JPG file can be show when I try to convert it to Bitmap using BitmapFactory.
I think this should not be the fastest way. So I try to get it by using ExifInterface. Unfortunately, ExifInterface (from Android) does not have any tag that indicates that the jpg can be shown in Android (color space tag or something).
Then, I think I have 2 ways:
1) A fast way to get bitmap from jpg: any tip of how to do it?
2) Or try to read Exif tags by my self, but without adding any other lib to the project: I don't have any idea of how to do it!
Ok so I did some looking around and I may have a solution for you but it may require a little work. The link is a pure java library that I think you can use in your project or at least modify and include a few classes. I have not worked with this yet but it looks like it will work.
http://commons.apache.org/proper/commons-imaging
final ImageInfo imageInfo = Imaging.getImageInfo(File file);
if(imageInfo.getColorType() == ImageInfo.COLOR_TYPE_CMYK){
}
else {
}
I am developing an app in which I need the image in TIFF format. But in android you can convert your bitmap/image to only JPEG/PNG image.
Is there a good way to convert JPEG/PNG file to TIFF format on android?
Android Do Not Support java.awt.image.*
check this.
http://developer.android.com/reference/packages.html
I'm not sure that Android SDK supports Java Image I/O, but check out following question: Java API to convert JPEG to TIFF
Android does not support TIFF files.
You can get the Bitmap's raw pixel data array and convert it to TIFF manually using any of the links from the previous comment.
If you are willing to add some C++ to your project via the Android NDK, then libtiff should do what you want.
I've recently found this great library on Github by Beyka (which uses libtiff and others natively) that provides many utilities for handling, opening, and writing .tiff files.
An example of converting JPEG to TIFF:
TiffConverter.ConverterOptions options = new TiffConverter.ConverterOptions();
//Set to true if you want use java exception mechanism
options.throwExceptions = false;
//Available 128Mb for work
options.availableMemory = 128 * 1024 * 1024;
//compression scheme for tiff
options.compressionScheme = CompressionScheme.LZW;
//If true will create one more tiff directory, else file will be overwritten
options.appendTiff = false;
TiffConverter.convertToTiff("in.jpg", "out.tif", options, progressListener);