con_info.pp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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(format: IPTCFormat);
  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: IPTCConsole;
  30. begin
  31. try
  32. try
  33. Writeln('[ptcpas version]');
  34. { print ptcpas version string define }
  35. Writeln(PTCPAS_VERSION);
  36. Writeln;
  37. { create console }
  38. console := TPTCConsoleFactory.CreateNew;
  39. { open the console }
  40. console.open('Info example');
  41. { print console data }
  42. Writeln('[console data]');
  43. Writeln('name = ', console.name);
  44. Writeln('title = ', console.title);
  45. Writeln('width = ', console.width);
  46. Writeln('height = ', console.height);
  47. Writeln('pages = ', console.pages);
  48. Writeln('pitch = ', console.pitch);
  49. Write('format = ');
  50. print(console.format);
  51. Writeln;
  52. Writeln;
  53. { print console information }
  54. Writeln('[console information]');
  55. Writeln(console.information);
  56. finally
  57. if Assigned(console) then
  58. console.close;
  59. end;
  60. except
  61. on error: TPTCError do
  62. { report error }
  63. error.report;
  64. end;
  65. end.