Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Nebula » Gallery image loading question
Gallery image loading question [message #61252] Fri, 12 December 2008 09:23 Go to next message
Eclipse UserFriend
Originally posted by: user.domain.invalid

Hello everyone,

We are currently developping a cataloging system, and we are using the
GalleryViewer.

We are loading a lot of image from the internet so I was wondering if
there was any way I could load the image lazily?
For example when loading a bunch of images into the gallery, i would
like to display first a default image and the tittle of the image. And
then in a thread fetch the image from the internet and replace the
default image with the correct one for each gallery item.

Thank you very much,

Baptiste
Re: Gallery image loading question [message #61277 is a reply to message #61252] Fri, 12 December 2008 10:13 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

Well I implemented such a feature for Nebula-Grid (the current
header_footer branch holds this stuff) besides loading images lazily you
also need to dispose them when the image is scrolled out of view else
you'll eating up your resource handles.

The feature I added to grid is that you can subscribed to the grid and
you get informed about the currently showing cells in the view:

a) when a cell is scrolled into view you can set an placeholder and span
a background-thread fetching the image restoring it in a temp dir and
replace the placeholder

b) when a cell is scrolled out of view you can set dipose the resource
and set the image back to the placeholder and next time

c) when the cell is once more scrolled into view check you local-disk
cache if the image is there load and return it else a)

I don't know if Gallery has such a feature but if not it would maybe
make sense to work together on a common API both widgets provide to
their users.

Tom

