2011-09-19 32 views
0

在MonoTouch中做實時運動模糊的方法是什麼?如何在Monotouch中對UIImageView執行運動模糊效果?

我需要在UIImageView上應用運動模糊效果,以滾動慣性圖片庫時的強度和方向作爲參數,如Photoshop中所示。

我在CocoaTouch或CoreAnimation或iOS SDK中的任何位置找不到任何模糊或運動模糊濾鏡。

是否有一些可用於MonoTouch的2D效果庫,其中包含適用於iPhone的實時模糊濾鏡?

在此先感謝。

回答

0
+0

謝謝你,但是這預先計算。在我的情況下,我不知道什麼是我要運動模糊的東西的圖片內容,所以我不能使用它。我需要實時的運動模糊效果,例如閃存畫廊中使用的經典運動模糊效果:http://www.flashtory.com/flash-components/horizo​​ntal-scroller-motion-blur或http://www.flashtory.com/flash-components/vertical-scroller-motion-blur –

1

我找到了一個很好的開源庫做的UIImage很多效果:

https://github.com/gdawg/uiimage-dsp

它還使用Accelerated框架來加速iOS 4.0上的一些事情。

現在,只要有這樣一個MonoTouch的包裝...

+0

有人嗎? iPhone上有任何與MonoTouch兼容的2D效果庫嗎? –

0

如果你想使用模糊全世界展示蘋果在WWDC(雖然不是實時的!)我做了他們的UIImage類的本地端口。

獲取模糊是有點乏味,但可行的:

// Helper method to create an image snapshot of the view hierarchy 
UIImage SnapshotImageWithScale (UIView view, float scale) 
{ 
    UIGraphics.BeginImageContextWithOptions (view.Bounds.Size, false, scale); 
    view.DrawViewHierarchy (view.Bounds, true); 

    UIImage image = UIGraphics.GetImageFromCurrentImageContext(); 
    UIGraphics.EndImageContext(); 

    return image; 
} 

... 

// Create snapshot of the parent view controller (this can be the superview or anything else) 
UIImage snapshot = SnapshotImageWithScale (parentView, UIScreen.MainScreen.Scale); 

// Blur the snapshot with the specified radius and tint color 
snapshot = snapshot.ApplyBlur (6.0f, UIColor.FromWhiteAlpha (0.0f, 0.6f), 0.8f, null); 

// Create an UIImageView to display the blurred snapshot 
UIImageView snapshotView = new UIImageView { 
    Frame = new RectangleF (0, 0, View.Bounds.Width, View.Bounds.Height), 
    Image = snapshot, 
}; 
View.AddSubview (snapshotView);