Skip to main content

Microsoft Silverlight

Answered Question Converting images to thumbnailsRSS Feed

(0)

kobruleht
kobruleht

Member

Member

161 points

579 Posts

Converting images to thumbnails

Images are stored in server database and retrieved as byte[] arrays using web service.

How to allow users to upload images of any size but convert them to small fixed-size thumbnails for fast display over slow internet connection?
Or is it better to do this conversion in client side to increase upload speed also?

Where to find such library and sample code? This should be common requirement.

Andrus.

ken tucker
ken tucker

All-Star

All-Star

16288 points

2,485 Posts

Answered Question

Re: Converting images to thumbnails

 Silverlight 2 does not have any bitmap functions so you would have to upload the image and process it server side.  I

 

Your best bet for doing this is to load the image into a bitmap class on the server side.  Check the size if it is too large I would use drawimage to draw the old bitmap on a new one of smaller size.  Then you would save the smaller image in the database.

ksleung
ksleung

Contributor

Contributor

5366 points

1,028 Posts

Re: Converting images to thumbnails

In SL2 you can use the open source Jpeg decoder (and encoder) called FJCore.  It has some functionality to resize images.

In SL3 beta there is WriteableBitmap but for two reasons it won't be helpful to you -- (1) security (see various threads on this topic), and (2) no way to encode bitmap to Jpeg.  Therefore, your choices are really (a) send the whole thing to the server, or (b) use FJCore to process the image on the client side and then send it to the server.

jay nanavati
jay nana...

Contributor

Contributor

3388 points

624 Posts

Re: Converting images to thumbnails

 If you prefer to use Silverlight 3, you can use WriteableBitmap class to redraw images that are large to relatively small size.

Jay K Nanavaty
www.technologyopinion.com
Mark as answer if it helps. It will also help others...

kobruleht
kobruleht

Member

Member

161 points

579 Posts

Re: Converting images to thumbnails

Thank you. My shop cart thumbnails are defined as

<Image Source='{Binding Toode_pilt}' Height='200' MaxWidth='150'/>
 and retrieved from db using web service as byte[] arrays.

They can be enlarged so they must be stored in high quality in database.

Where to find sample code for DrawImage or other solution in server side which reduces size of jpeg byte[] array for this format and to minimal size before sending ?

Andrus.

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities