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
Related
I need a bitmap to work with and I am provided an URI that is shared from another apps implicit intent. I currently work with
Bitmap btmp = MediaStore.Images.Media.getBitmap(getActivity().getContentResolver(), urinormal);
but it takes up to half a second to create the bitmap. I need it to work as fast as possible, what can I do?
I can't find a way to reduce the quality of the bitmap, I can only apply BitmapFactory.options afterwards to create a smaller bitmap, but that doesn't help.
There can be many reasons why image loads slow. Slow connection, large file etc.
I would suggest you to use Glide, an image loading library for android.
GlideApp
.with(ctx)
.load(url)
.centerCrop()
.placeholder(R.drawable.loading_spinner)
.into(myImageView);
This will show a custom loading image until the image is loaded.
You will have to use Generated API of Glide to have GlideApp class though. Read the docs, there are many other cool features.
Hope it helps.
Probably the file size is too large. If it is large it takes the required time. You can do nothing about it.
If it takes around half seconds, you may want to perform the decoding using AsyncTask so that the UI won't freeze.
As you mentioned that you are developing a gallery type app. You may want to store the thumbnail of the bitmaps in the storage when loading them the first time. So next time your app can quickly decode the image from the thumbnail file. When you click on the image, you can load full size image from the original location.
As #faztp12 mentioned in his answer, you may also use some third party image loading libraries like Picasso or Glide to achieve the similar functionality.
I have a big set of images saved in one atlas, but due to the 2048*2048 size limitation of a single page I had to split my packs in 12 pages.
My problem is that when I use atlas.findRegion(imageName).getTexture() to load the texture, it loads the whole 2048*2048 page and not the single texture inside the page (the image pack contains the correct image though, so I know it's loading the correct file, I just don't understand why it's not cropping the texture around the image I pass as parameter to findRegion).
Thanks in advance, hope the question is detailed enough to receive an answer.
The problem was actually calling the getTexture() method, I just needed to load the Region. More info here loading regions of textureatlas in libgdx loads the entire file
I have image saved in phone memory. I need to get some part of the entire image in desired resolution. I could possibly first downscale the entire image and then "decodeRegion" from it. Is there any way to "decodeDownScaledRegion" in one go rather than first downscaling original image and decoding region from it?
Maybe you could follow the document "Loading Large Bitmaps Efficiently" here:
http://developer.android.com/training/displaying-bitmaps/load-bitmap.html
I know I need to use different DPI for images and all graphics stuff, but I just don't understand if I have to create the different drawable folders by myself or if there's a proper way to do it, and plus, what to use them for.
For instance I need to add a wallpaper, where should I put it? And of what resolutions? What are the pixels needed for each?
Tried to read the Google page about this, but didn't get much, thank you!
I have to create the different drawable folders by myself or if
there's a proper way to do it?
Assuming you're using Android Studio:
what to use them for.
from http://developer.android.com/guide/practices/screens_support.html:
xlarge screens are at least 960dp x 720dp
large screens are at least 640dp x 480dp
normal screens are at least 470dp x 320dp
small screens are at least 426dp x 320dp
In that page you have documentation for screen sizes and densities.
Basically, when you put, let's say, an image in an activity, it will render according to the device's density corresponding folder.
a wallpaper, where should I put it?
The best is to have an image for each density, but if you don't have those provided, you can put it in the drawable folder, without any density qualifier, which means that your resource is the same for every screen density.
For a quick way of knowing your device screen stats, download ScreenInfo.
"...I just don't understand if I have to create the different drawable
folders by myself"
no, you don't have to, but you can.
"... if there's a proper way to do it"
If you right click on res then select new then select Image Asset, Android Studio has an Image Asset tool that guides you through the whole process. This is how you import various UI elements in their correct dpi and densities.
"... what to use them for"
This is upto you. But if you set an ImageButton to an drawable with various drawable resources for different screen dpi, the correct dpi drawable will be chosen according to the device's screen dpi when the app is running.
"wallpaper..?"
Put that in drawable-nodpi or just the regular drawable
I want to be able to take a snapshot of a preview camera screen being displayed on a SurfaceView. I know it has something to do with the onPreviewFrame() method and this returns a byte array in YUV format but I have no idea how to call the onPreviewFrame() method on it's own.
I have used it in conjunction with Camera.setPreviewCallback() but this is a continuous thing that keeps generating the image, I need it to do it once on an onClick(), to pretty much take a photo without making the preview window stop. Any ideas?
For anybody else with a similar problem to this I solved it by using the setOneShotPreviewCallback() method on the camera object to give me a byte[] with the information for the image. with that its can be used to create a YUV and then compressed to bitmap or whatever you need.
Capture the preview image into a canvas and hold a lock to it. You can then easily save to a BitMap
Refer this post for complete explanation with sample code
http://www.anddev.org/using_camerapreview_to_save_a_picture_on_disk-t226.html