con_info.pp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. {
  2. Ported to FPC by Nikolay Nikolov ([email protected])
  3. }
  4. {
  5. Info example for OpenPTC 1.0 C++ Implementation
  6. Copyright (c) Glenn Fiedler ([email protected])
  7. This source code is in the public domain
  8. }
  9. Program InfoExample;
  10. {$MODE objfpc}
  11. Uses
  12. ptc;
  13. Procedure print(Const format : TPTCFormat);
  14. Begin
  15. { check format type }
  16. If format.direct Then
  17. { check alpha }
  18. If format.a = 0 Then
  19. { direct color format without alpha }
  20. Write('Format(', format.bits:2, ',$', HexStr(format.r, 8), ',$', HexStr(format.g, 8), ',$', HexStr(format.b, 8), ')')
  21. Else
  22. { direct color format with alpha }
  23. Write('Format(', format.bits:2, ',$', HexStr(format.r, 8), ',$', HexStr(format.g, 8), ',$', HexStr(format.b, 8), ',$', HexStr(format.a, 8), ')')
  24. Else
  25. { indexed color format }
  26. Write('Format(', format.bits:2, ')');
  27. End;
  28. Var
  29. console : TPTCConsole;
  30. Begin
  31. console := Nil;
  32. Try
  33. Try
  34. Writeln('[ptc version]');
  35. { print ptc version string define }
  36. Writeln(PTC_VERSION);
  37. Writeln;
  38. { create console }
  39. console := TPTCConsole.Create;
  40. { open the console }
  41. console.open('Info example');
  42. { print console data }
  43. Writeln('[console data]');
  44. Writeln('name = ', console.name);
  45. Writeln('title = ', console.title);
  46. Writeln('width = ', console.width);
  47. Writeln('height = ', console.height);
  48. Writeln('pages = ', console.pages);
  49. Writeln('pitch = ', console.pitch);
  50. Write('format = ');
  51. print(console.format);
  52. Writeln;
  53. Writeln;
  54. { print console information }
  55. Writeln('[console information]');
  56. Writeln(console.information);
  57. Finally
  58. console.close;
  59. console.Free;
  60. End;
  61. Except
  62. On error : TPTCError Do
  63. { report error }
  64. error.report;
  65. End;
  66. End.