叶帆

C#GDI+图元组态和IronPython脚本应用之LED影像系统

0
阅读(2173)

 这段时间一直进行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 + 1
def 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"