views:

540

answers:

2

Hi folks,

Can i do the following in a silverlight page/app? (Note: the silverlight app will be embedded on an ASP.NET MVC website page) :-

  1. Display an image from a resource: eg. www.someDomain.com/image.png
  2. Url of the image to display is passed into the control (ie. it's not hardcoded, but .. say .. entered into a textbox via the user, on the page).
  3. Resize the image.
  4. Add layers to the image. A layer could be .. i donno .. some basic text or another image or icon
  5. change the font or font-size of a layer font.
  6. 'Save' the modified image to another url, via an HTTP-POST. So if i've resized the image or added some text-layers these are all rendered into a single bitmap (png/jpg/whatever) which is then POST'ed to a url as binary. (ie. multipart/form-data)

Note:

I've asked this question before but that was for Flash (flv/swf). I'm now interested if this can be done in silverlight.

Updated Question

Also, what software is required to create these silverlight apps? VS2008? Expression blend? I know u can use notepad .. but i'm so new to this I would need some WYSIWYG app, I expect.

+3  A: 

Yes it can, but it has similar crossdomain restriction as flash. You'll need a crossdomain.xml or clientaccesspolicy.xml in place on the remote servers to allow silverlight to communicate with them. There is an ms article here which gives some more information on the restrictions on using silverlight to talk to other servers.

Once you have the image then you can manipulate it on the client side using the normal .net libraries for such purposes.

So you might load it with

Bitmap bitmap = new Bitmap(<some stream>);
Graphics g = Graphics.FromImage(bitmap);

and then you can play with it in any way you wish.

g.DrawString("Silverlight image", 
    new Font("times", 32), 
    SystemBrushes.WindowText, 0, 0);
stimms
If it's the same as flash as you say, then you should also be able to proxy it through your server. Eg pass the image URL to your server, have the server download the image and return it to you. That will get around any crossdomain restrictions.
davr
You haven't said anything about client side image manipulation? is this available? Like Nigel suggested in another answer in this thread, it might be available in API v 3???
Pure.Krome
Added a bit about doing the manipulation. @davr, good call on proxying, but I kind of wonder if that doesn't defeat the purpose of having those restrictions in the first place.
stimms
+3  A: 

The Writable Bitmap API Silverlight 3 sounds pretty much what you're after. You can use the standard Silverlight controls such as TextBlock and Image to lay the image and layers out and then use the API to take a "screenshot" of that layout to upload to a server.

Hope this helps.

Nigel Sampson
Could I please have some more info on this Writable Bitmap API in SL3 please? Is it out, yet?This TextBlock and Image thing you talk about might be the answer also. .. Any links to examples?
Pure.Krome
Here's a url that's what you're after. http://www.wintellect.com/CS/blogs/jprosise/archive/2009/03/25/more-on-silverlight-3-s-new-writeable-bitmap.aspx
Nigel Sampson