BitmapProgram.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using HNWD.Pregrant.Common;
  6. using HNWD.Pregrant.DataAccess;
  7. using HNWD.Pregrant.Model;
  8. using System.Drawing;
  9. using System.IO;
  10. namespace HNWD.LatticeScreen.Server
  11. {
  12. internal class BitmapProgram : ProgramBase
  13. {
  14. private char[] pdata;
  15. public BitmapProgram(LedLatticeScreen ledLatticeScreen)
  16. : base()
  17. {
  18. this.ledLatticeScreen = ledLatticeScreen;
  19. }
  20. public override void SetEntity(Pregrant.Model.WD_ProgramInfo wd_ProgramInfo)
  21. {
  22. base.SetEntity(wd_ProgramInfo);
  23. byte[] byteArray = Convert.FromBase64String(GZipCompress.Decompress(this.wd_ProgramInfo.PROGRAM_MATRIX));
  24. pdata = new char[byteArray.LongLength];
  25. for(long i = 0;i<byteArray.LongLength;i++)
  26. {
  27. pdata[i] = (char)byteArray[i];
  28. }
  29. }
  30. public override void PlayWithErase()
  31. {
  32. this.GetBitmapAlignMode(this.wd_ProgramInfo.PROGRAM_ALIGN);
  33. LedControl.JHErase(this.ledLatticeScreen.hdl);
  34. int length = 1200;
  35. long ntimes = pdata.LongLength % length == 0 ? pdata.LongLength / length : pdata.LongLength / length + 1;
  36. int x = 0;
  37. while (x < ntimes)
  38. {
  39. tagBitmapSource tagBitmap = new tagBitmapSource();
  40. tagBitmap.pdata = pdata.Skip(length * x).Take(length).ToArray();
  41. tagBitmap.size = (ulong)tagBitmap.pdata.LongLength;
  42. tagBitmap.type = 0;
  43. tagBitmap.version = 0;
  44. LedControl.JHDrawBitmap(this.ledLatticeScreen.hdl, Convert.ToInt16(this.wd_ProgramInfo.PROGRAM_X), Convert.ToInt16(this.wd_ProgramInfo.PROGRAM_Y), Convert.ToUInt16(this.wd_ProgramInfo.PROGRAM_WIDTH), Convert.ToUInt16(this.wd_ProgramInfo.PROGRAM_HEIGHT), this.AlignMode, tagBitmap);
  45. x++;
  46. }
  47. }
  48. public override void PlayWithoutErase()
  49. {
  50. this.GetBitmapAlignMode(this.wd_ProgramInfo.PROGRAM_ALIGN);
  51. int length = 1200;
  52. long ntimes = pdata.LongLength % length == 0 ? pdata.LongLength / length : pdata.LongLength / length + 1;
  53. int x = 0;
  54. while (x < ntimes)
  55. {
  56. tagBitmapSource tagBitmap = new tagBitmapSource();
  57. tagBitmap.pdata = pdata.Skip(length * x ).Take(length).ToArray();
  58. tagBitmap.size = (ulong)tagBitmap.pdata.LongLength;
  59. tagBitmap.type = 0;
  60. tagBitmap.version = 0;
  61. LedControl.JHDrawBitmap(this.ledLatticeScreen.hdl, Convert.ToInt16(this.wd_ProgramInfo.PROGRAM_X), Convert.ToInt16(this.wd_ProgramInfo.PROGRAM_Y), Convert.ToUInt16(this.wd_ProgramInfo.PROGRAM_WIDTH), Convert.ToUInt16(this.wd_ProgramInfo.PROGRAM_HEIGHT), this.AlignMode, tagBitmap);
  62. x++;
  63. }
  64. }
  65. }
  66. }