#眉標=Silverlight 3.0、、 #副標=Silverlight 3.0技術應用(1) #大標=影像處理與動畫效果基礎應用 #作者=文/圖 董大偉 ===<反灰>============= Dim wBitmap As New System.Windows.Media.Imaging.WriteableBitmap(…) ================ ===<反灰>============= WriteableBitmap(影像來源BitmapSource) WriteableBitmap(寬Int32,高Int32) WriteableBitmap(任何物件UIElement, Transform物件) ================ ===<反灰>============= Dim wBitmap As New System.Windows.Media.Imaging.WriteableBitmap(640,480) ================ ===<反灰>============= wBitmap.Pixels(y * wBitmap.PixelHeight + x) = pixel ================ ===<反灰>============= Dim brg As Byte() = New Byte(3) {} 'Blue, B brg(0) = CByte(color.B) 'Green, G brg(1) = CByte(color.G) 'Red, R brg(2) = CByte(color.R) '透明度 brg(3) = color.A Dim pixel As Integer = BitConverter.ToInt32(brg, 0) ================ ===<反灰>============= '取得影像 Dim wBitmap As New System.Windows.Media.Imaging.WriteableBitmap(Me.Image1, Nothing) ================ ===<反灰>============= '把記憶體中的Bitmap圖形套回控件 Me.Image1.Source = wBitmap ================ ===<反灰>============= Image1.Effect = New System.Windows.Media.Effects.BlurEffect With {.Radius = 20} ================ ===<反灰>============= Dim myEffect As New ShaderEffectLibrary.RippleEffect myEffect.Center = Center myEffect.Amplitude = Amplitude Me.Image1.Effect = myEffect ================ ===<反灰>============= Dim sb As New Storyboard Dim da As New DoubleAnimation da.From = 0 da.To = 350 da.Duration = New TimeSpan(0, 0, 3) Storyboard.SetTarget(da, ellipse2) Storyboard.SetTargetProperty(da, New PropertyPath(Canvas.TopProperty)) sb.Children.Add(da) sb.Begin() ================ ===<反灰>============= Dim sb As New Storyboard Dim da As New DoubleAnimation da.From = 0 da.To = 350 da.Duration = New TimeSpan(0, 0, 3) Storyboard.SetTarget(da, ellipse2) Storyboard.SetTargetProperty(da, New PropertyPath(Canvas.TopProperty)) sb.Children.Add(da) '設定EasingFunction da.EasingFunction = New BounceEase With {.Bounces = 10, .Bounciness = 2, .EasingMode = EasingMode.EaseOut} sb.Begin() ================