Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
New Developer
swillia29
Posts: 13
Registered: ‎11-13-2013
My Device: Q10
Accepted Solution

Get file thumbnail for ListView

Is there a way to get the thumbnail image of a picture? I have a listview showing a list of selected pictures and I want to display the thumbnail along with the name of the file. Here is what I have so far

 

I let the user select a picture thru the file picker which only returns the file path I then pass that path into the a method to add it to the datamodel.

 

CPP file: I pass in the file path to the picture that was selected

            QVariantMap itemMap;
	    QFileInfo fileInfo = QFileInfo(filePath);
	    itemMap["name"] = QVariant(fileInfo.fileName());
	    itemMap["image"] = QVariant(fileInfo.filePath());

	    if (indexOf(itemMap) == -1)
	    {
	           insert(0, itemMap);
	     }
  

 ListItem QML

 

StandardListItem
{
    id:pictureItem
    title: ListItemData.name
    imageSpaceReserved: true
    imagesource: ListItemData.image
    
}

 

I'm fairly new to this so I have a really strong feeling I'm going about this the wrong way but I notice I get an error message saying it cannot access item in <file path> . My thinking was that the image space would shrink the image to fit in the reserved space

Developer
BBSJdev
Posts: 6,116
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30

Re: Get file thumbnail for ListView

For the error do you have the access_shared permission set? 

 

I would suggest you should be creating thumbnails of the images, saving them in the apps data folder and updating the ListItem image.

If you experience a lag when populating the ListView then you should think about preloading some images and caching.


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
New Developer
swillia29
Posts: 13
Registered: ‎11-13-2013
My Device: Q10

Re: Get file thumbnail for ListView

No I do not have acess to share permissions set, I will do that,

 

Creating and saving the thumbnail images will be time consuming no? I allow them to select multiple photos at once, unless the method that creates the thumbnails and save them in the appdata folder runs in the background

Developer
slashkyle
Posts: 820
Registered: ‎10-16-2012
My Device: Red Z10

Re: Get file thumbnail for ListView

[ Edited ]

this is a very in depth example of how to do this, just download and run the program and you'll notice the excellent performance

 

http://supportforums.blackberry.com/t5/Native-Development/Wappy-a-complete-free-and-open-source-BB10...

New Developer
swillia29
Posts: 13
Registered: ‎11-13-2013
My Device: Q10

Re: Get file thumbnail for ListView

[ Edited ]

That looks like that would work  thanks to both of you guys!

Developer
BBSJdev
Posts: 6,116
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30

Re: Get file thumbnail for ListView

Yes, I meant asynchronously (in the background) forgot that part in the actual response.

 

Best of luck.

 


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.