p_g.inc 27 KB

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