[Android] get all recent photos in gallery and display them as thumbnails
Hello there, I'm trying to create an app (not a game) similar to Instagram's Layout (https://play.google.com/store/apps/details?id=com.instagram.layout), it's kind of a clone exercise that I'm trying to accomplish.
So.. The problem I have right now is that I load the images in their entirety and then rescale them to fit a 200x200 sprite. As it was expected that crashes the app if I’m trying to load more than 5 images or something like that.
The way that i load the images is: 1) I get all the paths for all the images in the phone and i store them into a List of strings. 2) Then I use this code to load the image to a sprite and then put that sprite's (newly instantiated) gameobject into a scroll contain This code looks like that:
List<string> galleryImages = GetAllGalleryImagePaths();
int counter = 0;
foreach (string pth in galleryImages) {
if (counter >= 5) {
break;
}
Texture2D t = new Texture2D (100, 100);
WWW tex = new WWW(pth);
t = tex.texture;
TextureScale.Bilinear (t, 100, 100);
GameObject img = Instantiate (ImagePrefab);
img.transform.SetParent (ImageScrollContent);
img.GetComponent<Image>().sprite = Sprite.Create(t, new Rect (0, 0, 100, 100), new Vector2 (0, 0));
counter++;
}
So as you can understand this crashes the app every time I try to load even 10 images and up!!
Do you know of any ways to load just a thumbnail of an image and not a full one?
Thanks in advance
Your answer
Follow this Question
Related Questions
Android app load delay after quitting application 0 Answers
reading apps 1 Answer
performance 2D in apps,performance in apps 0 Answers
How to make auto play and off sound when target object is found and dissapear? 0 Answers
Android vs iOS build capacity 0 Answers