colors.ppi 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1993,97 by the Free Pascal development team.
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. { COLORS.PPI }
  12. { GetBkColor , SetBkColor , GetColor , SetColor , GetMaxColor }
  13. function Convert(Color:longint):longint;
  14. var c,r,g,b:longint;
  15. begin
  16. if BytesPerPixel = 1 then
  17. begin
  18. if (Color and $FF000000)=0 then
  19. begin
  20. C:=Color and $FF;
  21. Convert:=(C shl 24) + (C shl 16) + (C shl 8) + C;
  22. end else
  23. begin
  24. SetRGBPalette(((Color and $FF000000) shr 24),
  25. ((Color and $00FF0000) shr 16),
  26. ((Color and $0000FF00) shr 8),
  27. (Color and $000000FF));
  28. C:=(Color and $FF000000);
  29. Convert:=(C shr 24) + (C shr 16) + (C shr 8) + C;
  30. end;
  31. end else
  32. begin
  33. R:=(Color and $00FF0000) shr (24-VESAInfo.rm_size);
  34. G:=(Color and $0000FF00) shr (16-VESAInfo.gm_size);
  35. B:=(Color and $000000FF) shr (8-VESAInfo.bm_size);
  36. C:=(R shl VESAInfo.rf_pos) or (G shl VESAInfo.gf_pos) or
  37. (B shl VESAInfo.bf_pos);
  38. Convert:=(C shl 16) or C;
  39. end;
  40. end;
  41. function GetColor : longint;
  42. begin
  43. _graphresult:=grOk;
  44. if not isgraphmode then
  45. begin
  46. _graphresult:=grNoInitGraph;
  47. exit;
  48. end;
  49. getcolor:=aktcolor;
  50. end;
  51. { ----------------------------------------------------------------------- }
  52. procedure SetColor(color : Longint);
  53. begin
  54. _graphresult:=grOk;
  55. if not isgraphmode then
  56. begin
  57. _graphresult:=grNoInitGraph;
  58. exit;
  59. end;
  60. aktcolor:=convert(Color);
  61. end;
  62. { ----------------------------------------------------------------------- }
  63. function GetBkColor : longint;
  64. begin
  65. _graphresult:=grOk;
  66. if not isgraphmode then
  67. begin
  68. _graphresult:=grNoInitGraph;
  69. exit;
  70. end;
  71. getbkcolor:=aktbackcolor;
  72. end;
  73. procedure SetBkColor(Color : longint);
  74. begin
  75. _graphresult:=grOk;
  76. if not isgraphmode then
  77. begin
  78. _graphresult:=grNoInitGraph;
  79. exit;
  80. end;
  81. aktbackcolor:=convert(Color);
  82. end;
  83. function GetMaxColor : longint;
  84. begin
  85. _graphresult:=grOk;
  86. if not isgraphmode then
  87. begin
  88. _graphresult:=grNoInitGraph;;
  89. exit;
  90. end;
  91. getmaxcolor:=(1 shl VESAInfo.BitsPerPixel)-1;
  92. end;
  93. {
  94. $Log$
  95. Revision 1.1 1998-03-25 11:18:42 root
  96. Initial revision
  97. Revision 1.3 1998/01/26 11:57:43 michael
  98. + Added log at the end
  99. Working file: rtl/dos/ppi/colors.ppi
  100. description:
  101. ----------------------------
  102. revision 1.2
  103. date: 1997/12/01 12:21:28; author: michael; state: Exp; lines: +13 -0
  104. + added copyright reference in header.
  105. ----------------------------
  106. revision 1.1
  107. date: 1997/11/27 08:33:51; author: michael; state: Exp;
  108. Initial revision
  109. ----------------------------
  110. revision 1.1.1.1
  111. date: 1997/11/27 08:33:51; author: michael; state: Exp; lines: +0 -0
  112. FPC RTL CVS start
  113. =============================================================================
  114. }