user@domain.invalid schrieb:
> Hello everyone,
>
> We are currently developping a cataloging system, and we are using the
> GalleryViewer.
>
> We are loading a lot of image from the internet so I was wondering if
> there was any way I could load the image lazily?
> For example when loading a bunch of images into the gallery, i would
> like to display first a default image and the tittle of the image. And
> then in a thread fetch the image from the internet and replace the
> default image with the correct one for each gallery item.
>
> Thank you very much,
>
> Baptiste


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: Gallery image loading question [message #61301 is a reply to message #61277] Sat, 13 December 2008 11:26 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: user.domain.invalid

Hi Tom,

Thank you for your answer,

I don't find any feature like that in Gallery. It would be great to have
like a commons api.
Could you point me where this feature is implementated in the nebula
grid? As I went through the grid code from the header_footer but I
couldnd manage to find it.
So I could have a look at it and try to integrate that in gallery.

Thank you

Baptiste



Tom Schindl wrote:
> Hi,
>
> Well I implemented such a feature for Nebula-Grid (the current
> header_footer branch holds this stuff) besides loading images lazily you
> also need to dispose them when the image is scrolled out of view else
> you'll eating up your resource handles.
>
> The feature I added to grid is that you can subscribed to the grid and
> you get informed about the currently showing cells in the view:
>
> a) when a cell is scrolled into view you can set an placeholder and span
> a background-thread fetching the image restoring it in a temp dir and
> replace the placeholder
>
> b) when a cell is scrolled out of view you can set dipose the resource
> and set the image back to the placeholder and next time
>
> c) when the cell is once more scrolled into view check you local-disk
> cache if the image is there load and return it else a)
>
> I don't know if Gallery has such a feature but if not it would maybe
> make sense to work together on a common API both widgets provide to
> their users.
>
> Tom
>
> user@domain.invalid schrieb:
>> Hello everyone,
>>
>> We are currently developping a cataloging system, and we are using the
>> GalleryViewer.
>>
>> We are loading a lot of image from the internet so I was wondering if
>> there was any way I could load the image lazily?
>> For example when loading a bunch of images into the gallery, i would
>> like to display first a default image and the tittle of the image. And
>> then in a thread fetch the image from the internet and replace the
>> default image with the correct one for each gallery item.
>>
>> Thank you very much,
>>
>> Baptiste
>
>
Re: Gallery image loading question [message #61325 is a reply to message #61301] Sat, 13 December 2008 14:34 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

It is the GridVisibleRangeSupport which you are looking for.

Tom

user@domain.invalid schrieb:
> Hi Tom,
>
> Thank you for your answer,
>
> I don't find any feature like that in Gallery. It would be great to have
> like a commons api.
> Could you point me where this feature is implementated in the nebula
> grid? As I went through the grid code from the header_footer but I
> couldnd manage to find it.
> So I could have a look at it and try to integrate that in gallery.
>
> Thank you
>
> Baptiste
>
>
>
> Tom Schindl wrote:
>> Hi,
>>
>> Well I implemented such a feature for Nebula-Grid (the current
>> header_footer branch holds this stuff) besides loading images lazily you
>> also need to dispose them when the image is scrolled out of view else
>> you'll eating up your resource handles.
>>
>> The feature I added to grid is that you can subscribed to the grid and
>> you get informed about the currently showing cells in the view:
>>
>> a) when a cell is scrolled into view you can set an placeholder and span
>> a background-thread fetching the image restoring it in a temp dir and
>> replace the placeholder
>>
>> b) when a cell is scrolled out of view you can set dipose the resource
>> and set the image back to the placeholder and next time
>>
>> c) when the cell is once more scrolled into view check you local-disk
>> cache if the image is there load and return it else a)
>>
>> I don't know if Gallery has such a feature but if not it would maybe
>> make sense to work together on a common API both widgets provide to
>> their users.
>>
>> Tom
>>
>> user@domain.invalid schrieb:
>>> Hello everyone,
>>>
>>> We are currently developping a cataloging system, and we are using the
>>> GalleryViewer.
>>>
>>> We are loading a lot of image from the internet so I was wondering if
>>> there was any way I could load the image lazily?
>>> For example when loading a bunch of images into the gallery, i would
>>> like to display first a default image and the tittle of the image. And
>>> then in a thread fetch the image from the internet and replace the
>>> default image with the correct one for each gallery item.
>>>
>>> Thank you very much,
>>>
>>> Baptiste
>>
>>


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: Gallery image loading question [message #61539 is a reply to message #61325] Wed, 07 January 2009 12:01 Go to previous messageGo to next message
Nicolas Richeton is currently offline Nicolas RichetonFriend
Messages: 179
Registered: July 2009
Senior Member
A common API would be great.

I did lazy image loading with Gallery and Table in Sharemedia
www.sf.net/projects/sharemedia.

see org.sharemedia.services.imageservice.*
and org.sharemedia.libraryview.gallery.*

The basic idea is to use :
- SetData event to create the item, but not the image.
- Paint event to create the image if there is none or if the previous
one was disposed
- A class (WidgetImageCache) ensure that the widget does not creat
more than X images, and dispose the oldest ones if necessary.
- When the widget is hidden, the cache cleans all images to release
memory.

The good thing is that this works with all SWT controls with no
additionnal API

On the other side :
- the cache can keep more images than necessary (cache > visible items).
- if the widget can display more items than the cache size (cache <
visible), painting is slow because all images are disposed right after use.

To solve these issues, I only need a way to know how many items are
visible in a control to set the cache size accordingly.

If we work on an API, we have to ensure that the SWT team is ok to
support it in SWT default widgets.

Nicolas




Tom Schindl a écrit :
> Hi,
>
> It is the GridVisibleRangeSupport which you are looking for.
>
> Tom
>
> user@domain.invalid schrieb:
>> Hi Tom,
>>
>> Thank you for your answer,
>>
>> I don't find any feature like that in Gallery. It would be great to have
>> like a commons api.
>> Could you point me where this feature is implementated in the nebula
>> grid? As I went through the grid code from the header_footer but I
>> couldnd manage to find it.
>> So I could have a look at it and try to integrate that in gallery.
>>
>> Thank you
>>
>> Baptiste
>>
>>
>>
>> Tom Schindl wrote:
>>> Hi,
>>>
>>> Well I implemented such a feature for Nebula-Grid (the current
>>> header_footer branch holds this stuff) besides loading images lazily you
>>> also need to dispose them when the image is scrolled out of view else
>>> you'll eating up your resource handles.
>>>
>>> The feature I added to grid is that you can subscribed to the grid and
>>> you get informed about the currently showing cells in the view:
>>>
>>> a) when a cell is scrolled into view you can set an placeholder and span
>>> a background-thread fetching the image restoring it in a temp dir and
>>> replace the placeholder
>>>
>>> b) when a cell is scrolled out of view you can set dipose the resource
>>> and set the image back to the placeholder and next time
>>>
>>> c) when the cell is once more scrolled into view check you local-disk
>>> cache if the image is there load and return it else a)
>>>
>>> I don't know if Gallery has such a feature but if not it would maybe
>>> make sense to work together on a common API both widgets provide to
>>> their users.
>>>
>>> Tom
>>>
>>> user@domain.invalid schrieb:
>>>> Hello everyone,
>>>>
>>>> We are currently developping a cataloging system, and we are using the
>>>> GalleryViewer.
>>>>
>>>> We are loading a lot of image from the internet so I was wondering if
>>>> there was any way I could load the image lazily?
>>>> For example when loading a bunch of images into the gallery, i would
>>>> like to display first a default image and the tittle of the image. And
>>>> then in a thread fetch the image from the internet and replace the
>>>> default image with the correct one for each gallery item.
>>>>
>>>> Thank you very much,
>>>>
>>>> Baptiste
>>>
>
>
Re: Gallery image loading question [message #61557 is a reply to message #61539] Wed, 07 January 2009 20:08 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi Nicolas,

Nicolas Richeton schrieb:
> A common API would be great.
>
> I did lazy image loading with Gallery and Table in Sharemedia
> www.sf.net/projects/sharemedia.
>
> see org.sharemedia.services.imageservice.*
> and org.sharemedia.libraryview.gallery.*
>
> The basic idea is to use :
> - SetData event to create the item, but not the image.
> - Paint event to create the image if there is none or if the previous
> one was disposed
> - A class (WidgetImageCache) ensure that the widget does not creat
> more than X images, and dispose the oldest ones if necessary.
> - When the widget is hidden, the cache cleans all images to release
> memory.
>
> The good thing is that this works with all SWT controls with no
> additionnal API
>
> On the other side :
> - the cache can keep more images than necessary (cache > visible items).
> - if the widget can display more items than the cache size (cache <
> visible), painting is slow because all images are disposed right after use.

It's maybe not only suiteable for Images, Fonts, ... all types resources
and even Strings can be a memory / handler problem.

>
> To solve these issues, I only need a way to know how many items are
> visible in a control to set the cache size accordingly.
>
> If we work on an API, we have to ensure that the SWT team is ok to
> support it in SWT default widgets.
>

This is impossible for SWT and so the SetData-call back works
differently in SWT as far as I remember (called only once for the
lifetime of a Table/TreeItem [1]).

Tom

[1] http://tom-eclipse-dev.blogspot.com/2007/01/what-items-are-v isible-in-tabletree.html

--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: Gallery image loading question [message #592993 is a reply to message #61252] Fri, 12 December 2008 10:13 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

Well I implemented such a feature for Nebula-Grid (the current
header_footer branch holds this stuff) besides loading images lazily you
also need to dispose them when the image is scrolled out of view else
you'll eating up your resource handles.

The feature I added to grid is that you can subscribed to the grid and
you get informed about the currently showing cells in the view:

a) when a cell is scrolled into view you can set an placeholder and span
a background-thread fetching the image restoring it in a temp dir and
replace the placeholder

b) when a cell is scrolled out of view you can set dipose the resource
and set the image back to the placeholder and next time

