Skip to main content

Microsoft Silverlight

Answered Question Downloader object override my Image clipping that I set with Blend.RSS Feed

(0)

Epsilone3
Epsilone3

Member

Member

248 points

138 Posts

Downloader object override my Image clipping that I set with Blend.

I've got combine website.

It  ASP with silverlight project attach to it.

I made a clipping to my image object in Blend ( Aug ) and put a default image to check the image result.

I've got the silverlight files in the ASP & in the SL project ( they are the same includeing  the clipping definition ) .

When I press on the default.html in the silverlight project -> Open in browser ... I see the page.xaml with the image clipping. ( the image is direct link of some image in my hard drive , just for the testing ) .

But when I press open in a browser to the default.html that in ASP project ( they are the same ) and I retrieve a real image from my images folder ..that

in sit in my ASP project ( with the downloader object ) he's ( I thinking ) override my Image clipping  properties and the image show in her full size.

Any ideals how to keep my clipping when the image retrieve her content from the downloader object.

image.SetSource ( downloader , null ) ;

this is my clipping data as they post in the page.xaml :

Clip="M0.5,98.728 C0.5,48.193945 41.465945,7.228 92,7.228 L468,7.228 C518.53405,7.228 559.5,48.193945 559.5,98.728 L559.5,325.728 C559.5,376.26205 518.53405,417.228 468,417.228 L92,417.228 C41.465945,417.228 0.5,376.26205 0.5,325.728 z"

I've thinking maybe clipping again my image any ideal how to set this clipping data in c#.

I've thinking maybe using

RectangleGeometry rg = new RectangleGeometry();

But I don't know how to put the above clipping data inside of him , and then how to apply this to resize and clipping my image object.

Does Dependency-Object copy properties can be use in that issue ?

Is there a better , simple way to get the wishes result , or the RectangeGeometry and Dependency-Object not the way please let me know.

10x for you replies.

 

Guy.

Epsilone3
Epsilone3

Member

Member

248 points

138 Posts

Re: Downloader object override my Image clipping that I set with Blend.

Maybe there a way to copy clipping data in c# from one image to another ?

And by that keep my clipping ..

jasonxz
jasonxz

Participant

Participant

1752 points

530 Posts

Answered Question

Re: Downloader object override my Image clipping that I set with Blend.

Try putting the Clip on the Canvas that's the root of a User Control and the Image in that Canvas.

Epsilone3
Epsilone3

Member

Member

248 points

138 Posts

Re: Downloader object override my Image clipping that I set with Blend.

I need to do this override of clipping data in C# .

Cause the Downloader object overraid my Image clipping...

<Image x:Name="ImageFrame"  Width="560" Height="424.455" Clip="M0.5,98.728 C0.5,48.193945 41.465945,7.228 92,7.228 L468,7.228 C518.53405,7.228 559.5,48.193945 559.5,98.728 L559.5,325.728 C559.5,376.26205 518.53405,417.228 468,417.228 L92,417.228 C41.465945,417.228 0.5,376.26205 0.5,325.728 z" Canvas.Left="22" Canvas.Top="1.272" Stretch="Fill" />

 

and this is the C# function...

public void DownloaderCompleted(object o, EventArgs e)

{

Image im = new Image ( );

im.SetSource( _downloader, null);

// Way's I've try to overraid the im.clip with the ImageFrame.clip //

// DependencyObject Do = UIElement.ClipProperty(); no luck //

// Geometry.TransformProperty gt= new DependencyProperty( ); no luck //

/*    im.Clip ( M0.5,98.728 C0.5,48.193945 41.465945,7.228 92,7.228 L468,7.228 C518.53405,7.228 559.5,48.193945 559.5,98.728  L559.5,325.728 ,

      C559.5,376.26205 518.53405,417.228 468,417.228 L92,417.228 C41.465945,417.228 0.5,376.26205 0.5,325.728 z );  */

}

 

I burn - out Google engine in searching for that answer  // No luck for now //

 

Also I've try to look for this cliping data inside Quick-View in C# break -point can't find it . no luck. -:O

jasonxz
jasonxz

Participant

Participant

1752 points

530 Posts

Re: Downloader object override my Image clipping that I set with Blend.

Did you try my suggestion?

Epsilone3
Epsilone3

Member

Member

248 points

138 Posts

Re: Downloader object override my Image clipping that I set with Blend.

You want that the canvas clipped the image bounders  ? and that should not let the downloader object override the clipping ?

