Skip to main content

Microsoft Silverlight

Answered Question Request for getting binary from Canvas/Image ControlRSS Feed

(0)

jo2fong
jo2fong

Member

Member

2 points

12 Posts

Request for getting binary from Canvas/Image Control

It is so disappointed that SL does not support saving drawing on image/canvas....to jpeg..............................................

ksleung
ksleung

Contributor

Contributor

5366 points

1,028 Posts

Re: Request for getting binary from Canvas/Image Control

When SL3 RTW comes out hopefully we can save a control to a WriteableBitmap and then to a byte stream, assuming the original content is not a security risk.  Then, we can convert the byte stream to a Jpeg file using a 3rd party tool such as FJCore.  Right now, you can save a control to a WriteableBitmap but the bitmap is not readable (except to be used as an image source).

MarkMonster
MarkMonster

Contributor

Contributor

5220 points

1,046 Posts

Re: Request for getting binary from Canvas/Image Control

I guess we will have to wait until July 10.

Mark Monster - MCPD Enterprise
http://mark.mymonster.nl
Silverlight and Expression Insiders UG

Dont forget to click "Mark as Answer" on the post that helped you.

jo2fong
jo2fong

Member

Member

2 points

12 Posts

Re: Request for getting binary from Canvas/Image Control

i am developing application that would perform some drawing features on images...such draw text annotation..
i can draw the text...on image/canvas...but no way to save the content back to jpeg/png files....so disappointed...
i will give up in exploring SL...

ksleung
ksleung

Contributor

Contributor

5366 points

1,028 Posts

Re: Request for getting binary from Canvas/Image Control

Don't give up, wait for another month Big Smile

jo2fong
jo2fong

Member

Member

2 points

12 Posts

Re: Request for getting binary from Canvas/Image Control

I heard that SL3 still not support getting binary from Image/Canvas control....
In addition, Microsoft Silverlight Product Team seem not take developers' voice into consideration as I saw there is alot of votes on requesting printing feature and binary from from silverlight control...,but it seem these voice are ignored until SL 4

I am turning into Adobe Flex 3 now...Sad

MarkMonster
MarkMonster

Contributor

Contributor

5220 points

1,046 Posts

Re: Request for getting binary from Canvas/Image Control

I definitely don't feel like that. The Silverlight product team is reading the forums very often as I heard. And also don't forget the very tight schedule they are working on.

Silverlight 2 RTW: 2008-10-14

Silverlight 3 RTW: 2009-07-10

Just 9 months. Don't know if they will keep this speed in releasing, but they definitely put a lot of new things in SL3. Where did you hear that SL3 will not support getting binary from image/canvas control? Almost everyone (not always directly related to Microsoft) tell me it will probably be there because they think WritableBitmap is very useless without it.

Yes printing will take some time, but I also consider this one a very difficult one. Because all the advanced layouts that are possible on the screen, do we want this kind of thing on paper? Not just possible, but I don't know how Flex solved that.

Hope you'll stick at SL :-).

Mark Monster - MCPD Enterprise
http://mark.mymonster.nl
Silverlight and Expression Insiders UG

Dont forget to click "Mark as Answer" on the post that helped you.

ksleung
ksleung

Contributor

Contributor

5366 points

1,028 Posts

Re: Request for getting binary from Canvas/Image Control

I totally agree with Mark Monster.  And in my earlier reply, I already spelt out how to do that what the one tiny little feature which I shall call WriteableBitmap security issue is resolved.  The Silverlight team knows about this issue from the beginning and I ad many others had raised this important issue many times.  I am sure this is important to them as well.  One of the SL team member did say that this will be available in SL3 RTW, just that the exact detail about the security criteria has not been announced.  But comes SL3 RTW I definitely think you will be able to convert your drawings to Jpg...  Actually you can even do it today, just that you need to following a different (and more difficult) route that's all.

jo2fong
jo2fong

Member

Member

2 points

12 Posts

Re: Request for getting binary from Canvas/Image Control

I really thank for all you guys from heart!!! sorry for my bad temper in previous post.
In fact, i also a .net lovers, however, i have to submit my prototype on jul and may not be able to wait for Silverlight.

The most difficult part for me is that i cant save my drawing on canvas/image to jpeg control in SL 2.
i know we can submit XAML of SL to WCF and convert it to binary using WPF...but it is a bit indirect,slow performance and sometime inaccurate result.
In addition, i saw from posts in forum saying that SL3 also does not support getting binary from control and can't save drawing.
Therefore, i tend to NOT put it into SL platform.

jo2fong
jo2fong

Member

Member

2 points

12 Posts

Re: Request for getting binary from Canvas/Image Control

is there any way that we could have a try of the mentioned features? i.e. get binary from image/canvas control in SL3 RTW?

ksleung
ksleung

Contributor

Contributor

5366 points

1,028 Posts

Re: Request for getting binary from Canvas/Image Control

You'd need to wait to the release (presumably July 10th).  Unless there is an interim Release Candidate, it will be impossible to mimick or simulate the conversion even in the simplest setting.

Only thing you want to do is to set up your application so that it can convert a *readable* WriteableBitmap to Jpeg, since this step will not be provided by Silverlight even in SL3 RTW.  For now the only time a WriteableBitmap is readable only when it has never been "Render()" into.

jo2fong
jo2fong

Member

Member

2 points

12 Posts

Re: Request for getting binary from Canvas/Image Control

i am confused after readin the reply.
what is want to do is...i draw sth on image/canvas control such as drawing text, drawing line..etc
Can i save the image with drawn text and annotation to jpeg in SL3 RTW?

ksleung
ksleung

Contributor

Contributor

5366 points

1,028 Posts

Answered Question

Re: Request for getting binary from Canvas/Image Control

Supposedly, with some more work, YES.

The workflow to export Jpeg looks like this.

(1) Create a WriteableBitmap, take the image/canvas control, and call WriteableBitmap.Render() to render the content to the WriteableBitmap.  Now WriteableBitmap contains the pixels you want.

(2) Convert the WriteableBitmap to a byte array for processing in the next step

(3) Implement a new or use an existing C# Jpeg encoder, which takes a byte array reprensetation and convert into another byte array representation of the Jpeg.

In SL3 beta:

(1) is already supported
(2) is not supported because of the DRM issue.  Once the Render() function is called, the WriteableBitmap becomes unreadable.
(3) is not natively supported but it can be done

In SL3 RTW:

(1) is already supported (SAME AS ABOVE)
(2) should be supported for non-DRM-violating scenario
(3) is not natively supported but it can be done (SAME AS ABOVE)

jo2fong
jo2fong

Member

Member

2 points

12 Posts

Re: Request for gettifdng binary from Canvas/Image Control

there is no proven demo/sample on it...Sad

anyway, thank all again

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities