Android supports three image formats with this rating:
PNG (preferred), JPG (acceptable) and GIF (discouraged). Source: http://developer.android.com/guide/topics/resources/drawable-resource.html#Bitmap
Why is JPG only listed as acceptable? Isn't JPG a better format for images without transparency because they take less space than PNG:s?
Or does PNG behave so much better during runtime that it is worth storing full screen background images etc. as PNG:s even if they tend to make the APK much bigger?
I'm not very satisfied with many apps containing a lot of graphics eating the space on my Internal storage so it's getting full all the time. And my guess is that they are badly optimized in that sense by using PNG when they could use JPG because the developer guide says PNG is preferred without explaining why. Can anyone tell if I'm correct when saying JPG should be used for non-transparent images?
About image formats. Android apps typically use images that are in one or more of the following file formats: AVIF, PNG, JPG, and WebP.
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.
JPG format is a lossy compressed file format. This makes it useful for storing photographs at a smaller size than a BMP. JPG is a common choice for use on the Web because it is compressed.
Because of their different compression processes, JPEGs contain less data than PNGs — and therefore, are usually smaller in size. Unlike JPEGs, PNGs support transparent backgrounds, making them preferred for graphic design.
This article
http://mobile.tutsplus.com/tutorials/mobile-design-tutorials/mobile-design_png-or-jpg/
is more focused on iOS development, but it seems to agree with what you suspected about JPGs being fine for non-transparent images. PNGs are lossless, so they have that advantage, which is probably why they are recommended, but if you can live with some loss in exchange for size optimization, then JPGs seem fine to me.
PNGs are lossless while JPEGs are lossy. I would expect PNGs to scale slightly better, but if you can live with the JPEG quality it seems appropriate/acceptable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With