Load the images from the Gallery into gridview - android

This LazyLoading library helps me to load the images from the internet. Can i use this library to load the images from the gallery.
imageLoader.DisplayImage(url, image);
What should i send the argurment to display the image from the gallery
Note I'm having the path of the images in the ArrayList
Imp Note : I'm also having the ArrayList of byteArray (one byte array resembles to one image). So then how can i use the library
Edit I encrypted some images from the gallery and stored in SDCard and i need to display the encrypted images in my app(I know the path of the encrypted images) Encryption is done in Byte[] level.
Please suggest me. ThankYou

Can i use this library to load the images from the gallery?
Gallery itself a application which is showing images from your local folder. So if you have a local image you can show it by its path in your App.
You just need to add file in your image path to make path as URI.
Like
String URL = "file:///mnt/sdcard/image.png"; // from SD card

Related

How to save image file directly to image gallery in android

Is there any good way to save image into gallary using File object?
I want to do like this
File file = new File("path to image gallery","empty.jpg");
Picasso.with(context).load("http://i.imgur.com/DvpvklR.png").save(file);
I believe JakeWharton meant that ??
picasso issue

How to load image from SD card using Picasso library

i need to load images from the Sd card into gridview.
For efficiency i'm using Picasso Library
Picasso.with(activity).load(images.get(position).getDataPath())
.resize(96, 96).centerCrop().into(viewHolder.image);
I used the following code in the adapter. unfortunately m unable to see any images
so please can any one help.
Note
And also can anyone suggest any efficient image loading library to load the images from the sd card.
Requirement
I dont to load the image every time when scrolling. If it is already loaded dont load the image on scrolling
To load the file you need to convert it to a uri first
Uri uri = Uri.fromFile(new File(images.get(position).getDataPath()));
Picasso.with(activity).load(uri)
.resize(96, 96).centerCrop().into(viewHolder.image);
Requirement I dont to load the image every time when scrolling. If it
is already loaded dont load the image on scrolling
Picasso is excellent for this
In Picasso version 2.5.2, you need to pass a File as argument to load method, so the image can be loaded as:
Picasso.with(context).load(new File(images.get(position).getDataPath()))
.resize(96, 96).centerCrop().into(viewHolder.image);
I didn't want to create a new File because if the path was already obtained from an existing file, there is no need for a new object (want to see the already existing picture in the device).
According to Picasso docs you have to do something like this:
file:///android_asset/DvpvklR.png
So I used to have:
/storage/sdcard/Pictures/findyoursport/yoursport_1482358052384.jpeg
Prepending: file:// did the trick

how to attach image from assets folder loaded in gallery view to email android?

i'm new to android.
I have some images in assets folder.I know/and have already loaded them in a gallery view.
So my problem is :
when I open gallery,my images from assets folder gets loaded in gallery view.But when to send it through email.It doesn't gets attached to email.I want them to get attached to email (one at a time) without saving them to Sd card.
can anyone help me with my problem?
Not sure if this will work with assets, but use flag Intent.FLAG_GRANT_READ_URI_PERMISSION while launching the Email app.

Save image to sdcard from imageview

I have listview having customized some textview and one imageview. When I long click on item I have store that item information to the database but the question is how to store image in sdcard and store the relevant path to the database. The image alread download as cache now I don't want to re-download that image.
Is there way to store that Image to the sdcard.
I am using this example to download the images for listview https://github.com/thest1/LazyList
Edit
I got solution
no need to extra process when using this example. Just store the web path of image into the database and pass that imageview into the ImageLoader object with path it'll use the cache images if the image was exist for same URL
No Need to extra process, Using this example it'll will care for future usage also for same URL of image. This will get from the cache directory if the image found that use that image otherwise download it and then use it.
If you use Prime the caching will be transparent, when you request the image again it will grab it from a memory cache if available or a disk cache automatically. It also is really easy to get images with.
You can save your bitmap which you get via Bitmap bitmap=memoryCache.get(url); using save-file-to-sd-card.
You can also get the bitmap from the ImageView(if you want) like:
//say your ImageView object is i;
i = (ImageView) findViewById(R.id.img);
Drawable d = i.getBackground();
Bitmap bitmap = ((BitmapDrawable)d).getBitmap();

Adding Images to Drawable Folder from a Server

I need to add images into res/drawable folder dynamically as the user select images of his choice from a server...then store the corresponding R.drawable.imageid to Database..so as to load the user chosen images on the next run...Is there no way to do so...?
int[] images = {
R.drawable.m1,R.drawable.m2, R.drawable.m3,
R.drawable.m4,R.drawable.m5, R.drawable.m6,
R.drawable.m7, R.drawable.m8,
R.drawable.m9
};
ImageView iv = (ImageView)findViewById(imageViews[next]);
iv.setImageResource(images[j]);
Here R.drawable.m1, R.drawable.m2, R.drawable.m3, R.drawable.m4, R.drawable.m5, R.drawable.m6, R.drawable.m7, R.drawable.m8, R.drawable.m9 should be ids of images chosen by user from the server
Quoting Android Engineer RomainGuy
You cannot write to res/drawable.
However you can look for other alternatives like external storage.
Links to consider are
android image save to res/drawable folder
How to convert a Drawable to a Bitmap?
Android: Image save to location
u cannot copy the images in drawable folder.
create folder in data folder and write images there and use bitmap class to map the image.

Categories

Resources