Home » Eclipse Projects » Remote Application Platform (RAP) » Working with images
Working with images [message #31585] |
Thu, 07 June 2007 08:35  |
Eclipse User |
|
|
|
Hi all, I have a doubt about how to work with Images.
Now I store images in Blob columns of my BBDD, I would like to convert
them in org.eclipse.swt.graphics.Image objects in order to display them
in a Label widget, well, I'm thinking about to use this method:
Image img = Image.find("/myimage_000", myBlob.getBinaryStream());
But then, I have 2 poblems:
1.- Image bytes are cached and I'm using a shared hosting provider with
a limited private heap size and if these images are stored in cache I
could have problems with memory limitations.
2.- An Image can be modified and I don't know how to "refresh" cached
image data with new data.
Is there any way for dispose an Image from cache ?
I'm thinking about alternatives, If i can't use a standard widget I can
implements my own ImageWidget or I can use a Browser with XML/XSLT
content to display an embebed serialized image.
Any other idea ?
Thanks in advance.
Roberto.
|
|
| |
Re: Working with images [message #31860 is a reply to message #31791] |
Mon, 11 June 2007 05:30   |
Eclipse User |
|
|
|
Originally posted by: roberto.sanchez.autonomind.com
Hi Frank, there is a problem with this "approach", Sharing images
between sessions isn't a good idea if these images are "private", that
is, my application is a Curriculum vitae manager, and the images that i
have to store are user photos, they are "private info", of course an
user can change his own photo so I need to "refresh" that image.
Imagine, if I have 1000 users with photo, and every foto of 100 Kb, If
all photos are stored in Image cache, Every time an user login my
application his photo is shown and stored, I'll need 100 Mb only for
storing photos !! that is too much for my system (I'm using a shared
hosting provider), just for 1000 users, imagine 10000, ...
Besides I had another problem showing images in Labels, the size, I need
to show all photos with the same size and AFAIK this is not possible in
this moment with Label widget then I had to look for another solution:
I don't use Image objects, I've created a Photo control, which extends
from Composite and contain a Browser widget I need a new servlet as
well, this servlet reads the image from database and returns an image
content, i.e. "image/png", I set Browser url pointing to this servlet
adding "photo code" and It works fine. I use a minimal amount of heap
memory and images are shown with the size I need.
Regards.
Roberto.
Frank Appel wrote:
> Hi,
>
> as RAP shares images between user sessions, it is currently not possible to
> dispose of a single image instance. Sharing the images between sessions
> instead of creating image instances of the same images for each session
> should in fact reduce the needed heap size for image representation.
> Currently it is only possible to clear the complete image buffer
> (Image.clear()), but I am not sure, whether this is really a good way if
> you only need to refresh one image. There is also a problem due to the SWT
> subset API with that approach. So probably there will be some changes to the
> Image stuff till 1.0.
>
> Ciao
> Frank
>
> "Roberto Sá‡nchez" <roberto@autonomind.com> schrieb im Newsbeitrag
> news:f48u1p$49b$1@build.eclipse.org...
>> Hi all, I have a doubt about how to work with Images.
>>
>> Now I store images in Blob columns of my BBDD, I would like to convert
>> them in org.eclipse.swt.graphics.Image objects in order to display them in
>> a Label widget, well, I'm thinking about to use this method:
>>
>> Image img = Image.find("/myimage_000", myBlob.getBinaryStream());
>>
>> But then, I have 2 poblems:
>>
>> 1.- Image bytes are cached and I'm using a shared hosting provider with a
>> limited private heap size and if these images are stored in cache I could
>> have problems with memory limitations.
>>
>> 2.- An Image can be modified and I don't know how to "refresh" cached
>> image data with new data.
>>
>>
>> Is there any way for dispose an Image from cache ?
>>
>>
>> I'm thinking about alternatives, If i can't use a standard widget I can
>> implements my own ImageWidget or I can use a Browser with XML/XSLT content
>> to display an embebed serialized image.
>>
>> Any other idea ?
>>
>> Thanks in advance.
>> Roberto.
>
>
|
|
|
Re: Working with images [message #32036 is a reply to message #31860] |
Tue, 12 June 2007 03:06  |
Eclipse User |
|
|
|
Originally posted by: fappel.innoopract.com
Hi,
I see your point that images are not reused between sessions in your case.
And as the Label does not fit your needs you have found a solution that
works fine for you. But just for clarification I think your memory
computation is not correct. We do not buffer the image's data, we only
buffer the link to the image's location. All in all we only have a String
and a Object reference which, if I remember our tests correctly, do not
consume more that a few Kb - let's say 5 to 10. So the1000 images would
consume 5 to 10 Mb.
In most cases images are reused application wide, so this is a memory
inprovement compared to that every session creates redundantly the same
images. There's also the possibility to implement an overflow strategy, say
we limit the buffer size and remove the images that are seldom used. Seeing
your use case I think also about creating the possibility to remove a image
explicitly from the buffer.
Thanks for your input, that helps us to improve RAP!
Ciao
Frank
"Roberto S
|
|
|
Goto Forum:
Current Time: Thu Apr 24 22:46:19 EDT 2025
Powered by FUDForum. Page generated in 0.03398 seconds
|