Skip to main content
Home Forums Silverlight Programming Programming with .NET - General Downloader object override my Image clipping that I set with Blend.
13 replies. Latest Post by Epsilone3 on October 2, 2007.
(0)
Epsilone3
Member
248 points
138 Posts
09-26-2007 6:37 PM |
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.
Guy.
09-26-2007 8:09 PM |
Maybe there a way to copy clipping data in c# from one image to another ?
And by that keep my clipping ..
jasonxz
Participant
1752 points
530 Posts
09-26-2007 8:57 PM |
Try putting the Clip on the Canvas that's the root of a User Control and the Image in that Canvas.
09-27-2007 3:16 AM |
I need to do this override of clipping data in C# .
Cause the Downloader object overraid my Image clipping...
<
and this is the C# function...
{
im.SetSource( _downloader,
// Way's I've try to overraid the im.clip with the ImageFrame.clip //
/* 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
09-27-2007 8:35 AM |
Did you try my suggestion?
09-27-2007 8:49 AM |
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 ?
09-27-2007 8:53 AM |
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.
09-27-2007 8:58 AM |
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 .
09-27-2007 9:00 AM |
OK , I try it now.
I make a new xaml as my UserControl , and let you know.
09-27-2007 9:10 AM |
You know I really start to like that little boy :-).
It's work.
10x Again.
09-27-2007 9:56 AM |
Jason are we lost the Stretch options now ?
When The Image get clipped inside a canvas clipping ?
09-27-2007 10:09 AM |
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.
09-27-2007 10:22 AM |
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.
10-02-2007 3:15 AM |
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