c) when the cell is once more scrolled into view check you local-disk
cache if the image is there load and return it else a)

I don't know if Gallery has such a feature but if not it would maybe
make sense to work together on a common API both widgets provide to
their users.

Tom

user@domain.invalid schrieb:
> Hello everyone,
>
> We are currently developping a cataloging system, and we are using the
> GalleryViewer.
>
> We are loading a lot of image from the internet so I was wondering if
> there was any way I could load the image lazily?
> For example when loading a bunch of images into the gallery, i would
> like to display first a default image and the tittle of the image. And
> then in a thread fetch the image from the internet and replace the
> default image with the correct one for each gallery item.
>
> Thank you very much,
>
> Baptiste


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: Gallery image loading question [message #593006 is a reply to message #61277] Sat, 13 December 2008 11:26 Go to previous message
user is currently offline userFriend
Messages: 296
Registered: July 2009
Senior Member
Hi Tom,

Thank you for your answer,

I don't find any feature like that in Gallery. It would be great to have
like a commons api.
Could you point me where this feature is implementated in the nebula
grid? As I went through the grid code from the header_footer but I
couldnd manage to find it.
So I could have a look at it and try to integrate that in gallery.

Thank you

Baptiste



Tom Schindl wrote:
> Hi,
>
> Well I implemented such a feature for Nebula-Grid (the current
> header_footer branch holds this stuff) besides loading images lazily you
> also need to dispose them when the image is scrolled out of view else
> you'll eating up your resource handles.
>
> The feature I added to grid is that you can subscribed to the grid and
> you get informed about the currently showing cells in the view:
>
> a) when a cell is scrolled into view you can set an placeholder and span
> a background-thread fetching the image restoring it in a temp dir and
> replace the placeholder
>
> b) when a cell is scrolled out of view you can set dipose the resource
> and set the image back to the placeholder and next time
>
> c) when the cell is once more scrolled into view check you local-disk
> cache if the image is there load and return it else a)
>
> I don't know if Gallery has such a feature but if not it would maybe
> make sense to work together on a common API both widgets provide to
> their users.
>
> Tom
>
> user@domain.invalid schrieb:
>> Hello everyone,
>>
>> We are currently developping a cataloging system, and we are using the
>> GalleryViewer.
>>
>> We are loading a lot of image from the internet so I was wondering if
>> there was any way I could load the image lazily?
>> For example when loading a bunch of images into the gallery, i would
>> like to display first a default image and the tittle of the image. And
>> then in a thread fetch the image from the internet and replace the
>> default image with the correct one for each gallery item.
>>
>> Thank you very much,
>>
>> Baptiste
>
>
Re: Gallery image loading question [message #593015 is a reply to message #61301] Sat, 13 December 2008 14:34 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

It is the GridVisibleRangeSupport which you are looking for.

Tom

user@domain.invalid schrieb:
> Hi Tom,
>
> Thank you for your answer,
>
> I don't find any feature like that in Gallery. It would be great to have
> like a commons api.
> Could you point me where this feature is implementated in the nebula
> grid? As I went through the grid code from the header_footer but I
> couldnd manage to find it.
> So I could have a look at it and try to integrate that in gallery.
>
> Thank you
>
> Baptiste
>
>
>
> Tom Schindl wrote:
>> Hi,
>>
>> Well I implemented such a feature for Nebula-Grid (the current
>> header_footer branch holds this stuff) besides loading images lazily you
>> also need to dispose them when the image is scrolled out of view else
>> you'll eating up your resource handles.
>>
>> The feature I added to grid is that you can subscribed to the grid and
>> you get informed about the currently showing cells in the view:
>>
>> a) when a cell is scrolled into view you can set an placeholder and span
>> a background-thread fetching the image restoring it in a temp dir and
>> replace the placeholder
>>
>> b) when a cell is scrolled out of view you can set dipose the resource
>> and set the image back to the placeholder and next time
>>
>> c) when the cell is once more scrolled into view check you local-disk
>> cache if the image is there load and return it else a)
>>
>> I don't know if Gallery has such a feature but if not it would maybe
>> make sense to work together on a common API both widgets provide to
>> their users.
>>
>> Tom
>>
>> user@domain.invalid schrieb:
>>> Hello everyone,
>>>
>>> We are currently developping a cataloging system, and we are using the
>>> GalleryViewer.
>>>
>>> We are loading a lot of image from the internet so I was wondering if
>>> there was any way I could load the image lazily?
>>> For example when loading a bunch of images into the gallery, i would
>>> like to display first a default image and the tittle of the image. And
>>> then in a thread fetch the image from the internet and replace the
>>> default image with the correct one for each gallery item.
>>>
>>> Thank you very much,
>>>
>>> Baptiste
>>
>>


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: Gallery image loading question [message #593102 is a reply to message #61325] Wed, 07 January 2009 12:01 Go to previous message
Nicolas Richeton is currently offline Nicolas RichetonFriend
Messages: 179
Registered: July 2009
Senior Member
A common API would be great.

I did lazy image loading with Gallery and Table in Sharemedia
www.sf.net/projects/sharemedia.

see org.sharemedia.services.imageservice.*
and org.sharemedia.libraryview.gallery.*

The basic idea is to use :
- SetData event to create the item, but not the image.
- Paint event to create the image if there is none or if the previous
one was disposed
- A class (WidgetImageCache) ensure that the widget does not creat
more than X images, and dispose the oldest ones if necessary.
- When the widget is hidden, the cache cleans all images to release
memory.

The good thing is that this works with all SWT controls with no
additionnal API

On the other side :
- the cache can keep more images than necessary (cache > visible items).
- if the widget can display more items than the cache size (cache <
visible), painting is slow because all images are disposed right after use.

To solve these issues, I only need a way to know how many items are
visible in a control to set the cache size accordingly.

If we work on an API, we have to ensure that the SWT team is ok to
support it in SWT default widgets.

Nicolas




Tom Schindl a écrit :
> Hi,
>
> It is the GridVisibleRangeSupport which you are looking for.
>
> Tom
>
> user@domain.invalid schrieb:
>> Hi Tom,
>>
>> Thank you for your answer,
>>
>> I don't find any feature like that in Gallery. It would be great to have
>> like a commons api.
>> Could you point me where this feature is implementated in the nebula
>> grid? As I went through the grid code from the header_footer but I
>> couldnd manage to find it.
>> So I could have a look at it and try to integrate that in gallery.
>>
>> Thank you
>>
>> Baptiste
>>
>>
>>
>> Tom Schindl wrote:
>>> Hi,
>>>
>>> Well I implemented such a feature for Nebula-Grid (the current
>>> header_footer branch holds this stuff) besides loading images lazily you
>>> also need to dispose them when the image is scrolled out of view else
>>> you'll eating up your resource handles.
>>>
>>> The feature I added to grid is that you can subscribed to the grid and
>>> you get informed about the currently showing cells in the view:
>>>
>>> a) when a cell is scrolled into view you can set an placeholder and span
>>> a background-thread fetching the image restoring it in a temp dir and
>>> replace the placeholder
>>>
>>> b) when a cell is scrolled out of view you can set dipose the resource
>>> and set the image back to the placeholder and next time
>>>
>>> c) when the cell is once more scrolled into view check you local-disk
>>> cache if the image is there load and return it else a)
>>>
>>> I don't know if Gallery has such a feature but if not it would maybe
>>> make sense to work together on a common API both widgets provide to
>>> their users.
>>>
>>> Tom
>>>
>>> user@domain.invalid schrieb:
>>>> Hello everyone,
>>>>
>>>> We are currently developping a cataloging system, and we are using the
>>>> GalleryViewer.
>>>>
>>>> We are loading a lot of image from the internet so I was wondering if
>>>> there was any way I could load the image lazily?
>>>> For example when loading a bunch of images into the gallery, i would
>>>> like to display first a default image and the tittle of the image. And
>>>> then in a thread fetch the image from the internet and replace the
>>>> default image with the correct one for each gallery item.
>>>>
>>>> Thank you very much,
>>>>
>>>> Baptiste
>>>
>
>
Re: Gallery image loading question [message #593110 is a reply to message #61539] Wed, 07 January 2009 20:08 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi Nicolas,

Nicolas Richeton schrieb:
> A common API would be great.
>
> I did lazy image loading with Gallery and Table in Sharemedia
> www.sf.net/projects/sharemedia.
>
> see org.sharemedia.services.imageservice.*
> and org.sharemedia.libraryview.gallery.*
>
> The basic idea is to use :
> - SetData event to create the item, but not the image.
> - Paint event to create the image if there is none or if the previous
> one was disposed
> - A class (WidgetImageCache) ensure that the widget does not creat
> more than X images, and dispose the oldest ones if necessary.
> - When the widget is hidden, the cache cleans all images to release
> memory.
>
> The good thing is that this works with all SWT controls with no
> additionnal API
>
> On the other side :
> - the cache can keep more images than necessary (cache > visible items).
> - if the widget can display more items than the cache size (cache <
> visible), painting is slow because all images are disposed right after use.

It's maybe not only suiteable for Images, Fonts, ... all types resources
and even Strings can be a memory / handler problem.

>
> To solve these issues, I only need a way to know how many items are
> visible in a control to set the cache size accordingly.
>
> If we work on an API, we have to ensure that the SWT team is ok to
> support it in SWT default widgets.
>

This is impossible for SWT and so the SetData-call back works
differently in SWT as far as I remember (called only once for the
lifetime of a Table/TreeItem [1]).

Tom

[1] http://tom-eclipse-dev.blogspot.com/2007/01/what-items-are-v isible-in-tabletree.html

--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Previous Topic:Problem with getFocusCell method in Grid
Next Topic:Problem with getFocusCell method in Grid
Goto Forum:
  


Current Time: Thu Mar 28 18:05:26 GMT 2024

Powered by FUDForum. Page generated in 0.05060 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top