p_g.inc 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074
  1. {
  2. Free Pascal port of the Hermes C library.
  3. Copyright (C) 2001-2003 Nikolay Nikolov ([email protected])
  4. Original C version by Christian Nentwich ([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. {
  29. Generic format conversion routines for the HERMES library
  30. Copyright (c) 1998 Christian Nentwich ([email protected])
  31. This source code is licensed under the GNU LGPL
  32. Please refer to the file COPYING.LIB contained in the distribution for
  33. licensing conditions
  34. }
  35. procedure ConvertP_Generic32_Generic32(iface: PHermesConverterInterface); cdecl;
  36. var
  37. s_pixel, r, g, b: Uint32;
  38. count: DWord;
  39. source, dest: PUint8;
  40. begin
  41. source := iface^.s_pixels; dest := iface^.d_pixels;
  42. repeat
  43. count := iface^.s_width;
  44. repeat
  45. s_pixel := PUint32(source)^;
  46. r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
  47. iface^.mask_r;
  48. g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
  49. iface^.mask_g;
  50. b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
  51. iface^.mask_b;
  52. PUint32(dest)^ := r or g or b;
  53. Inc(source, 4);
  54. Inc(dest, 4);
  55. Dec(count);
  56. until count = 0;
  57. Inc(source, iface^.s_add);
  58. Inc(dest, iface^.d_add);
  59. Dec(iface^.s_height);
  60. until iface^.s_height = 0;
  61. end;
  62. procedure ConvertP_Generic32_Generic24(iface: PHermesConverterInterface); cdecl;
  63. var
  64. s_pixel, r, g, b: Uint32;
  65. d_ptr: PUint8;
  66. count: DWord;
  67. source, dest: PUint8;
  68. begin
  69. d_ptr := PUint8(@s_pixel) + (R_32 - R_24);
  70. source := iface^.s_pixels; dest := iface^.d_pixels;
  71. repeat
  72. count := iface^.s_width;
  73. repeat
  74. s_pixel := PUint32(source)^;
  75. r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
  76. iface^.mask_r;
  77. g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
  78. iface^.mask_g;
  79. b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
  80. iface^.mask_b;
  81. s_pixel := r or g or b;
  82. (dest+0)^ := (d_ptr+0)^;
  83. (dest+1)^ := (d_ptr+1)^;
  84. (dest+2)^ := (d_ptr+2)^;
  85. Inc(source, 4);
  86. Inc(dest, 3);
  87. Dec(count);
  88. until count = 0;
  89. Inc(source, iface^.s_add);
  90. Inc(dest, iface^.d_add);
  91. Dec(iface^.s_height);
  92. until iface^.s_height = 0;
  93. end;
  94. procedure ConvertP_Generic32_Generic16(iface: PHermesConverterInterface); cdecl;
  95. var
  96. s_pixel, r, g, b: Uint32;
  97. count: DWord;
  98. source, dest: PUint8;
  99. begin
  100. source := iface^.s_pixels; dest := iface^.d_pixels;
  101. repeat
  102. count := iface^.s_width shr 1;
  103. if count <> 0 then
  104. repeat
  105. r := (((PUint32(source)^) shr iface^.info.r_right) shl iface^.info.r_left) and
  106. iface^.mask_r;
  107. g := (((PUint32(source)^) shr iface^.info.g_right) shl iface^.info.g_left) and
  108. iface^.mask_g;
  109. b := (((PUint32(source)^) shr iface^.info.b_right) shl iface^.info.b_left) and
  110. iface^.mask_b;
  111. s_pixel := (r or g or b) shl DWORD_SMALLINT0_SHL;
  112. r := ((((PUint32(source)+1)^) shr iface^.info.r_right) shl iface^.info.r_left) and
  113. iface^.mask_r;
  114. g := ((((PUint32(source)+1)^) shr iface^.info.g_right) shl iface^.info.g_left) and
  115. iface^.mask_g;
  116. b := ((((PUint32(source)+1)^) shr iface^.info.b_right) shl iface^.info.b_left) and
  117. iface^.mask_b;
  118. s_pixel := s_pixel or ((r or g or b) shl DWORD_SMALLINT1_SHL);
  119. PUint32(dest)^ := s_pixel;
  120. Inc(source, 8);
  121. Inc(dest, 4);
  122. Dec(count);
  123. until count = 0;
  124. { Trailing pixel }
  125. if (iface^.s_width and 1) <> 0 then
  126. begin
  127. r := (((PUint32(source)^) shr iface^.info.r_right) shl iface^.info.r_left) and
  128. iface^.mask_r;
  129. g := (((PUint32(source)^) shr iface^.info.g_right) shl iface^.info.g_left) and
  130. iface^.mask_g;
  131. b := (((PUint32(source)^) shr iface^.info.b_right) shl iface^.info.b_left) and
  132. iface^.mask_b;
  133. PUint16(dest)^ := r or g or b;
  134. Inc(dest, 2);
  135. Inc(source, 4);
  136. end;
  137. Inc(source, iface^.s_add);
  138. Inc(dest, iface^.d_add);
  139. Dec(iface^.s_height);
  140. until iface^.s_height = 0;
  141. end;
  142. procedure ConvertP_Generic32_Generic8(iface: PHermesConverterInterface); cdecl;
  143. var
  144. s_pixel, r, g, b: Uint32;
  145. count: DWord;
  146. source, dest: PUint8;
  147. begin
  148. source := iface^.s_pixels; dest := iface^.d_pixels;
  149. repeat
  150. count := iface^.s_width;
  151. repeat
  152. s_pixel := PUint32(source)^;
  153. r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
  154. iface^.mask_r;
  155. g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
  156. iface^.mask_g;
  157. b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
  158. iface^.mask_b;
  159. dest^ := r or g or b;
  160. Inc(source, 4);
  161. Inc(dest);
  162. Dec(count);
  163. until count = 0;
  164. Inc(source, iface^.s_add);
  165. Inc(dest, iface^.d_add);
  166. Dec(iface^.s_height);
  167. until iface^.s_height = 0;
  168. end;
  169. procedure ConvertP_Generic24_Generic32(iface: PHermesConverterInterface); cdecl;
  170. var
  171. s_pixel, r, g, b: Uint32;
  172. count: DWord;
  173. source, dest: PUint8;
  174. begin
  175. source := iface^.s_pixels; dest := iface^.d_pixels;
  176. repeat
  177. count := iface^.s_width;
  178. repeat
  179. s_pixel := (((source+R_24)^) shl 16) or
  180. (((source+G_24)^) shl 8) or
  181. ((source+B_24)^);
  182. r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
  183. iface^.mask_r;
  184. g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
  185. iface^.mask_g;
  186. b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
  187. iface^.mask_b;
  188. PUint32(dest)^ := r or g or b;
  189. Inc(source, 3);
  190. Inc(dest, 4);
  191. Dec(count);
  192. until count = 0;
  193. Inc(source, iface^.s_add);
  194. Inc(dest, iface^.d_add);
  195. Dec(iface^.s_height);
  196. until iface^.s_height = 0;
  197. end;
  198. procedure ConvertP_Generic24_Generic24(iface: PHermesConverterInterface); cdecl;
  199. var
  200. s_pixel, r, g, b: Uint32;
  201. d_ptr: PUint8;
  202. count: DWord;
  203. source, dest: PUint8;
  204. begin
  205. d_ptr := PUint8(@s_pixel) + (R_32 - R_24);
  206. source := iface^.s_pixels; dest := iface^.d_pixels;
  207. repeat
  208. count := iface^.s_width;
  209. repeat
  210. s_pixel := (((source+R_24)^) shl 16) or
  211. (((source+G_24)^) shl 8) or
  212. ((source+B_24)^);
  213. r := ((s_pixel shl iface^.info.r_left) shr iface^.info.r_right) and
  214. iface^.mask_r;
  215. g := ((s_pixel shl iface^.info.g_left) shr iface^.info.g_right) and
  216. iface^.mask_g;
  217. b := ((s_pixel shl iface^.info.b_left) shr iface^.info.b_right) and
  218. iface^.mask_b;
  219. s_pixel := r or g or b;
  220. (dest + 0)^ := (d_ptr + 0)^;
  221. (dest + 1)^ := (d_ptr + 1)^;
  222. (dest + 2)^ := (d_ptr + 2)^;
  223. Inc(source, 3);
  224. Inc(dest, 3);
  225. Dec(count);
  226. until count = 0;
  227. Inc(source, iface^.s_add);
  228. Inc(dest, iface^.d_add);
  229. Dec(iface^.s_height);
  230. until iface^.s_height = 0;
  231. end;
  232. procedure ConvertP_Generic24_Generic16(iface: PHermesConverterInterface); cdecl;
  233. var
  234. s_pixel, r, g, b: Uint32;
  235. count: DWord;
  236. source, dest: PUint8;
  237. begin
  238. source := iface^.s_pixels; dest := iface^.d_pixels;
  239. repeat
  240. count := iface^.s_width;
  241. repeat
  242. s_pixel := (((source+R_24)^) shl 16) or
  243. (((source+G_24)^) shl 8) or
  244. ((source+B_24)^);
  245. r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
  246. iface^.mask_r;
  247. g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
  248. iface^.mask_g;
  249. b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
  250. iface^.mask_b;
  251. PUint16(dest)^ := r or g or b;
  252. Inc(source, 3);
  253. Inc(dest, 2);
  254. Dec(count);
  255. until count = 0;
  256. Inc(source, iface^.s_add);
  257. Inc(dest, iface^.d_add);
  258. Dec(iface^.s_height);
  259. until iface^.s_height = 0;
  260. end;
  261. procedure ConvertP_Generic24_Generic8(iface: PHermesConverterInterface); cdecl;
  262. var
  263. s_pixel, r, g, b: Uint32;
  264. count: DWord;
  265. source, dest: PUint8;
  266. begin
  267. source := iface^.s_pixels; dest := iface^.d_pixels;
  268. repeat
  269. count := iface^.s_width;
  270. repeat
  271. s_pixel := (((source+R_24)^) shl 16) or
  272. (((source+G_24)^) shl 8) or
  273. ((source+B_24)^);
  274. r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
  275. iface^.mask_r;
  276. g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
  277. iface^.mask_g;
  278. b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
  279. iface^.mask_b;
  280. dest^ := r or g or b;
  281. Inc(source, 3);
  282. Inc(dest);
  283. Dec(count);
  284. until count = 0;
  285. Inc(source, iface^.s_add);
  286. Inc(dest, iface^.d_add);
  287. Dec(iface^.s_height);
  288. until iface^.s_height = 0;
  289. end;
  290. procedure ConvertP_Generic16_Generic32(iface: PHermesConverterInterface); cdecl;
  291. var
  292. s_pixel, r, g, b: Uint32;
  293. count: DWord;
  294. source, dest: PUint8;
  295. begin
  296. source := iface^.s_pixels; dest := iface^.d_pixels;
  297. repeat
  298. count := iface^.s_width;
  299. repeat
  300. s_pixel := PUint16(source)^;
  301. r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
  302. iface^.mask_r;
  303. g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
  304. iface^.mask_g;
  305. b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
  306. iface^.mask_b;
  307. PUint32(dest)^ := r or g or b;
  308. Inc(source, 2);
  309. Inc(dest, 4);
  310. Dec(count);
  311. until count = 0;
  312. Inc(source, iface^.s_add);
  313. Inc(dest, iface^.d_add);
  314. Dec(iface^.s_height);
  315. until iface^.s_height = 0;
  316. end;
  317. procedure ConvertP_Generic16_Generic24(iface: PHermesConverterInterface); cdecl;
  318. var
  319. s_pixel, r, g, b: Uint32;
  320. d_ptr: PUint8;
  321. count: DWord;
  322. source, dest: PUint8;
  323. begin
  324. d_ptr := PUint8(@s_pixel) + (R_32 - R_24);
  325. source := iface^.s_pixels; dest := iface^.d_pixels;
  326. repeat
  327. count := iface^.s_width;
  328. repeat
  329. s_pixel := PUint16(source)^;
  330. r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
  331. iface^.mask_r;
  332. g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
  333. iface^.mask_g;
  334. b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
  335. iface^.mask_b;
  336. s_pixel := r or g or b;
  337. (dest + 0)^ := (d_ptr + 0)^;
  338. (dest + 1)^ := (d_ptr + 1)^;
  339. (dest + 2)^ := (d_ptr + 2)^;
  340. Inc(source, 2);
  341. Inc(dest, 3);
  342. Dec(count);
  343. until count = 0;
  344. Inc(source, iface^.s_add);
  345. Inc(dest, iface^.d_add);
  346. Dec(iface^.s_height);
  347. until iface^.s_height = 0;
  348. end;
  349. procedure ConvertP_Generic16_Generic16(iface: PHermesConverterInterface); cdecl;
  350. var
  351. s_pixel, r, g, b: Uint32;
  352. count: DWord;
  353. source, dest: PUint8;
  354. begin
  355. source := iface^.s_pixels; dest := iface^.d_pixels;
  356. repeat
  357. count := iface^.s_width;
  358. repeat
  359. s_pixel := PUint16(source)^;
  360. r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
  361. iface^.mask_r;
  362. g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
  363. iface^.mask_g;
  364. b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
  365. iface^.mask_b;
  366. PUint16(dest)^ := r or g or b;
  367. Inc(source, 2);
  368. Inc(dest, 2);
  369. Dec(count);
  370. until count = 0;
  371. Inc(source, iface^.s_add);
  372. Inc(dest, iface^.d_add);
  373. Dec(iface^.s_height);
  374. until iface^.s_height = 0;
  375. end;
  376. procedure ConvertP_Generic16_Generic8(iface: PHermesConverterInterface); cdecl;
  377. var
  378. s_pixel, r, g, b: Uint32;
  379. count: DWord;
  380. source, dest: PUint8;
  381. begin
  382. source := iface^.s_pixels; dest := iface^.d_pixels;
  383. repeat
  384. count := iface^.s_width;
  385. repeat
  386. s_pixel := PUint16(source)^;
  387. r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
  388. iface^.mask_r;
  389. g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
  390. iface^.mask_g;
  391. b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
  392. iface^.mask_b;
  393. dest^ := r or g or b;
  394. Inc(source, 2);
  395. Inc(dest);
  396. Dec(count);
  397. until count = 0;
  398. Inc(source, iface^.s_add);
  399. Inc(dest, iface^.d_add);
  400. Dec(iface^.s_height);
  401. until iface^.s_height = 0;
  402. end;
  403. procedure ConvertP_Generic8_Generic32(iface: PHermesConverterInterface); cdecl;
  404. begin
  405. {todo}
  406. end;
  407. procedure ConvertP_Generic8_Generic24(iface: PHermesConverterInterface); cdecl;
  408. begin
  409. {todo}
  410. end;
  411. procedure ConvertP_Generic8_Generic16(iface: PHermesConverterInterface); cdecl;
  412. begin
  413. {todo}
  414. end;
  415. procedure ConvertP_Generic8_Generic8(iface: PHermesConverterInterface); cdecl;
  416. begin
  417. {todo}
  418. end;
  419. { -------------------------------------------------------------------------
  420. STRETCH CONVERTERS
  421. ------------------------------------------------------------------------- }
  422. procedure ConvertP_Generic32_Generic32_S(iface: PHermesConverterInterface); cdecl;
  423. var
  424. s_pixel, r, g, b: Uint32;
  425. count: DWord;
  426. source, dest: PUint8;
  427. dx, dy, x, y: DWord;
  428. begin
  429. source := iface^.s_pixels;
  430. dest := iface^.d_pixels;
  431. dy := (iface^.s_height shl 16) div iface^.d_height;
  432. dx := (iface^.s_width shl 16) div iface^.d_width;
  433. y := 0;
  434. repeat
  435. count := iface^.d_width;
  436. x := 0;
  437. repeat
  438. s_pixel := (PUint32(source)+(x shr 16))^;
  439. r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
  440. iface^.mask_r;
  441. g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
  442. iface^.mask_g;
  443. b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
  444. iface^.mask_b;
  445. PUint32(dest)^ := r or g or b;
  446. Inc(x, dx);
  447. Inc(dest, 4);
  448. Dec(count);
  449. until count = 0;
  450. Inc(dest, iface^.d_add);
  451. Inc(y, dy);
  452. Inc(source, (y shr 16)*DWord(iface^.s_pitch));
  453. y := y and $ffff;
  454. Dec(iface^.d_height);
  455. until iface^.d_height = 0;
  456. end;
  457. procedure ConvertP_Generic32_Generic24_S(iface: PHermesConverterInterface); cdecl;
  458. var
  459. s_pixel, r, g, b: Uint32;
  460. d_ptr: PUint8;
  461. count: DWord;
  462. source, dest: PUint8;
  463. dx, dy, x, y: DWord;
  464. begin
  465. d_ptr := PUint8(@s_pixel) + (R_32 - R_24);
  466. source := iface^.s_pixels;
  467. dest := iface^.d_pixels;
  468. dy := (iface^.s_height shl 16) div iface^.d_height;
  469. dx := (iface^.s_width shl 16) div iface^.d_width;
  470. y := 0;
  471. repeat
  472. count := iface^.d_width;
  473. x := 0;
  474. repeat
  475. s_pixel := (PUint32(source)+(x shr 16))^;
  476. r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
  477. iface^.mask_r;
  478. g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
  479. iface^.mask_g;
  480. b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
  481. iface^.mask_b;
  482. s_pixel := r or g or b;
  483. (dest + 0)^ := (d_ptr + 0)^;
  484. (dest + 1)^ := (d_ptr + 1)^;
  485. (dest + 2)^ := (d_ptr + 2)^;
  486. Inc(x, dx);
  487. Inc(dest, 3);
  488. Dec(count);
  489. until count = 0;
  490. Inc(dest, iface^.d_add);
  491. Inc(y, dy);
  492. Inc(source, (y shr 16)*DWord(iface^.s_pitch));
  493. y := y and $ffff;
  494. Dec(iface^.d_height);
  495. until iface^.d_height = 0;
  496. end;
  497. procedure ConvertP_Generic32_Generic16_S(iface: PHermesConverterInterface); cdecl;
  498. var
  499. s_pixel, r, g, b: Uint32;
  500. count: DWord;
  501. source, dest: PUint8;
  502. dx, dy, x, y: DWord;
  503. begin
  504. source := iface^.s_pixels;
  505. dest := iface^.d_pixels;
  506. dy := (iface^.s_height shl 16) div iface^.d_height;
  507. dx := (iface^.s_width shl 16) div iface^.d_width;
  508. y := 0;
  509. repeat
  510. count := iface^.d_width;
  511. x := 0;
  512. repeat
  513. s_pixel := (PUint32(source)+(x shr 16))^;
  514. r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
  515. iface^.mask_r;
  516. g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
  517. iface^.mask_g;
  518. b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
  519. iface^.mask_b;
  520. PUint16(dest)^ := r or g or b;
  521. Inc(x, dx);
  522. Inc(dest, 2);
  523. Dec(count);
  524. until count = 0;
  525. Inc(dest, iface^.d_add);
  526. Inc(y, dy);
  527. Inc(source, (y shr 16)*DWord(iface^.s_pitch));
  528. y := y and $ffff;
  529. Dec(iface^.d_height);
  530. until iface^.d_height = 0;
  531. end;
  532. procedure ConvertP_Generic32_Generic8_S(iface: PHermesConverterInterface); cdecl;
  533. var
  534. s_pixel, r, g, b: Uint32;
  535. count: DWord;
  536. source, dest: PUint8;
  537. dx, dy, x, y: DWord;
  538. begin
  539. source := iface^.s_pixels;
  540. dest := iface^.d_pixels;
  541. dy := (iface^.s_height shl 16) div iface^.d_height;
  542. dx := (iface^.s_width shl 16) div iface^.d_width;
  543. y := 0;
  544. repeat
  545. count := iface^.d_width;
  546. x := 0;
  547. repeat
  548. s_pixel := (PUint32(source)+(x shr 16))^;
  549. r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
  550. iface^.mask_r;
  551. g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
  552. iface^.mask_g;
  553. b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
  554. iface^.mask_b;
  555. dest^ := r or g or b;
  556. Inc(x, dx);
  557. Inc(dest);
  558. Dec(count);
  559. until count = 0;
  560. Inc(dest, iface^.d_add);
  561. Inc(y, dy);
  562. Inc(source, (y shr 16)*DWord(iface^.s_pitch));
  563. y := y and $ffff;
  564. Dec(iface^.d_height);
  565. until iface^.d_height = 0;
  566. end;
  567. procedure ConvertP_Generic24_Generic32_S(iface: PHermesConverterInterface); cdecl;
  568. var
  569. s_pixel, r, g, b: Uint32;
  570. count: DWord;
  571. source, src, dest: PUint8;
  572. dx, dy, x, y: DWord;
  573. begin
  574. source := iface^.s_pixels;
  575. dest := iface^.d_pixels;
  576. dy := (iface^.s_height shl 16) div iface^.d_height;
  577. dx := (iface^.s_width shl 16) div iface^.d_width;
  578. y := 0;
  579. repeat
  580. count := iface^.d_width;
  581. x := 0;
  582. src := source;
  583. repeat
  584. s_pixel := (((src+R_24)^) shl 16) or
  585. (((src+G_24)^) shl 8) or
  586. ((src+B_24)^);
  587. r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
  588. iface^.mask_r;
  589. g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
  590. iface^.mask_g;
  591. b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
  592. iface^.mask_b;
  593. PUint32(dest)^ := r or g or b;
  594. Inc(x, dx);
  595. Inc(src, x shr 16);
  596. Inc(src, x shr 16);
  597. Inc(src, x shr 16);
  598. x := x and $FFFF;
  599. Inc(dest, 4);
  600. Dec(count);
  601. until count = 0;
  602. Inc(dest, iface^.d_add);
  603. Inc(y, dy);
  604. Inc(source, (y shr 16)*DWord(iface^.s_pitch));
  605. y := y and $ffff;
  606. Dec(iface^.d_height);
  607. until iface^.d_height = 0;
  608. end;
  609. procedure ConvertP_Generic24_Generic24_S(iface: PHermesConverterInterface); cdecl;
  610. var
  611. s_pixel, r, g, b: Uint32;
  612. d_ptr: PUint8;
  613. count: DWord;
  614. source, src, dest: PUint8;
  615. dx, dy, x, y: DWord;
  616. begin
  617. d_ptr := PUint8(@s_pixel) + (R_32 - R_24);
  618. source := iface^.s_pixels;
  619. dest := iface^.d_pixels;
  620. dy := (iface^.s_height shl 16) div iface^.d_height;
  621. dx := (iface^.s_width shl 16) div iface^.d_width;
  622. y := 0;
  623. repeat
  624. count := iface^.d_width;
  625. x := 0;
  626. src := source;
  627. repeat
  628. s_pixel := (((src+R_24)^) shl 16) or
  629. (((src+G_24)^) shl 8) or
  630. ((src+B_24)^);
  631. r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
  632. iface^.mask_r;
  633. g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
  634. iface^.mask_g;
  635. b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
  636. iface^.mask_b;
  637. s_pixel := r or g or b;
  638. (dest + 0)^ := (d_ptr + 0)^;
  639. (dest + 1)^ := (d_ptr + 1)^;
  640. (dest + 2)^ := (d_ptr + 2)^;
  641. Inc(x, dx);
  642. Inc(src, x shr 16);
  643. Inc(src, x shr 16);
  644. Inc(src, x shr 16);
  645. x := x and $FFFF;
  646. Inc(dest, 3);
  647. Dec(count);
  648. until count = 0;
  649. Inc(dest, iface^.d_add);
  650. Inc(y, dy);
  651. Inc(source, (y shr 16)*DWord(iface^.s_pitch));
  652. y := y and $ffff;
  653. Dec(iface^.d_height);
  654. until iface^.d_height = 0;
  655. end;
  656. procedure ConvertP_Generic24_Generic16_S(iface: PHermesConverterInterface); cdecl;
  657. var
  658. s_pixel, r, g, b: Uint32;
  659. count: DWord;
  660. source, src, dest: PUint8;
  661. dx, dy, x, y: DWord;
  662. begin
  663. source := iface^.s_pixels;
  664. dest := iface^.d_pixels;
  665. dy := (iface^.s_height shl 16) div iface^.d_height;
  666. dx := (iface^.s_width shl 16) div iface^.d_width;
  667. y := 0;
  668. repeat
  669. count := iface^.d_width;
  670. x := 0;
  671. src := source;
  672. repeat
  673. s_pixel := (((src+R_24)^) shl 16) or
  674. (((src+G_24)^) shl 8) or
  675. ((src+B_24)^);
  676. r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
  677. iface^.mask_r;
  678. g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
  679. iface^.mask_g;
  680. b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
  681. iface^.mask_b;
  682. PUint16(dest)^ := r or g or b;
  683. Inc(x, dx);
  684. Inc(src, x shr 16);
  685. Inc(src, x shr 16);
  686. Inc(src, x shr 16);
  687. x := x and $FFFF;
  688. Inc(dest, 2);
  689. Dec(count);
  690. until count = 0;
  691. Inc(dest, iface^.d_add);
  692. Inc(y, dy);
  693. Inc(source, (y shr 16)*DWord(iface^.s_pitch));
  694. y := y and $ffff;
  695. Dec(iface^.d_height);
  696. until iface^.d_height = 0;
  697. end;
  698. procedure ConvertP_Generic24_Generic8_S(iface: PHermesConverterInterface); cdecl;
  699. var
  700. s_pixel, r, g, b: Uint32;
  701. count: DWord;
  702. source, src, dest: PUint8;
  703. dx, dy, x, y: DWord;
  704. begin
  705. source := iface^.s_pixels;
  706. dest := iface^.d_pixels;
  707. dy := (iface^.s_height shl 16) div iface^.d_height;
  708. dx := (iface^.s_width shl 16) div iface^.d_width;
  709. y := 0;
  710. repeat
  711. count := iface^.d_width;
  712. x := 0;
  713. src := source;
  714. repeat
  715. s_pixel := (((src+R_24)^) shl 16) or
  716. (((src+G_24)^) shl 8) or
  717. ((src+B_24)^);
  718. r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
  719. iface^.mask_r;
  720. g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
  721. iface^.mask_g;
  722. b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
  723. iface^.mask_b;
  724. dest^ := r or g or b;
  725. Inc(x, dx);
  726. Inc(src, x shr 16);
  727. Inc(src, x shr 16);
  728. Inc(src, x shr 16);
  729. x := x and $FFFF;
  730. Inc(dest);
  731. Dec(count);
  732. until count = 0;
  733. Inc(dest, iface^.d_add);
  734. Inc(y, dy);
  735. Inc(source, (y shr 16)*DWord(iface^.s_pitch));
  736. y := y and $ffff;
  737. Dec(iface^.d_height);
  738. until iface^.d_height = 0;
  739. end;
  740. procedure ConvertP_Generic16_Generic32_S(iface: PHermesConverterInterface); cdecl;
  741. var
  742. s_pixel, r, g, b: Uint32;
  743. count: DWord;
  744. source, dest: PUint8;
  745. dx, dy, x, y: DWord;
  746. begin
  747. source := iface^.s_pixels;
  748. dest := iface^.d_pixels;
  749. dy := (iface^.s_height shl 16) div iface^.d_height;
  750. dx := (iface^.s_width shl 16) div iface^.d_width;
  751. y := 0;
  752. repeat
  753. count := iface^.d_width;
  754. x := 0;
  755. repeat
  756. s_pixel := (PUint16(source)+(x shr 16))^;
  757. r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
  758. iface^.mask_r;
  759. g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
  760. iface^.mask_g;
  761. b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
  762. iface^.mask_b;
  763. PUint32(dest)^ := r or g or b;
  764. Inc(x, dx);
  765. Inc(dest, 4);
  766. Dec(count);
  767. until count = 0;
  768. Inc(dest, iface^.d_add);
  769. Inc(y, dy);
  770. Inc(source, (y shr 16)*DWord(iface^.s_pitch));
  771. y := y and $ffff;
  772. Dec(iface^.d_height);
  773. until iface^.d_height = 0;
  774. end;
  775. procedure ConvertP_Generic16_Generic24_S(iface: PHermesConverterInterface); cdecl;
  776. var
  777. s_pixel, r, g, b: Uint32;
  778. d_ptr: PUint8;
  779. count: DWord;
  780. source, dest: PUint8;
  781. dx, dy, x, y: DWord;
  782. begin
  783. d_ptr := PUint8(@s_pixel) + (R_32 - R_24);
  784. source := iface^.s_pixels;
  785. dest := iface^.d_pixels;
  786. dy := (iface^.s_height shl 16) div iface^.d_height;
  787. dx := (iface^.s_width shl 16) div iface^.d_width;
  788. y := 0;
  789. repeat
  790. count := iface^.d_width;
  791. x := 0;
  792. repeat
  793. s_pixel := (PUint16(source)+(x shr 16))^;
  794. r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
  795. iface^.mask_r;
  796. g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
  797. iface^.mask_g;
  798. b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
  799. iface^.mask_b;
  800. s_pixel := r or g or b;
  801. (dest + 0)^ := (d_ptr + 0)^;
  802. (dest + 1)^ := (d_ptr + 1)^;
  803. (dest + 2)^ := (d_ptr + 2)^;
  804. Inc(x, dx);
  805. Inc(dest, 3);
  806. Dec(count);
  807. until count = 0;
  808. Inc(dest, iface^.d_add);
  809. Inc(y, dy);
  810. Inc(source, (y shr 16)*DWord(iface^.s_pitch));
  811. y := y and $ffff;
  812. Dec(iface^.d_height);
  813. until iface^.d_height = 0;
  814. end;
  815. procedure ConvertP_Generic16_Generic16_S(iface: PHermesConverterInterface); cdecl;
  816. var
  817. s_pixel, r, g, b: Uint32;
  818. count: DWord;
  819. source, dest: PUint8;
  820. dx, dy, x, y: DWord;
  821. begin
  822. source := iface^.s_pixels;
  823. dest := iface^.d_pixels;
  824. dy := (iface^.s_height shl 16) div iface^.d_height;
  825. dx := (iface^.s_width shl 16) div iface^.d_width;
  826. y := 0;
  827. repeat
  828. count := iface^.d_width;
  829. x := 0;
  830. repeat
  831. s_pixel := (PUint16(source)+(x shr 16))^;
  832. r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
  833. iface^.mask_r;
  834. g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
  835. iface^.mask_g;
  836. b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
  837. iface^.mask_b;
  838. PUint16(dest)^ := r or g or b;
  839. Inc(x, dx);
  840. Inc(dest, 2);
  841. Dec(count);
  842. until count = 0;
  843. Inc(dest, iface^.d_add);
  844. Inc(y, dy);
  845. Inc(source, (y shr 16)*DWord(iface^.s_pitch));
  846. y := y and $ffff;
  847. Dec(iface^.d_height);
  848. until iface^.d_height = 0;
  849. end;
  850. procedure ConvertP_Generic16_Generic8_S(iface: PHermesConverterInterface); cdecl;
  851. var
  852. s_pixel, r, g, b: Uint32;
  853. count: DWord;
  854. source, dest: PUint8;
  855. dx, dy, x, y: DWord;
  856. begin
  857. source := iface^.s_pixels;
  858. dest := iface^.d_pixels;
  859. dy := (iface^.s_height shl 16) div iface^.d_height;
  860. dx := (iface^.s_width shl 16) div iface^.d_width;
  861. y := 0;
  862. repeat
  863. count := iface^.d_width;
  864. x := 0;
  865. repeat
  866. s_pixel := (PUint16(source)+(x shr 16))^;
  867. r := ((s_pixel shr iface^.info.r_right) shl iface^.info.r_left) and
  868. iface^.mask_r;
  869. g := ((s_pixel shr iface^.info.g_right) shl iface^.info.g_left) and
  870. iface^.mask_g;
  871. b := ((s_pixel shr iface^.info.b_right) shl iface^.info.b_left) and
  872. iface^.mask_b;
  873. dest^ := r or g or b;
  874. Inc(x, dx);
  875. Inc(dest);
  876. Dec(count);
  877. until count = 0;
  878. Inc(dest, iface^.d_add);
  879. Inc(y, dy);
  880. Inc(source, (y shr 16)*DWord(iface^.s_pitch));
  881. y := y and $ffff;
  882. Dec(iface^.d_height);
  883. until iface^.d_height = 0;
  884. end;
  885. procedure ConvertP_Generic8_Generic32_S(iface: PHermesConverterInterface); cdecl;
  886. begin
  887. {todo}
  888. end;
  889. procedure ConvertP_Generic8_Generic24_S(iface: PHermesConverterInterface); cdecl;
  890. begin
  891. {todo}
  892. end;
  893. procedure ConvertP_Generic8_Generic16_S(iface: PHermesConverterInterface); cdecl;
  894. begin
  895. {todo}
  896. end;
  897. procedure ConvertP_Generic8_Generic8_S(iface: PHermesConverterInterface); cdecl;
  898. begin
  899. {todo}
  900. end;