星期二, 4月 10, 2007

[WPF Concept] Immediate mode v.s. Retained Mode

看了WPF Graphics Rendering Overview這篇文章

才知道以往我在解釋WPF與SDK的Rendering異同之時 是可以用這二個詞的...

C P如下,或是直接參考原文





Retained Mode Graphics

One of the keys to understanding the role of the Visual object is to understand the difference between immediate mode and retained mode

graphics systems. A standard Win32 application based on GDI or GDI+

uses an immediate mode graphics system. This means that the application

is responsible for repainting the portion of the client area that is

invalidated, due to an action such as a window being resized, or an

object changing its visual appearance.

In contrast, WPF uses a retained mode system. This means application

objects that have a visual appearance define a set of serialized

drawing data. Once the drawing data is defined, the system is

responsible thereafter for responding to all repaint requests for

rendering the application objects. Even at run time, you can modify or

create application objects, and still rely on the system for responding

to paint requests. The power in a retained mode graphics system is that

drawing information is always persisted in a serialized state by the

application, but rendering responsibility left to the system.



Intelligent Redrawing

One
of the biggest benefits in using retained mode graphics is that WPF can
efficiently optimize what needs to be redrawn in the application. Even
if you have a complex scene with varying levels of opacity, you
generally do not need to write special-purpose code to optimize
redrawing. Compare this with Win32 programming in which you can spend a
great deal of effort in optimizing your application by minimizing the
amount of redrawing in the update region. See Redrawing in the Update Region for an example of the type of complexity involved in optimizing redrawing in Win32 applications.



Performance Profiling Tools for WPF



最近我們討論看WPF Performance問題 所以我上網找了一些東西



但是我這二個星期都會很忙~~ 所以先把找的東西作一個紀錄 等有時間在來看



主要遇到的問題是開二張5000x3000的Image 會吃Memory吃到600MB~~~



但似乎.Net 2.0並沒有這情況發生....





一篇WPF Render的文章 有提到一個Profling 的tool Performance Profiling Tools for WPF



這裡有一些WPF Performance的Suggestions 再來這裡有對
Graphics Rendering Tiers的介紹



對於上述Image的問題 可能可以用Virtualization Control來 例如VirtualizingPanel





大概先這樣



JimChang





powered by performancing firefox

星期一, 4月 09, 2007

How to simulation a KeyEventArgs



這裡有一篇在解怎麼用Enter作Focus Navigation



Sheva's TechSpace: Focus Navigation Using Enter Key





剛好解答了我們之前一直找不到怎麼用寫程式的方法Simulation一個keyEvent



解答如下



private void documentRoot_KeyDown(Object sender, KeyEventArgs e)

{

if (e.Key == Key.Return)

{

e.Handled = true;

KeyEventArgs args = new KeyEventArgs(

Keyboard
.PrimaryDevice, Keyboard.PrimaryDevice.ActiveSource, 0, Key.Tab);

args.RoutedEvent = Keyboard.KeyDownEvent;

InputManager.Current.ProcessInput(args);

//^^^^^^^^^^^^^^^^^^^^^^^^^^原來可以這樣用哦........

}

}








powered by performancing firefox

星期六, 4月 07, 2007

Fast Gaussian Blur Algorithm in C#

之前寫一個Blur的Filter 因為我不是DSP出身的人
所以其實是用很naive的方式來implement

可是後來玩了Sony Vegas的Gaussian Blur 覺得快的不可思議~~
其實到現在我還是不知發佈道他怎麼做的

在網路上看到一篇Fast Gaussian Blur的文章 先記錄下來
等我有空的時候再來試吧...