Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Silverlight do the following?

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.

like image 603
Pure.Krome Avatar asked Nov 24 '25 06:11

Pure.Krome


2 Answers

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.

like image 140
Nigel Sampson Avatar answered Nov 27 '25 04:11

Nigel Sampson


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);
like image 36
stimms Avatar answered Nov 27 '25 03:11

stimms



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!