I believe you will always make use of the scaling tool insider Flash or Blend. However, have you ever thought of achieving image scaling by coding?
That’s not an easy technique. You have to take care of the mouse position, image position, scale factor, cursor look, etc..
But don’t worry, here you could find a very simple demo for manipulating the size of the image. My sample is not intended to give you a complete/portable solution for Image Scaling. Instead, it provides you a basic idea how this is working.
Comparison
Flash implementation: 50 minutes
Silverlight implementation: 70 minutes (Implemented First)
Source codes
Image Manipulation - Scale [Flash 9, AS3] (30.7 KiB, 804 hits)
Image Manipulation - Scale [Silverlight 2, C#] (20.7 KiB, 1,006 hits)
Flash
Silverlight
Silverlight: Create a custom property in XAML definition
If you open the Silverlight Source Code, you will find that the image is passed into the Image Manipulation Class directly in XAML. Here is part of the XAML code:
<custom:ImageManipulationScale VerticalAlignment=”Center” HorizontalAlignment=”Center“>
<custom:ImageManipulationScale.Source>
<Image Source=”shinedraw_logo.jpg” Width=”396” Height=”300“/>
</custom:ImageManipulationScale.Source>
</custom:ImageManipulationScale>
It’s an important technique that everyone must know it. It definitely helps you to write a more professional control.
To start with, we have to define the property name and the property type. In the sample above, the property name is Source and the type is Image. Then, we are going to add some codings behind the Class ImageManipulationScale.
// C#
// create a custom property than can be exported to XAML
public static readonly DependencyProperty SourceProperty =
DependencyProperty.Register(
"Source", typeof(Image),
typeof(ImageManipulationScale), null
);
// define a public property with the name Source
public Image Source
{
get { return (Image)GetValue(SourceProperty); }
set
{
SetValue(SourceProperty, value);
// do whatever you want here
}
}
That’s all! Pretty simple, right?

February 18th, 2009 at 6:21 am
[...] Silverlight vs Flash: Image Manipulation - Scale [...]
February 19th, 2009 at 12:04 pm
Odd - the Silverlight version appears to perform much better but the scaling of the image seem to be better in Flash. The scaled down Silverlight image is a little pixelated.
February 24th, 2009 at 3:37 am
[...] If you want to add a resize functionality to the object, you may refer to my previous post Image Manipulation - Scale. [...]
February 27th, 2009 at 8:23 pm
Nice custom property!Good job! I’ve wrote an article about Silverlight too:
Silverlight
Regards,
Mark
March 15th, 2009 at 8:05 pm
Nice one…
At the beginning i was a little bit fooled that silverlight renders the image better than flash, but when we want to compare the frame rate in this example we will find that silverlight has a default frame rate of (60 fps) while flash has only (24 fps) !, and that’s why it seems that silverlight renders the image better than flash, but if we put the two applications at the same level of frame rate, we will see that flash renders the image much more better than silverlight does !
May 2nd, 2009 at 2:55 am
I must say, I could not agree with you in 100%, but it
August 8th, 2009 at 6:33 pm
Silverlight vs Flash: Image Manipulation - Scale…
Thank you for submitting this cool story - Trackback from NewsPeeps…
December 9th, 2009 at 1:22 pm
I am a newbie trying to borrow this code (for Flash) and make it resize my object when clicked on. I am not having luck. Can you edit it for me so that I can apply the function to my own objects?
Thanks
July 10th, 2010 at 3:51 am
thanks for sharing..
keep moving forward..