|
|
Questions and answers for Graphics and Multimedia 2D Graphics.
|
28. Graphics and Multimedia 2D Graphics
|
| 28.1 How
do I apply BitmapEffect to a particular area of an Image ?
|
| 28.2 How
do I apply Transform when an event is occurred ?
|
| 28.3 In
what way CombinedGeometry is used ?
|
28.1 How do I apply BitmapEffect to a particular area of an Image ?
|
|
BitmapEffect can be applied to a particular area of an Image using the
"BitmapEffectInput" property of the "Image" class. "AreaToApplyEffect" property
of the BitmapEffectInput markup extension is used to specify the area and
"AreaToApplyEffectUnits" property is used to specify the units.
The following lines of code are used to apply BitmapEffect to a lower part of
the image.
|
[XAML]
<Image Source="pda.ico" Height="160" Width="160">
<Image.BitmapEffect>
<BevelBitmapEffect BevelWidth="10" EdgeProfile="BulgedUp"/>
</Image.BitmapEffect>
<Image.BitmapEffectInput>
<BitmapEffectInput AreaToApplyEffect="0,0.5,1,0.5"
AreaToApplyEffectUnits="RelativeToBoundingBox"/>
</Image.BitmapEffectInput>
</Image>
|
28.2 How do I apply Transform when an event is occurred ?
|
|
Any type of transform can be applied when an event has occurred.
The following lines of code apply a 'RotateTransform' when the mouse is moved
over the image.
|
[XAML]
<Image Source="pda.ico" MouseEnter="Image_MouseEnter"
MouseLeave="Image_MouseLeave">
<Image.RenderTransform>
<RotateTransform Angle="0" x:Name="ImageRot"/>
</Image.RenderTransform>
</Image>
|
|
|
[C#]
private void Image_MouseEnter(object sender, MouseEventArgs e)
{
ImageRot.Angle = 30;
}
private void Image_MouseLeave(object sender, MouseEventArgs e)
{
ImageRot.Angle = 0;
}
|
28.3 In what way CombinedGeometry is used ?
|
|
BitmapEffect can be applied to a particular area of an Image using the
"BitmapEffectInput" property of the "Image" class. "AreaToApplyEffect" property
of the BitmapEffectInput markup extension is used to specify the area and
"AreaToApplyEffectUnits" property is used to specify the units.
The following lines of code are used to apply BitmapEffect to a lower part of
the image.
|
[XAML]
<Image Source="pda.ico" Height="160" Width="160">
<Image.BitmapEffect>
<BevelBitmapEffect BevelWidth="10" EdgeProfile="BulgedUp"/>
</Image.BitmapEffect>
<Image.BitmapEffectInput>
<BitmapEffectInput AreaToApplyEffect="0,0.5,1,0.5"
AreaToApplyEffectUnits="RelativeToBoundingBox"/>
</Image.BitmapEffectInput>
</Image>
|
|