Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Which image format shall I use and why? [closed]

Im a beginner programmer, and my question is: Which image format shall i use for my android app?

Descripton: I only use illustrations, so the images are mostly background images, and some buttons, and i would like to know which is the best way to do this.

My current progress for images are the next: I use .png file format. I dont know what resolution should I use, now I work with 300x400 px images aproximetly.

Here is my code for using the images:

Bitmap bMap = BitmapFactory.decodeResource(getResources(), MyArray[index].getArtiD());

MyImageView.setImageBitmap(bMap);

So this is the way I use images in Android, pls guys if anyone know issues, tips or a "must know information" to tell pls do it. I dont really understand why should I use this bitmap factory or why should i use png format. I want to do it in the best way I can, and I dont see many things in android documentation.

Thanks, Adam

like image 466
Adam Varhegyi Avatar asked Nov 08 '11 08:11

Adam Varhegyi


People also ask

What is the recommended image format in android?

Android 12 (API level 31) and higher support images that use the AV1 Image File Format (AVIF). AVIF is a container format for images and sequences of images encoded using AV1. AVIF takes advantage of the intra-frame encoded content from video compression.

What is the best image file format and why?

TIFF stands for Tagged Image File Format, and it is known as the most used file format by photographers and designers. Images stored as TIFF files are best for post-processing, because they are not compressed at all. With TIFF files, you can create all kinds of digital images.

Which image format is best for mobile?

My Personal opinion is in android the best format of Image is PNG as it light compare to JPG,JPEG etc.So its easy to draw and take less time to perform the operation while using these images. Save this answer.

Which image format is best choice?

JPEG – Joint Photographic Experts Group JPG format is the standard file format of digital cameras and is the most common image format used on the web because of its compression and universal support. These files are best used for saving photographs with small file sizes and little noticeable quality loss.


2 Answers

Note that: "img.setImageResource(...)" still calls the bitmap routines, potentially on UI thread: http://developer.android.com/reference/android/widget/ImageView.html#setImageResource%28int%29

That may cause undesirable UI-lags, so you might want to deal with the BitmapFactory yourself, in a seperate thread, as discussed here: http://developer.android.com/training/displaying-bitmaps/index.html

As to the original question, PNG comes is many forms (see: 'PNG color options' and 'PNG color types' on the PNG Wiki page) -- Is there a favoured PNG format for Android?

like image 138
William Ellis Avatar answered Nov 15 '22 22:11

William Ellis


In android the best format of Image is PNG as it light compare to JPG,JPEG etc.So its easy to draw and take less time to perform the operation while using these images.

And For bitmap Go through this Bitmap Help

Edited Yes no need to use Bitmap ,if you have images in resource.If your images are in Drawable then use

ImageView img=new ImageView(this);
//You can use like that without using Bitmap
img.setImageResource(R.drawable.arrow_s);
like image 37
Tofeeq Ahmad Avatar answered Nov 15 '22 21:11

Tofeeq Ahmad