Maybe I don't understand what you really means ?

Do you ever success to see the Image clipping data inside a quick-view ?

 

 

jasonxz
jasonxz

Participant

Participant

1752 points

530 Posts

Answered Question

Re: Downloader object override my Image clipping that I set with Blend.

Let me explain in a little more detail.  Have I done this?  No.  But, it should work.

Create a UserControl.  This UserControl will contain a Canvas as its root.  Put your clip on that Canvas.  Put the Image inside that Canvas.  If you do this, it doesn't matter what the image does b/c the Canvas will only show what inside the clip path.

Epsilone3
Epsilone3

Member

Member

248 points

138 Posts

Re: Downloader object override my Image clipping that I set with Blend.

I thinki the key to do that is in the begging of the clipping data.

the clipping in the xaml goes like :

<Imagem x:Name="ImageFrame"  Clip="Clip ( M0.5,98.728 C0.5,48.193945 41.465945,7.228...."/>

So if we could figure out what is ( M0.05,98.728 C0.5,48.... ) we could figure what kind of object of matrix it is ?

But any way I think It's hard to figure casue in the  quick-view we can't see the cliping data ... )

I only could trace that the :

ImageFrame.Clip  is a Geometry UIElement and the  Image.ClipProperty  is a DependencyProperty .

 

Epsilone3
Epsilone3

Member

Member

248 points

138 Posts

Re: Downloader object override my Image clipping that I set with Blend.

OK , I try it now.

I make a new xaml as my UserControl , and let you know.

Epsilone3
Epsilone3

Member

Member

248 points

138 Posts

Re: Downloader object override my Image clipping that I set with Blend.

You know I really start to like that little boy :-).

It's work.

10x Again.

 

Epsilone3
Epsilone3

Member

Member

248 points

138 Posts

Re: Re: Downloader object override my Image clipping that I set with Blend.

Jason are we lost the Stretch options now ?

When The Image get clipped  inside a canvas clipping ?

jasonxz
jasonxz

Participant

Participant

1752 points

530 Posts

Re: Re: Downloader object override my Image clipping that I set with Blend.

Hmmm....  Good question.  What, exactly, is it that you're wanting to do with the Stretch?  Clipping and Stretching may not be compatible even if the clipping is done directly on the image.

 

Epsilone3
Epsilone3

Member

Member

248 points

138 Posts

Re: Re: Downloader object override my Image clipping that I set with Blend.

Clipping and stretching cause the pictures are in  hi- res .

So back to start :-) ?.

 

 

Guy's solutions : :-)

 

How to copy a xaml clipping with C# ?

And how it's possible to see the clypping data inside a quick-view ?

 

 

And 10x  allot to Jason ,

For not giving up on this one :-) .

10x.

 

Epsilone3
Epsilone3

Member

Member

248 points

138 Posts

Answered Question

Re: Re: Downloader object override my Image clipping that I set with Blend.

HI ok.

Yi-Lun Luo - MSFT 
Give me this suggestion I've still got not time to check cause I've move back to XBAP.

 

But here his suggestion hope it can help :

Unfortunately, looks like it won’t be so easy in Silverlight… But maybe it’s because I still don’t have much knowledge on Silverlight. If you try to do something like image.Clip = path.Data; or even simply image2.Clip = image1.Clip; You’ll encounter exceptions at run time…

 

The only way I found to reuse a Clip created from such a string is to completely create the Image in code via XamlReader:

            string clipText = "M0.5,98.728 C0.5,48.193945 41.465945,7.228 92,7.228 L468,7.228 C518.53405,7.228 559.5,48.193945 559.5,98.728 L559.5,325.728 C559.5,376.26205 518.53405,417.228 468,417.228 L92,417.228 C41.465945,417.228 0.5,376.26205 0.5,325.728 z";

            Image image = (Image)XamlReader.Load("<Image Source=\"Test.jpg\" Clip=\"" + clipText + "\"/>");

            //You can also set other properties in code if you don’t want to mess them in the XAML string.

            image.Width = 560;

            image.Height = 424.455;

            image.Stretch = Stretch.Fill;

            image.SetValue(Canvas.LeftProperty, 20d);

            image.SetValue(Canvas.TopProperty, 20d);

            this.Children.Add(image);

 

Then you can create another image using the same clipText.

 

http://forums.microsoft.com/MSDN/showpost.aspx?postid=2217956&siteid=1


 

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities