1. 程式人生 > >C#GDI+圖元組態和IronPython指令碼應用之LED影像系統

C#GDI+圖元組態和IronPython指令碼應用之LED影像系統

這段時間一直進行LED影像系統緊張的開發工作,目前成績還是非常"斐然"的,終於有了一點透氣的機會:)

該系統從技術角度來說包括三點:一是圖元組態(這點和普通的組態軟體沒有什麼區別,由於面對的使用者技術層次相對較低,所以把原來嵌入式組態修改屬性的屬性列表,修改為屬性面板,以直觀的方式修改元件屬性);二是圖片特效製作,圖片特效主要是淡入淡出、旋轉、晶格、移動、放縮等等;三是IronPython指令碼,該指令碼為C#語言開發,是作者為了證明C#效率不行而開發的程式碼,沒有想到事與願違,效率反而出奇的好,被微軟收編後,推出了開源的IronPython指令碼,該指令碼最大的特點就是和C#無縫整合,可以引用C#所有的庫,就如C#本身引用一樣,此外還能直接引用C#自己開發的庫(其實和系統庫的引用沒有本質區別),本系統就採用了該指令碼進行特效處理,這樣系統的特效完全實現了定製,並且介面豐富,應對能力極強。

這是指令碼特效編輯器(下圖)

這是特效具體的一個指令碼程式碼:

def process():
if this.RunState == 0:
Init()
this.RunState
=1
this.Image
= this.Data.BmpImage

this.Total
=80/ (this.Rate +1)
this.Current
= this.Current +1
dw
=BitmapProcess.GetDiagonalWidth(this.Image.Width,this.Image.Height)
ds
= (float)(dw) / this.Total
width
= ds * (this.Current + this.Total /2)

bmp
= BitmapProcess.OpenBevel(this.Image, Orientation_Bevel.TopLeft, width, Color.Black)
bmp
= BitmapProcess.OpenBevel(bmp , Orientation_Bevel.BottomRight, width, Color.Black)
bmp
= BitmapProcess.OpenBevel(bmp , Orientation_Bevel.TopRight, width, Color.Black)
bmp
= BitmapProcess.OpenBevel(bmp , Orientation_Bevel.BottomLeft, width, Color.Black)
this.Data.BmpImage
= bmp

if width <= dw:
this.Current
= this.Total +1def Init():
import clr
clr.AddReferenceByPartialName(
"System.Windows.Forms")
clr.AddReferenceByPartialName(
"System.Drawing")
clr.AddReferenceToFile(
"BitmapProcess.dll")

from System.Windows.Forms import*from System.Drawing import*from LBxSoft.Drawing import*try:
process()
except:
print"Error"

Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1627782