capi_surface.inc 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. {
  2. Free Pascal port of the OpenPTC C++ library.
  3. Copyright (C) 2001-2010 Nikolay Nikolov ([email protected])
  4. Original C++ version by Glenn Fiedler ([email protected])
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version
  9. with the following modification:
  10. As a special exception, the copyright holders of this library give you
  11. permission to link this library with independent modules to produce an
  12. executable, regardless of the license terms of these independent modules,and
  13. to copy and distribute the resulting executable under terms of your choice,
  14. provided that you also meet, for each linked independent module, the terms
  15. and conditions of the license of that module. An independent module is a
  16. module which is not derived from or based on this library. If you modify
  17. this library, you may extend this exception to your version of the library,
  18. but you are not obligated to do so. If you do not wish to do so, delete this
  19. exception statement from your version.
  20. This library is distributed in the hope that it will be useful,
  21. but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  23. Lesser General Public License for more details.
  24. You should have received a copy of the GNU Lesser General Public
  25. License along with this library; if not, write to the Free Software
  26. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  27. }
  28. function ptc_surface_create(width, height: Integer; format: TPTC_FORMAT): TPTC_SURFACE;
  29. begin
  30. try
  31. ptc_surface_create := TPTC_SURFACE(TPTCSurface.Create(width, height, TPTCFormat(format)));
  32. except
  33. on error: TPTCError do
  34. begin
  35. ptc_exception_handle(error);
  36. ptc_surface_create := nil;
  37. end;
  38. end;
  39. end;
  40. procedure ptc_surface_destroy(obj: TPTC_SURFACE);
  41. begin
  42. if obj = nil then
  43. exit;
  44. try
  45. TPTCBaseSurface(obj).Destroy;
  46. except
  47. on error: TPTCError do
  48. ptc_exception_handle(error);
  49. end;
  50. end;
  51. procedure ptc_surface_copy(obj: TPTC_SURFACE; surface: TPTC_SURFACE);
  52. begin
  53. try
  54. TPTCBaseSurface(obj).copy(TPTCBaseSurface(surface));
  55. except
  56. on error: TPTCError do
  57. ptc_exception_handle(error);
  58. end;
  59. end;
  60. procedure ptc_surface_copy_area(obj: TPTC_SURFACE; surface: TPTC_SURFACE; source, destination: TPTC_AREA);
  61. begin
  62. try
  63. TPTCBaseSurface(obj).copy(TPTCBaseSurface(surface), TPTCArea(source), TPTCArea(destination));
  64. except
  65. on error: TPTCError do
  66. ptc_exception_handle(error);
  67. end;
  68. end;
  69. function ptc_surface_lock(obj: TPTC_SURFACE): Pointer;
  70. begin
  71. try
  72. ptc_surface_lock := TPTCBaseSurface(obj).lock;
  73. except
  74. on error: TPTCError do
  75. begin
  76. ptc_exception_handle(error);
  77. ptc_surface_lock := nil;
  78. end;
  79. end;
  80. end;
  81. procedure ptc_surface_unlock(obj: TPTC_SURFACE);
  82. begin
  83. try
  84. TPTCBaseSurface(obj).unlock;
  85. except
  86. on error: TPTCError do
  87. ptc_exception_handle(error);
  88. end;
  89. end;
  90. procedure ptc_surface_load(obj: TPTC_SURFACE; pixels: Pointer; width, height, pitch: Integer; format: TPTC_FORMAT; palette: TPTC_PALETTE);
  91. begin
  92. try
  93. TPTCBaseSurface(obj).load(pixels, width, height, pitch, TPTCFormat(format), TPTCPalette(palette));
  94. except
  95. on error: TPTCError do
  96. ptc_exception_handle(error);
  97. end;
  98. end;
  99. procedure ptc_surface_load_area(obj: TPTC_SURFACE; pixels: Pointer; width, height, pitch: Integer; format: TPTC_FORMAT; palette: TPTC_PALETTE; source, destination: TPTC_AREA);
  100. begin
  101. try
  102. TPTCBaseSurface(obj).load(pixels, width, height, pitch, TPTCFormat(format), TPTCPalette(palette), TPTCArea(source), TPTCArea(destination));
  103. except
  104. on error: TPTCError do
  105. ptc_exception_handle(error);
  106. end;
  107. end;
  108. procedure ptc_surface_save(obj: TPTC_SURFACE; pixels: Pointer; width, height, pitch: Integer; format: TPTC_FORMAT; palette: TPTC_PALETTE);
  109. begin
  110. try
  111. TPTCBaseSurface(obj).save(pixels, width, height, pitch, TPTCFormat(format), TPTCPalette(palette));
  112. except
  113. on error: TPTCError do
  114. ptc_exception_handle(error);
  115. end;
  116. end;
  117. procedure ptc_surface_save_area(obj: TPTC_SURFACE; pixels: Pointer; width, height, pitch: Integer; format: TPTC_FORMAT; palette: TPTC_PALETTE; source, destination: TPTC_AREA);
  118. begin
  119. try
  120. TPTCBaseSurface(obj).save(pixels, width, height, pitch, TPTCFormat(format), TPTCPalette(palette), TPTCArea(source), TPTCArea(destination));
  121. except
  122. on error: TPTCError do
  123. ptc_exception_handle(error);
  124. end;
  125. end;
  126. procedure ptc_surface_clear(obj: TPTC_SURFACE);
  127. begin
  128. try
  129. TPTCBaseSurface(obj).clear;
  130. except
  131. on error: TPTCError do
  132. ptc_exception_handle(error);
  133. end;
  134. end;
  135. procedure ptc_surface_clear_color(obj: TPTC_SURFACE; color: TPTC_COLOR);
  136. begin
  137. try
  138. TPTCBaseSurface(obj).clear(TPTCColor(color));
  139. except
  140. on error: TPTCError do
  141. ptc_exception_handle(error);
  142. end;
  143. end;
  144. procedure ptc_surface_clear_color_area(obj: TPTC_SURFACE; color: TPTC_COLOR; area: TPTC_AREA);
  145. begin
  146. try
  147. TPTCBaseSurface(obj).clear(TPTCColor(color), TPTCArea(area));
  148. except
  149. on error: TPTCError do
  150. ptc_exception_handle(error);
  151. end;
  152. end;
  153. procedure ptc_surface_palette_set(obj: TPTC_SURFACE; palette: TPTC_PALETTE);
  154. begin
  155. try
  156. TPTCBaseSurface(obj).palette(TPTCPalette(palette));
  157. except
  158. on error: TPTCError do
  159. ptc_exception_handle(error);
  160. end;
  161. end;
  162. function ptc_surface_palette_get(obj: TPTC_SURFACE): TPTC_PALETTE;
  163. begin
  164. try
  165. ptc_surface_palette_get := TPTC_PALETTE(TPTCBaseSurface(obj).palette);
  166. except
  167. on error: TPTCError do
  168. begin
  169. ptc_exception_handle(error);
  170. ptc_surface_palette_get := nil;
  171. end;
  172. end;
  173. end;
  174. procedure ptc_surface_clip_set(obj: TPTC_SURFACE; area: TPTC_AREA);
  175. begin
  176. try
  177. TPTCBaseSurface(obj).clip(TPTCArea(area));
  178. except
  179. on error: TPTCError do
  180. ptc_exception_handle(error);
  181. end;
  182. end;
  183. function ptc_surface_width(obj: TPTC_SURFACE): Integer;
  184. begin
  185. try
  186. ptc_surface_width := TPTCBaseSurface(obj).width;
  187. except
  188. on error: TPTCError do
  189. begin
  190. ptc_exception_handle(error);
  191. ptc_surface_width := 0;
  192. end;
  193. end;
  194. end;
  195. function ptc_surface_height(obj: TPTC_SURFACE): Integer;
  196. begin
  197. try
  198. ptc_surface_height := TPTCBaseSurface(obj).height;
  199. except
  200. on error: TPTCError do
  201. begin
  202. ptc_exception_handle(error);
  203. ptc_surface_height := 0;
  204. end;
  205. end;
  206. end;
  207. function ptc_surface_pitch(obj: TPTC_SURFACE): Integer;
  208. begin
  209. try
  210. ptc_surface_pitch := TPTCBaseSurface(obj).pitch;
  211. except
  212. on error: TPTCError do
  213. begin
  214. ptc_exception_handle(error);
  215. ptc_surface_pitch := 0;
  216. end;
  217. end;
  218. end;
  219. function ptc_surface_area(obj: TPTC_SURFACE): TPTC_AREA;
  220. begin
  221. try
  222. ptc_surface_area := TPTC_AREA(TPTCBaseSurface(obj).area);
  223. except
  224. on error: TPTCError do
  225. begin
  226. ptc_exception_handle(error);
  227. ptc_surface_area := nil;
  228. end;
  229. end;
  230. end;
  231. function ptc_surface_clip(obj: TPTC_SURFACE): TPTC_AREA;
  232. begin
  233. try
  234. ptc_surface_clip := TPTC_AREA(TPTCBaseSurface(obj).clip);
  235. except
  236. on error: TPTCError do
  237. begin
  238. ptc_exception_handle(error);
  239. ptc_surface_clip := nil;
  240. end;
  241. end;
  242. end;
  243. function ptc_surface_format(obj: TPTC_SURFACE): TPTC_FORMAT;
  244. begin
  245. try
  246. ptc_surface_format := TPTC_FORMAT(TPTCBaseSurface(obj).format);
  247. except
  248. on error: TPTCError do
  249. begin
  250. ptc_exception_handle(error);
  251. ptc_surface_format := nil;
  252. end;
  253. end;
  254. end;
  255. function ptc_surface_option(obj: TPTC_SURFACE; _option: string): Boolean;
  256. begin
  257. try
  258. ptc_surface_option := TPTCBaseSurface(obj).option(_option);
  259. except
  260. on error: TPTCError do
  261. begin
  262. ptc_exception_handle(error);
  263. ptc_surface_option := False;
  264. end;
  265. end;
  266. end;