render.pas 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354
  1. {
  2. This file is part of the Free Pascal run time library.
  3. A file in Amiga system run time library.
  4. Copyright (c) 2003 by Nils Sjöholm.
  5. member of the Amiga RTL development team.
  6. This is a unit for render.library
  7. See the file COPYING.FPC, included in this distribution,
  8. for details about the copyright.
  9. This program 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.
  12. **********************************************************************}
  13. {
  14. History:
  15. First version of this unit.
  16. 16 Jan 2003.
  17. Changed cardinal > longword.
  18. Changed startcode for unit.
  19. 12 Feb 2003
  20. [email protected] Nils Sjoholm
  21. }
  22. {$mode objfpc}
  23. {$I useamigasmartlink.inc}
  24. {$ifdef use_amiga_smartlink}
  25. {$smartlink on}
  26. {$endif use_amiga_smartlink}
  27. UNIT RENDER;
  28. INTERFACE
  29. USES Exec,utility,graphics;
  30. VAR RenderBase : pLibrary;
  31. type
  32. pPLANEPTR = ^PLANEPTR;
  33. const
  34. RENDERNAME : PChar = 'render.library';
  35. {
  36. $VER: render.h v40 (19.12.2002)
  37. render.library definitions
  38. }
  39. const
  40. RND_TAGBASE = TAG_USER + $1000;
  41. {
  42. memhandler
  43. }
  44. { type of memhandler, see below }
  45. RND_MemType = RND_TAGBASE + 1;
  46. { ptr to block of memory }
  47. RND_MemBlock = RND_TAGBASE + 2;
  48. { size of memblock [bytes] }
  49. RND_MemSize = RND_TAGBASE + 3;
  50. { memflags (exec/memory.h) }
  51. RND_MemFlags = RND_TAGBASE + 18;
  52. { to pass a memhandler as an argument }
  53. RND_RMHandler = RND_TAGBASE + 12;
  54. {
  55. memhandler types
  56. }
  57. { v39 exec dynamic pool }
  58. RMHTYPE_POOL = 1;
  59. { private memory pool }
  60. RMHTYPE_PRIVATE = 2;
  61. { common public memory }
  62. RMHTYPE_PUBLIC = 3;
  63. {
  64. palette
  65. }
  66. { palette import/export format }
  67. RND_PaletteFormat = RND_TAGBASE + 19;
  68. { tag to indicate a palette is EHB }
  69. RND_EHBPalette = RND_TAGBASE + 22;
  70. { first palette entry }
  71. RND_FirstColor = RND_TAGBASE + 23;
  72. { dispose the old palette and load a new one }
  73. RND_NewPalette = RND_TAGBASE + 24;
  74. { quantization factors }
  75. RND_RGBWeight = RND_TAGBASE + 11;
  76. {
  77. palette format types
  78. }
  79. { ULONG red,green,blue }
  80. PALFMT_RGB32 = 1;
  81. { ULONG 0x00rrggbb }
  82. PALFMT_RGB8 = 2;
  83. { UWORD 0xrgb }
  84. PALFMT_RGB4 = 3;
  85. { render.library palette }
  86. PALFMT_PALETTE = 4;
  87. {
  88. palette sort mode types
  89. for the use with SortPalette()
  90. }
  91. { no particular order }
  92. PALMODE_NONE = $0000;
  93. { sort palette entries by brightness }
  94. PALMODE_BRIGHTNESS = $0001;
  95. { sort palette entries by the number of pixels that they represent.
  96. You must supply the RND_Histogram taglist argument. }
  97. PALMODE_POPULARITY = $0002;
  98. { sort palette entries by the number of histogram entries that they
  99. represent. You must supply the RND_Histogram taglist argument. }
  100. PALMODE_REPRESENTATION = $0003;
  101. { sort palette entries by their optical significance for the human
  102. eye. Implementation is unknown to you and may change.
  103. You must supply the RND_Histogram taglist argument. }
  104. PALMODE_SIGNIFICANCE = $0004;
  105. { sort palette entries by color intensity }
  106. PALMODE_SATURATION = $0005;
  107. { By default, sort direction is descending, i.e. the precedence is
  108. more-to-less. Combine with this flag to invert the sort direction. }
  109. PALMODE_ASCENDING = $0008;
  110. {
  111. histogram related
  112. }
  113. { histogram type, see below }
  114. RND_HSType = RND_TAGBASE + 4;
  115. { a histogram as an argument }
  116. RND_Histogram = RND_TAGBASE + 9;
  117. {
  118. Histogram / Palette types
  119. to be specified with RND_HSType
  120. }
  121. { 12bit dynamic histogram }
  122. HSTYPE_12BIT = 4;
  123. { 15bit dynamic histogram }
  124. HSTYPE_15BIT = 5;
  125. { 18bit dynamic histogram }
  126. HSTYPE_18BIT = 6;
  127. { 21bit dynamic histogram }
  128. HSTYPE_21BIT = 7;
  129. { 24bit dynamic histogram }
  130. HSTYPE_24BIT = 8;
  131. { 12bit tabular histogram }
  132. HSTYPE_12BIT_TURBO = 20;
  133. { 15bit tabular histogram }
  134. HSTYPE_15BIT_TURBO = 21;
  135. { 18bit tabular histogram }
  136. HSTYPE_18BIT_TURBO = 22;
  137. {
  138. tags that can be queried via QueryHistogram()
  139. }
  140. { # pixels in a histogram }
  141. RND_NumPixels = RND_TAGBASE + 5;
  142. { # colors in a histogram }
  143. RND_NumColors = RND_TAGBASE + 6;
  144. {
  145. rendering and conversions
  146. }
  147. { color mode, see below }
  148. RND_ColorMode = RND_TAGBASE + 7;
  149. { dither mode, see below }
  150. RND_DitherMode = RND_TAGBASE + 8;
  151. { dither amount }
  152. RND_DitherAmount = RND_TAGBASE + 26;
  153. { first color index to be output }
  154. RND_OffsetColorZero = RND_TAGBASE + 10;
  155. {
  156. color mode types
  157. to be specified with RND_ColorMode
  158. }
  159. { normal palette lookup }
  160. COLORMODE_CLUT = $0000;
  161. { HAM8 mode }
  162. COLORMODE_HAM8 = $0001;
  163. { HAM6 mode }
  164. COLORMODE_HAM6 = $0002;
  165. { mask to determine COLORMODE }
  166. COLORMODE_MASK = $0003;
  167. {
  168. dither mode types
  169. to be specified with RND_DitherMode
  170. }
  171. { no dither }
  172. DITHERMODE_NONE = $0000;
  173. { Floyd-Steinberg dither }
  174. DITHERMODE_FS = $0001;
  175. { random dither. amount required. }
  176. DITHERMODE_RANDOM = $0002;
  177. { EDD dither }
  178. DITHERMODE_EDD = $0003;
  179. {
  180. miscellaneous
  181. }
  182. { progress callback hook }
  183. RND_ProgressHook = RND_TAGBASE + 13;
  184. { total input width [pixels] }
  185. RND_SourceWidth = RND_TAGBASE + 14;
  186. { total output width [pixels] }
  187. RND_DestWidth = RND_TAGBASE + 15;
  188. { ptr to a chunky conversion table }
  189. RND_PenTable = RND_TAGBASE + 16;
  190. { chunky data left edge [pixels] }
  191. RND_LeftEdge = RND_TAGBASE + 17;
  192. { line callback hook }
  193. RND_LineHook = RND_TAGBASE + 20;
  194. { Mapping-Engine }
  195. RND_MapEngine = RND_TAGBASE + 27;
  196. { Interleave }
  197. RND_Interleave = RND_TAGBASE + 28;
  198. { Palette }
  199. RND_Palette = RND_TAGBASE + 29;
  200. { Weight factor }
  201. RND_Weight = RND_TAGBASE + 30;
  202. { ScaleEngine }
  203. RND_ScaleEngine = RND_TAGBASE + 31;
  204. { Texture coordinates }
  205. RND_DestCoordinates = RND_TAGBASE + 42;
  206. { backcolor for filling }
  207. RND_BGColor = RND_TAGBASE + 43;
  208. { backpen for filling }
  209. RND_BGPen = RND_TAGBASE + 44;
  210. {
  211. alpha-channel and masking
  212. }
  213. { custom alpha-channel }
  214. RND_AlphaChannel = RND_TAGBASE + 32;
  215. { bytes between alpha-channel pixels }
  216. RND_AlphaModulo = RND_TAGBASE + 33;
  217. { width of alpha-channel array }
  218. RND_AlphaWidth = RND_TAGBASE + 34;
  219. { masking RGB for CreateAlphaArray }
  220. RND_MaskRGB = RND_TAGBASE + 35;
  221. { mask value for outside color range }
  222. RND_MaskFalse = RND_TAGBASE + 36;
  223. { mask value for inside color range }
  224. RND_MaskTrue = RND_TAGBASE + 37;
  225. { total source width for 3channel operations }
  226. RND_SourceWidth2 = RND_TAGBASE + 38;
  227. { second custom alpha-channel }
  228. RND_AlphaChannel2 = RND_TAGBASE + 39;
  229. { pixel modulo for a second alpha-channel }
  230. RND_AlphaModulo2 = RND_TAGBASE + 40;
  231. { width of a second alpha-channel array }
  232. RND_AlphaWidth2 = RND_TAGBASE + 41;
  233. {
  234. PixelFormat
  235. }
  236. { pixel format, see below }
  237. RND_PixelFormat = RND_TAGBASE + 25;
  238. PIXFMTB_CHUNKY = 3;
  239. PIXFMTB_BITMAP = 4;
  240. PIXFMTB_RGB = 5;
  241. PIXFMT_CHUNKY_CLUT = (1 shl PIXFMTB_CHUNKY) + COLORMODE_CLUT;
  242. PIXFMT_0RGB_32 = (1 shl PIXFMTB_RGB) + 0;
  243. {
  244. these types are currently not used by render.library, but
  245. some of them are applicable for guigfx.library functions:
  246. }
  247. PIXFMT_CHUNKY_HAM8 = (1 shl PIXFMTB_CHUNKY) + COLORMODE_HAM8;
  248. PIXFMT_CHUNKY_HAM6 = (1 shl PIXFMTB_CHUNKY) + COLORMODE_HAM6;
  249. PIXFMT_BITMAP_CLUT = (1 shl PIXFMTB_BITMAP) + COLORMODE_CLUT;
  250. PIXFMT_BITMAP_HAM8 = (1 shl PIXFMTB_BITMAP) + COLORMODE_HAM8;
  251. PIXFMT_BITMAP_HAM6 = (1 shl PIXFMTB_BITMAP) + COLORMODE_HAM6;
  252. PIXFMT_RGB_24 = (1 shl PIXFMTB_RGB) + 1;
  253. {
  254. strictly internal:
  255. }
  256. PIXFMT_BITMAP_RGB = (1 shl PIXFMTB_BITMAP) + (1 shl PIXFMTB_RGB);
  257. {
  258. ExtractPalette return codes
  259. You must at least check for EXTP_SUCCESS.
  260. EXTP_NO_DATA indicates that there were no colors
  261. in the histogram.
  262. }
  263. EXTP_SUCCESS = 0;
  264. EXTP_NOT_ENOUGH_MEMORY = 1;
  265. EXTP_CALLBACK_ABORTED = 2;
  266. EXTP_NO_DATA = 3;
  267. {
  268. AddRGB, AddRGBImage and AddChunkyImage return codes
  269. You must at least check for ADDH_SUCCESS.
  270. If not delivered, the histogram might be
  271. inaccurate.
  272. }
  273. ADDH_SUCCESS = 0;
  274. ADDH_NOT_ENOUGH_MEMORY = 1;
  275. ADDH_CALLBACK_ABORTED = 2;
  276. ADDH_NO_DATA = 3;
  277. {
  278. Render return codes
  279. You must at least check for REND_SUCCESS.
  280. If not delivered, the image has not been
  281. rendered completely.
  282. }
  283. REND_SUCCESS = 0;
  284. REND_NOT_ENOUGH_MEMORY = 1;
  285. REND_CALLBACK_ABORTED = 2;
  286. REND_NO_VALID_PALETTE = 3;
  287. REND_NO_DATA = 3;
  288. {
  289. SortPalette return codes
  290. You must at least check for SORTP_SUCCESS.
  291. SORTP_NO_DATA indicates that there were data missing,
  292. e.g. you specified no histogram or the histogram was empty.
  293. }
  294. SORTP_SUCCESS = 0;
  295. SORTP_NO_DATA = 1;
  296. SORTP_NOT_ENOUGH_MEMORY = 2;
  297. SORTP_NOT_IMPLEMENTED = 3;
  298. {
  299. conversion return codes
  300. These return codes apply to conversion functions
  301. such as Chunky2RGB and ConvertChunky.
  302. }
  303. CONV_SUCCESS = 0;
  304. CONV_CALLBACK_ABORTED = 1;
  305. CONV_NOT_ENOUGH_MEMORY = 2;
  306. CONV_NO_DATA = 3;
  307. FUNCTION AddChunkyImageA(histogram : POINTER; chunky : pByte; width : WORD; height : WORD; palette : POINTER; taglist : pTagItem) : longword;
  308. FUNCTION AddHistogramA(histogram1 : POINTER; histogram2 : POINTER; taglist : pTagItem) : longword;
  309. FUNCTION AddRGB(histogram : POINTER; RGB : longword; count : longword) : longword;
  310. FUNCTION AddRGBImageA(histogram : POINTER; rgb : pULONG; width : WORD; height : WORD; taglist : pTagItem) : longword;
  311. FUNCTION AllocRenderMem(rendermemhandler : POINTER; size : longword) : POINTER;
  312. FUNCTION AllocRenderVec(rendermemhandler : POINTER; size : longword) : POINTER;
  313. FUNCTION AllocRenderVecClear(rendermemhandler : POINTER; size : longword) : POINTER;
  314. PROCEDURE ApplyAlphaChannelA(sourcearray : pULONG; width : WORD; height : WORD; destarray : pULONG; taglist : pTagItem);
  315. FUNCTION BestPen(palette : POINTER; rgb : longword) : LONGINT;
  316. PROCEDURE Chunky2BitMapA(chunky : pByte; sx : WORD; sy : WORD; width : WORD; height : WORD; bitmap : pBitMap; dx : WORD; dy : WORD; taglist : pTagItem);
  317. FUNCTION Chunky2RGBA(chunky : pByte; width : WORD; height : WORD; rgb : pULONG; palette : POINTER; taglist : pTagItem) : longword;
  318. FUNCTION ChunkyArrayDiversityA(chunky : pByte; palette : POINTER; width : WORD; height : WORD; taglist : pTagItem) : LONGINT;
  319. FUNCTION ConvertChunkyA(source : pByte; oldpalette : POINTER; width : WORD; height : WORD; dest : pByte; newpalette : POINTER; taglist : pTagItem) : longword;
  320. FUNCTION CountRGB(histogram : POINTER; rgb : longword) : longword;
  321. PROCEDURE CreateAlphaArrayA(rgbarray : pULONG; width : WORD; height : WORD; taglist : pTagItem);
  322. FUNCTION CreateHistogramA(taglist : pTagItem) : POINTER;
  323. FUNCTION CreateMapEngineA(palette : POINTER; taglist : pTagItem) : POINTER;
  324. FUNCTION CreatePaletteA(taglist : pTagItem) : POINTER;
  325. PROCEDURE CreatePenTableA(chunky : pByte; oldpalette : POINTER; width : WORD; height : WORD; newpalette : POINTER; convtab : pByte; taglist : pTagItem);
  326. FUNCTION CreateRMHandlerA(taglist : pTagItem) : POINTER;
  327. FUNCTION CreateScaleEngineA(sourcewidth : WORD; sourceheight : WORD; destwidth : WORD; destheight : WORD; taglist : pTagItem) : POINTER;
  328. PROCEDURE DeleteHistogram(histogram : POINTER);
  329. PROCEDURE DeleteMapEngine(engine : POINTER);
  330. PROCEDURE DeletePalette(palette : POINTER);
  331. PROCEDURE DeleteRMHandler(rmh : POINTER);
  332. PROCEDURE DeleteScaleEngine(engine : POINTER);
  333. PROCEDURE ExportPaletteA(palette : POINTER; coltab : POINTER; taglist : pTagItem);
  334. PROCEDURE ExtractAlphaChannelA(rgbarray : pULONG; width : WORD; height : WORD; chunkyarray : pByte; taglist : pTagItem);
  335. FUNCTION ExtractPaletteA(histogram : POINTER; palette : pULONG; numcolors : WORD; taglist : pTagItem) : longword;
  336. PROCEDURE FlushPalette(palette : POINTER);
  337. PROCEDURE FreeRenderMem(rendermemhandler : POINTER; mem : POINTER; size : longword);
  338. PROCEDURE FreeRenderVec(mem : POINTER);
  339. PROCEDURE ImportPaletteA(palette : POINTER; coltab : POINTER; numcols : WORD; taglist : pTagItem);
  340. PROCEDURE InsertAlphaChannelA(maskarray : pByte; width : WORD; height : WORD; rgbarray : pULONG; taglist : pTagItem);
  341. FUNCTION MapChunkyArrayA(engine : POINTER; source : pByte; palette : POINTER; width : WORD; height : WORD; dest : pByte; taglist : pTagItem) : longword;
  342. FUNCTION MapRGBArrayA(engine : POINTER; rgb : pULONG; width : WORD; height : WORD; chunky : pByte; taglist : pTagItem) : longword;
  343. PROCEDURE MixAlphaChannelA(source1 : pULONG; source2 : pULONG; width : WORD; height : WORD; dest : pULONG; taglist : pTagItem);
  344. PROCEDURE MixRGBArrayA(sourcearray : pULONG; width : WORD; height : WORD; destarray : pULONG; ratio : WORD; taglist : pTagItem);
  345. PROCEDURE Planar2ChunkyA(planetab : pPLANEPTR; bytewidth : WORD; height : WORD; depth : WORD; bytesperrow : WORD; chunky : pByte; taglist : pTagItem);
  346. FUNCTION QueryHistogram(histogram : POINTER; d0arg : longword) : longword;
  347. FUNCTION RenderA(rgb : pULONG; width : WORD; height : WORD; chunky : pByte; palette : POINTER; taglist : pTagItem) : longword;
  348. FUNCTION RGBArrayDiversityA(rgb : pULONG; width : WORD; height : WORD; taglist : pTagItem) : LONGINT;
  349. FUNCTION ScaleA(engine : POINTER; source : POINTER; dest : POINTER; taglist : pTagItem) : longword;
  350. FUNCTION ScaleOrdinate(source : WORD; dest : WORD; ordinate : WORD) : WORD;
  351. FUNCTION SortPaletteA(palette : POINTER; mode : longword; taglist : pTagItem) : longword;
  352. PROCEDURE TintRGBArrayA(source : pULONG; width : WORD; height : WORD; RGB : longword; ratio : WORD; dest : pULONG; taglist : pTagItem);
  353. {
  354. Functions and procedures with array of const go here
  355. }
  356. FUNCTION AddChunkyImage(histogram : POINTER; chunky : pByte; width : WORD; height : WORD; palette : POINTER; const taglist : Array Of Const) : longword;
  357. FUNCTION AddHistogram(histogram1 : POINTER; histogram2 : POINTER; const taglist : Array Of Const) : longword;
  358. FUNCTION AddRGBImage(histogram : POINTER; rgb : pULONG; width : WORD; height : WORD; const taglist : Array Of Const) : longword;
  359. PROCEDURE ApplyAlphaChannel(sourcearray : pULONG; width : WORD; height : WORD; destarray : pULONG; const taglist : Array Of Const);
  360. PROCEDURE Chunky2BitMap(chunky : pByte; sx : WORD; sy : WORD; width : WORD; height : WORD; bitmap : pBitMap; dx : WORD; dy : WORD; const taglist : Array Of Const);
  361. FUNCTION Chunky2RGB(chunky : pByte; width : WORD; height : WORD; rgb : pULONG; palette : POINTER; const taglist : Array Of Const) : longword;
  362. FUNCTION ChunkyArrayDiversity(chunky : pByte; palette : POINTER; width : WORD; height : WORD; const taglist : Array Of Const) : LONGINT;
  363. FUNCTION ConvertChunky(source : pByte; oldpalette : POINTER; width : WORD; height : WORD; dest : pByte; newpalette : POINTER; const taglist : Array Of Const) : longword;
  364. PROCEDURE CreateAlphaArray(rgbarray : pULONG; width : WORD; height : WORD; const taglist : Array Of Const);
  365. FUNCTION CreateHistogram(const taglist : Array Of Const) : POINTER;
  366. FUNCTION CreateMapEngine(palette : POINTER; const taglist : Array Of Const) : POINTER;
  367. FUNCTION CreatePalette(const taglist : Array Of Const) : POINTER;
  368. PROCEDURE CreatePenTable(chunky : pByte; oldpalette : POINTER; width : WORD; height : WORD; newpalette : POINTER; convtab : pByte; const taglist : Array Of Const);
  369. FUNCTION CreateRMHandler(const taglist : Array Of Const) : POINTER;
  370. FUNCTION CreateScaleEngine(sourcewidth : WORD; sourceheight : WORD; destwidth : WORD; destheight : WORD; const taglist : Array Of Const) : POINTER;
  371. PROCEDURE ExportPalette(palette : POINTER; coltab : POINTER; const taglist : Array Of Const);
  372. PROCEDURE ExtractAlphaChannel(rgbarray : pULONG; width : WORD; height : WORD; chunkyarray : pByte; const taglist : Array Of Const);
  373. FUNCTION ExtractPalette(histogram : POINTER; palette : pULONG; numcolors : WORD; const taglist : Array Of Const) : longword;
  374. PROCEDURE ImportPalette(palette : POINTER; coltab : POINTER; numcols : WORD; const taglist : Array Of Const);
  375. PROCEDURE InsertAlphaChannel(maskarray : pByte; width : WORD; height : WORD; rgbarray : pULONG; const taglist : Array Of Const);
  376. FUNCTION MapChunkyArray(engine : POINTER; source : pByte; palette : POINTER; width : WORD; height : WORD; dest : pByte; const taglist : Array Of Const) : longword;
  377. FUNCTION MapRGBArray(engine : POINTER; rgb : pULONG; width : WORD; height : WORD; chunky : pByte; const taglist : Array Of Const) : longword;
  378. PROCEDURE MixAlphaChannel(source1 : pULONG; source2 : pULONG; width : WORD; height : WORD; dest : pULONG; const taglist : Array Of Const);
  379. PROCEDURE MixRGBArray(sourcearray : pULONG; width : WORD; height : WORD; destarray : pULONG; ratio : WORD; const taglist : Array Of Const);
  380. PROCEDURE Planar2Chunky(planetab : pPLANEPTR; bytewidth : WORD; height : WORD; depth : WORD; bytesperrow : WORD; chunky : pByte; const taglist : Array Of Const);
  381. FUNCTION RenderTags(rgb : pULONG; width : WORD; height : WORD; chunky : pByte; palette : POINTER; const taglist : Array Of Const) : longword;
  382. FUNCTION RGBArrayDiversity(rgb : pULONG; width : WORD; height : WORD; const taglist : Array Of Const) : LONGINT;
  383. FUNCTION Scale(engine : POINTER; source : POINTER; dest : POINTER; const taglist : Array Of Const) : longword;
  384. FUNCTION SortPalette(palette : POINTER; mode : longword; const taglist : Array Of Const) : longword;
  385. PROCEDURE TintRGBArray(source : pULONG; width : WORD; height : WORD; RGB : longword; ratio : WORD; dest : pULONG; const taglist : Array Of Const);
  386. {You can remove this include and use a define instead}
  387. {$I useautoopenlib.inc}
  388. {$ifdef use_init_openlib}
  389. procedure InitRENDERLibrary;
  390. {$endif use_init_openlib}
  391. {This is a variable that knows how the unit is compiled}
  392. var
  393. RENDERIsCompiledHow : longint;
  394. IMPLEMENTATION
  395. uses
  396. {$ifndef dont_use_openlib}
  397. msgbox,
  398. {$endif dont_use_openlib}
  399. tagsarray;
  400. FUNCTION AddChunkyImageA(histogram : POINTER; chunky : pByte; width : WORD; height : WORD; palette : POINTER; taglist : pTagItem) : longword;
  401. BEGIN
  402. ASM
  403. MOVE.L A6,-(A7)
  404. MOVEA.L histogram,A0
  405. MOVEA.L chunky,A1
  406. MOVE.L width,D0
  407. MOVE.L height,D1
  408. MOVEA.L palette,A2
  409. MOVEA.L taglist,A3
  410. MOVEA.L RenderBase,A6
  411. JSR -108(A6)
  412. MOVEA.L (A7)+,A6
  413. MOVE.L D0,@RESULT
  414. END;
  415. END;
  416. FUNCTION AddHistogramA(histogram1 : POINTER; histogram2 : POINTER; taglist : pTagItem) : longword;
  417. BEGIN
  418. ASM
  419. MOVE.L A6,-(A7)
  420. MOVEA.L histogram1,A0
  421. MOVEA.L histogram2,A1
  422. MOVEA.L taglist,A2
  423. MOVEA.L RenderBase,A6
  424. JSR -222(A6)
  425. MOVEA.L (A7)+,A6
  426. MOVE.L D0,@RESULT
  427. END;
  428. END;
  429. FUNCTION AddRGB(histogram : POINTER; RGB : longword; count : longword) : longword;
  430. BEGIN
  431. ASM
  432. MOVE.L A6,-(A7)
  433. MOVEA.L histogram,A0
  434. MOVE.L RGB,D0
  435. MOVE.L count,D1
  436. MOVEA.L RenderBase,A6
  437. JSR -096(A6)
  438. MOVEA.L (A7)+,A6
  439. MOVE.L D0,@RESULT
  440. END;
  441. END;
  442. FUNCTION AddRGBImageA(histogram : POINTER; rgb : pULONG; width : WORD; height : WORD; taglist : pTagItem) : longword;
  443. BEGIN
  444. ASM
  445. MOVE.L A6,-(A7)
  446. MOVEA.L histogram,A0
  447. MOVEA.L rgb,A1
  448. MOVE.L width,D0
  449. MOVE.L height,D1
  450. MOVEA.L taglist,A2
  451. MOVEA.L RenderBase,A6
  452. JSR -102(A6)
  453. MOVEA.L (A7)+,A6
  454. MOVE.L D0,@RESULT
  455. END;
  456. END;
  457. FUNCTION AllocRenderMem(rendermemhandler : POINTER; size : longword) : POINTER;
  458. BEGIN
  459. ASM
  460. MOVE.L A6,-(A7)
  461. MOVEA.L rendermemhandler,A0
  462. MOVE.L size,D0
  463. MOVEA.L RenderBase,A6
  464. JSR -054(A6)
  465. MOVEA.L (A7)+,A6
  466. MOVE.L D0,@RESULT
  467. END;
  468. END;
  469. FUNCTION AllocRenderVec(rendermemhandler : POINTER; size : longword) : POINTER;
  470. BEGIN
  471. ASM
  472. MOVE.L A6,-(A7)
  473. MOVEA.L rendermemhandler,A0
  474. MOVE.L size,D0
  475. MOVEA.L RenderBase,A6
  476. JSR -066(A6)
  477. MOVEA.L (A7)+,A6
  478. MOVE.L D0,@RESULT
  479. END;
  480. END;
  481. FUNCTION AllocRenderVecClear(rendermemhandler : POINTER; size : longword) : POINTER;
  482. BEGIN
  483. ASM
  484. MOVE.L A6,-(A7)
  485. MOVEA.L rendermemhandler,A0
  486. MOVE.L size,D0
  487. MOVEA.L RenderBase,A6
  488. JSR -306(A6)
  489. MOVEA.L (A7)+,A6
  490. MOVE.L D0,@RESULT
  491. END;
  492. END;
  493. PROCEDURE ApplyAlphaChannelA(sourcearray : pULONG; width : WORD; height : WORD; destarray : pULONG; taglist : pTagItem);
  494. BEGIN
  495. ASM
  496. MOVE.L A6,-(A7)
  497. MOVEA.L sourcearray,A0
  498. MOVE.L width,D0
  499. MOVE.L height,D1
  500. MOVEA.L destarray,A1
  501. MOVEA.L taglist,A2
  502. MOVEA.L RenderBase,A6
  503. JSR -294(A6)
  504. MOVEA.L (A7)+,A6
  505. END;
  506. END;
  507. FUNCTION BestPen(palette : POINTER; rgb : longword) : LONGINT;
  508. BEGIN
  509. ASM
  510. MOVE.L A6,-(A7)
  511. MOVEA.L palette,A0
  512. MOVE.L rgb,D0
  513. MOVEA.L RenderBase,A6
  514. JSR -204(A6)
  515. MOVEA.L (A7)+,A6
  516. MOVE.L D0,@RESULT
  517. END;
  518. END;
  519. PROCEDURE Chunky2BitMapA(chunky : pByte; sx : WORD; sy : WORD; width : WORD; height : WORD; bitmap : pBitMap; dx : WORD; dy : WORD; taglist : pTagItem);
  520. BEGIN
  521. ASM
  522. MOVE.L A6,-(A7)
  523. MOVEA.L chunky,A0
  524. MOVE.L sx,D0
  525. MOVE.L sy,D1
  526. MOVE.L width,D2
  527. MOVE.L height,D3
  528. MOVEA.L bitmap,A1
  529. MOVE.L dx,D4
  530. MOVE.L dy,D5
  531. MOVEA.L taglist,A2
  532. MOVEA.L RenderBase,A6
  533. JSR -138(A6)
  534. MOVEA.L (A7)+,A6
  535. END;
  536. END;
  537. FUNCTION Chunky2RGBA(chunky : pByte; width : WORD; height : WORD; rgb : pULONG; palette : POINTER; taglist : pTagItem) : longword;
  538. BEGIN
  539. ASM
  540. MOVE.L A6,-(A7)
  541. MOVEA.L chunky,A0
  542. MOVE.L width,D0
  543. MOVE.L height,D1
  544. MOVEA.L rgb,A1
  545. MOVEA.L palette,A2
  546. MOVEA.L taglist,A3
  547. MOVEA.L RenderBase,A6
  548. JSR -132(A6)
  549. MOVEA.L (A7)+,A6
  550. MOVE.L D0,@RESULT
  551. END;
  552. END;
  553. FUNCTION ChunkyArrayDiversityA(chunky : pByte; palette : POINTER; width : WORD; height : WORD; taglist : pTagItem) : LONGINT;
  554. BEGIN
  555. ASM
  556. MOVE.L A6,-(A7)
  557. MOVEA.L chunky,A0
  558. MOVEA.L palette,A1
  559. MOVE.L width,D0
  560. MOVE.L height,D1
  561. MOVEA.L taglist,A2
  562. MOVEA.L RenderBase,A6
  563. JSR -270(A6)
  564. MOVEA.L (A7)+,A6
  565. MOVE.L D0,@RESULT
  566. END;
  567. END;
  568. FUNCTION ConvertChunkyA(source : pByte; oldpalette : POINTER; width : WORD; height : WORD; dest : pByte; newpalette : POINTER; taglist : pTagItem) : longword;
  569. BEGIN
  570. ASM
  571. MOVE.L A6,-(A7)
  572. MOVEA.L source,A0
  573. MOVEA.L oldpalette,A1
  574. MOVE.L width,D0
  575. MOVE.L height,D1
  576. MOVEA.L dest,A2
  577. MOVEA.L newpalette,A3
  578. MOVEA.L taglist,A4
  579. MOVEA.L RenderBase,A6
  580. JSR -162(A6)
  581. MOVEA.L (A7)+,A6
  582. MOVE.L D0,@RESULT
  583. END;
  584. END;
  585. FUNCTION CountRGB(histogram : POINTER; rgb : longword) : longword;
  586. BEGIN
  587. ASM
  588. MOVE.L A6,-(A7)
  589. MOVEA.L histogram,A0
  590. MOVE.L rgb,D0
  591. MOVEA.L RenderBase,A6
  592. JSR -198(A6)
  593. MOVEA.L (A7)+,A6
  594. MOVE.L D0,@RESULT
  595. END;
  596. END;
  597. PROCEDURE CreateAlphaArrayA(rgbarray : pULONG; width : WORD; height : WORD; taglist : pTagItem);
  598. BEGIN
  599. ASM
  600. MOVE.L A6,-(A7)
  601. MOVEA.L rgbarray,A0
  602. MOVE.L width,D0
  603. MOVE.L height,D1
  604. MOVEA.L taglist,A1
  605. MOVEA.L RenderBase,A6
  606. JSR -312(A6)
  607. MOVEA.L (A7)+,A6
  608. END;
  609. END;
  610. FUNCTION CreateHistogramA(taglist : pTagItem) : POINTER;
  611. BEGIN
  612. ASM
  613. MOVE.L A6,-(A7)
  614. MOVEA.L taglist,A1
  615. MOVEA.L RenderBase,A6
  616. JSR -078(A6)
  617. MOVEA.L (A7)+,A6
  618. MOVE.L D0,@RESULT
  619. END;
  620. END;
  621. FUNCTION CreateMapEngineA(palette : POINTER; taglist : pTagItem) : POINTER;
  622. BEGIN
  623. ASM
  624. MOVE.L A6,-(A7)
  625. MOVEA.L palette,A0
  626. MOVEA.L taglist,A1
  627. MOVEA.L RenderBase,A6
  628. JSR -246(A6)
  629. MOVEA.L (A7)+,A6
  630. MOVE.L D0,@RESULT
  631. END;
  632. END;
  633. FUNCTION CreatePaletteA(taglist : pTagItem) : POINTER;
  634. BEGIN
  635. ASM
  636. MOVE.L A6,-(A7)
  637. MOVEA.L taglist,A1
  638. MOVEA.L RenderBase,A6
  639. JSR -174(A6)
  640. MOVEA.L (A7)+,A6
  641. MOVE.L D0,@RESULT
  642. END;
  643. END;
  644. PROCEDURE CreatePenTableA(chunky : pByte; oldpalette : POINTER; width : WORD; height : WORD; newpalette : POINTER; convtab : pByte; taglist : pTagItem);
  645. BEGIN
  646. ASM
  647. MOVE.L A6,-(A7)
  648. MOVEA.L chunky,A0
  649. MOVEA.L oldpalette,A1
  650. MOVE.L width,D0
  651. MOVE.L height,D1
  652. MOVEA.L newpalette,A2
  653. MOVEA.L convtab,A3
  654. MOVEA.L taglist,A4
  655. MOVEA.L RenderBase,A6
  656. JSR -168(A6)
  657. MOVEA.L (A7)+,A6
  658. END;
  659. END;
  660. FUNCTION CreateRMHandlerA(taglist : pTagItem) : POINTER;
  661. BEGIN
  662. ASM
  663. MOVE.L A6,-(A7)
  664. MOVEA.L taglist,A1
  665. MOVEA.L RenderBase,A6
  666. JSR -042(A6)
  667. MOVEA.L (A7)+,A6
  668. MOVE.L D0,@RESULT
  669. END;
  670. END;
  671. FUNCTION CreateScaleEngineA(sourcewidth : WORD; sourceheight : WORD; destwidth : WORD; destheight : WORD; taglist : pTagItem) : POINTER;
  672. BEGIN
  673. ASM
  674. MOVE.L A6,-(A7)
  675. MOVE.L sourcewidth,D0
  676. MOVE.L sourceheight,D1
  677. MOVE.L destwidth,D2
  678. MOVE.L destheight,D3
  679. MOVEA.L taglist,A1
  680. MOVEA.L RenderBase,A6
  681. JSR -144(A6)
  682. MOVEA.L (A7)+,A6
  683. MOVE.L D0,@RESULT
  684. END;
  685. END;
  686. PROCEDURE DeleteHistogram(histogram : POINTER);
  687. BEGIN
  688. ASM
  689. MOVE.L A6,-(A7)
  690. MOVEA.L histogram,A0
  691. MOVEA.L RenderBase,A6
  692. JSR -084(A6)
  693. MOVEA.L (A7)+,A6
  694. END;
  695. END;
  696. PROCEDURE DeleteMapEngine(engine : POINTER);
  697. BEGIN
  698. ASM
  699. MOVE.L A6,-(A7)
  700. MOVEA.L engine,A0
  701. MOVEA.L RenderBase,A6
  702. JSR -252(A6)
  703. MOVEA.L (A7)+,A6
  704. END;
  705. END;
  706. PROCEDURE DeletePalette(palette : POINTER);
  707. BEGIN
  708. ASM
  709. MOVE.L A6,-(A7)
  710. MOVEA.L palette,A0
  711. MOVEA.L RenderBase,A6
  712. JSR -180(A6)
  713. MOVEA.L (A7)+,A6
  714. END;
  715. END;
  716. PROCEDURE DeleteRMHandler(rmh : POINTER);
  717. BEGIN
  718. ASM
  719. MOVE.L A6,-(A7)
  720. MOVEA.L rmh,A0
  721. MOVEA.L RenderBase,A6
  722. JSR -048(A6)
  723. MOVEA.L (A7)+,A6
  724. END;
  725. END;
  726. PROCEDURE DeleteScaleEngine(engine : POINTER);
  727. BEGIN
  728. ASM
  729. MOVE.L A6,-(A7)
  730. MOVEA.L engine,A0
  731. MOVEA.L RenderBase,A6
  732. JSR -150(A6)
  733. MOVEA.L (A7)+,A6
  734. END;
  735. END;
  736. PROCEDURE ExportPaletteA(palette : POINTER; coltab : POINTER; taglist : pTagItem);
  737. BEGIN
  738. ASM
  739. MOVE.L A6,-(A7)
  740. MOVEA.L palette,A0
  741. MOVEA.L coltab,A1
  742. MOVEA.L taglist,A2
  743. MOVEA.L RenderBase,A6
  744. JSR -192(A6)
  745. MOVEA.L (A7)+,A6
  746. END;
  747. END;
  748. PROCEDURE ExtractAlphaChannelA(rgbarray : pULONG; width : WORD; height : WORD; chunkyarray : pByte; taglist : pTagItem);
  749. BEGIN
  750. ASM
  751. MOVE.L A6,-(A7)
  752. MOVEA.L rgbarray,A0
  753. MOVE.L width,D0
  754. MOVE.L height,D1
  755. MOVEA.L chunkyarray,A1
  756. MOVEA.L taglist,A2
  757. MOVEA.L RenderBase,A6
  758. JSR -288(A6)
  759. MOVEA.L (A7)+,A6
  760. END;
  761. END;
  762. FUNCTION ExtractPaletteA(histogram : POINTER; palette : pULONG; numcolors : WORD; taglist : pTagItem) : longword;
  763. BEGIN
  764. ASM
  765. MOVE.L A6,-(A7)
  766. MOVEA.L histogram,A0
  767. MOVEA.L palette,A1
  768. MOVE.L numcolors,D0
  769. MOVEA.L taglist,A2
  770. MOVEA.L RenderBase,A6
  771. JSR -114(A6)
  772. MOVEA.L (A7)+,A6
  773. MOVE.L D0,@RESULT
  774. END;
  775. END;
  776. PROCEDURE FlushPalette(palette : POINTER);
  777. BEGIN
  778. ASM
  779. MOVE.L A6,-(A7)
  780. MOVEA.L palette,A0
  781. MOVEA.L RenderBase,A6
  782. JSR -210(A6)
  783. MOVEA.L (A7)+,A6
  784. END;
  785. END;
  786. PROCEDURE FreeRenderMem(rendermemhandler : POINTER; mem : POINTER; size : longword);
  787. BEGIN
  788. ASM
  789. MOVE.L A6,-(A7)
  790. MOVEA.L rendermemhandler,A0
  791. MOVEA.L mem,A1
  792. MOVE.L size,D0
  793. MOVEA.L RenderBase,A6
  794. JSR -060(A6)
  795. MOVEA.L (A7)+,A6
  796. END;
  797. END;
  798. PROCEDURE FreeRenderVec(mem : POINTER);
  799. BEGIN
  800. ASM
  801. MOVE.L A6,-(A7)
  802. MOVEA.L mem,A0
  803. MOVEA.L RenderBase,A6
  804. JSR -072(A6)
  805. MOVEA.L (A7)+,A6
  806. END;
  807. END;
  808. PROCEDURE ImportPaletteA(palette : POINTER; coltab : POINTER; numcols : WORD; taglist : pTagItem);
  809. BEGIN
  810. ASM
  811. MOVE.L A6,-(A7)
  812. MOVEA.L palette,A0
  813. MOVEA.L coltab,A1
  814. MOVE.L numcols,D0
  815. MOVEA.L taglist,A2
  816. MOVEA.L RenderBase,A6
  817. JSR -186(A6)
  818. MOVEA.L (A7)+,A6
  819. END;
  820. END;
  821. PROCEDURE InsertAlphaChannelA(maskarray : pByte; width : WORD; height : WORD; rgbarray : pULONG; taglist : pTagItem);
  822. BEGIN
  823. ASM
  824. MOVE.L A6,-(A7)
  825. MOVEA.L maskarray,A0
  826. MOVE.L width,D0
  827. MOVE.L height,D1
  828. MOVEA.L rgbarray,A1
  829. MOVEA.L taglist,A2
  830. MOVEA.L RenderBase,A6
  831. JSR -282(A6)
  832. MOVEA.L (A7)+,A6
  833. END;
  834. END;
  835. FUNCTION MapChunkyArrayA(engine : POINTER; source : pByte; palette : POINTER; width : WORD; height : WORD; dest : pByte; taglist : pTagItem) : longword;
  836. BEGIN
  837. ASM
  838. MOVE.L A6,-(A7)
  839. MOVEA.L engine,A0
  840. MOVEA.L source,A1
  841. MOVEA.L palette,A2
  842. MOVE.L width,D0
  843. MOVE.L height,D1
  844. MOVEA.L dest,A3
  845. MOVEA.L taglist,A4
  846. MOVEA.L RenderBase,A6
  847. JSR -276(A6)
  848. MOVEA.L (A7)+,A6
  849. MOVE.L D0,@RESULT
  850. END;
  851. END;
  852. FUNCTION MapRGBArrayA(engine : POINTER; rgb : pULONG; width : WORD; height : WORD; chunky : pByte; taglist : pTagItem) : longword;
  853. BEGIN
  854. ASM
  855. MOVE.L A6,-(A7)
  856. MOVEA.L engine,A0
  857. MOVEA.L rgb,A1
  858. MOVE.L width,D0
  859. MOVE.L height,D1
  860. MOVEA.L chunky,A2
  861. MOVEA.L taglist,A3
  862. MOVEA.L RenderBase,A6
  863. JSR -258(A6)
  864. MOVEA.L (A7)+,A6
  865. MOVE.L D0,@RESULT
  866. END;
  867. END;
  868. PROCEDURE MixAlphaChannelA(source1 : pULONG; source2 : pULONG; width : WORD; height : WORD; dest : pULONG; taglist : pTagItem);
  869. BEGIN
  870. ASM
  871. MOVE.L A6,-(A7)
  872. MOVEA.L source1,A0
  873. MOVEA.L source2,A1
  874. MOVE.L width,D0
  875. MOVE.L height,D1
  876. MOVEA.L dest,A2
  877. MOVEA.L taglist,A3
  878. MOVEA.L RenderBase,A6
  879. JSR -318(A6)
  880. MOVEA.L (A7)+,A6
  881. END;
  882. END;
  883. PROCEDURE MixRGBArrayA(sourcearray : pULONG; width : WORD; height : WORD; destarray : pULONG; ratio : WORD; taglist : pTagItem);
  884. BEGIN
  885. ASM
  886. MOVE.L A6,-(A7)
  887. MOVEA.L sourcearray,A0
  888. MOVE.L width,D0
  889. MOVE.L height,D1
  890. MOVEA.L destarray,A1
  891. MOVE.L ratio,D2
  892. MOVEA.L taglist,A2
  893. MOVEA.L RenderBase,A6
  894. JSR -300(A6)
  895. MOVEA.L (A7)+,A6
  896. END;
  897. END;
  898. PROCEDURE Planar2ChunkyA(planetab : pPLANEPTR; bytewidth : WORD; height : WORD; depth : WORD; bytesperrow : WORD; chunky : pByte; taglist : pTagItem);
  899. BEGIN
  900. ASM
  901. MOVE.L A6,-(A7)
  902. MOVEA.L planetab,A0
  903. MOVE.L bytewidth,D0
  904. MOVE.L height,D1
  905. MOVE.L depth,D2
  906. MOVE.L bytesperrow,D3
  907. MOVEA.L chunky,A1
  908. MOVEA.L taglist,A2
  909. MOVEA.L RenderBase,A6
  910. JSR -126(A6)
  911. MOVEA.L (A7)+,A6
  912. END;
  913. END;
  914. FUNCTION QueryHistogram(histogram : POINTER; d0arg : longword) : longword;
  915. BEGIN
  916. ASM
  917. MOVE.L A6,-(A7)
  918. MOVEA.L histogram,A0
  919. MOVE.L d0arg,D0
  920. MOVEA.L RenderBase,A6
  921. JSR -090(A6)
  922. MOVEA.L (A7)+,A6
  923. MOVE.L D0,@RESULT
  924. END;
  925. END;
  926. FUNCTION RenderA(rgb : pULONG; width : WORD; height : WORD; chunky : pByte; palette : POINTER; taglist : pTagItem) : longword;
  927. BEGIN
  928. ASM
  929. MOVE.L A6,-(A7)
  930. MOVEA.L rgb,A0
  931. MOVE.L width,D0
  932. MOVE.L height,D1
  933. MOVEA.L chunky,A1
  934. MOVEA.L palette,A2
  935. MOVEA.L taglist,A3
  936. MOVEA.L RenderBase,A6
  937. JSR -120(A6)
  938. MOVEA.L (A7)+,A6
  939. MOVE.L D0,@RESULT
  940. END;
  941. END;
  942. FUNCTION RGBArrayDiversityA(rgb : pULONG; width : WORD; height : WORD; taglist : pTagItem) : LONGINT;
  943. BEGIN
  944. ASM
  945. MOVE.L A6,-(A7)
  946. MOVEA.L rgb,A0
  947. MOVE.L width,D0
  948. MOVE.L height,D1
  949. MOVEA.L taglist,A1
  950. MOVEA.L RenderBase,A6
  951. JSR -264(A6)
  952. MOVEA.L (A7)+,A6
  953. MOVE.L D0,@RESULT
  954. END;
  955. END;
  956. FUNCTION ScaleA(engine : POINTER; source : POINTER; dest : POINTER; taglist : pTagItem) : longword;
  957. BEGIN
  958. ASM
  959. MOVE.L A6,-(A7)
  960. MOVEA.L engine,A0
  961. MOVEA.L source,A1
  962. MOVEA.L dest,A2
  963. MOVEA.L taglist,A3
  964. MOVEA.L RenderBase,A6
  965. JSR -156(A6)
  966. MOVEA.L (A7)+,A6
  967. MOVE.L D0,@RESULT
  968. END;
  969. END;
  970. FUNCTION ScaleOrdinate(source : WORD; dest : WORD; ordinate : WORD) : WORD;
  971. BEGIN
  972. ASM
  973. MOVE.L A6,-(A7)
  974. MOVE.L source,D0
  975. MOVE.L dest,D1
  976. MOVE.L ordinate,D2
  977. MOVEA.L RenderBase,A6
  978. JSR -228(A6)
  979. MOVEA.L (A7)+,A6
  980. MOVE.L D0,@RESULT
  981. END;
  982. END;
  983. FUNCTION SortPaletteA(palette : POINTER; mode : longword; taglist : pTagItem) : longword;
  984. BEGIN
  985. ASM
  986. MOVE.L A6,-(A7)
  987. MOVEA.L palette,A0
  988. MOVE.L mode,D0
  989. MOVEA.L taglist,A1
  990. MOVEA.L RenderBase,A6
  991. JSR -216(A6)
  992. MOVEA.L (A7)+,A6
  993. MOVE.L D0,@RESULT
  994. END;
  995. END;
  996. PROCEDURE TintRGBArrayA(source : pULONG; width : WORD; height : WORD; RGB : longword; ratio : WORD; dest : pULONG; taglist : pTagItem);
  997. BEGIN
  998. ASM
  999. MOVE.L A6,-(A7)
  1000. MOVEA.L source,A0
  1001. MOVE.L width,D0
  1002. MOVE.L height,D1
  1003. MOVE.L RGB,D2
  1004. MOVE.L ratio,D3
  1005. MOVEA.L dest,A1
  1006. MOVEA.L taglist,A2
  1007. MOVEA.L RenderBase,A6
  1008. JSR -324(A6)
  1009. MOVEA.L (A7)+,A6
  1010. END;
  1011. END;
  1012. {
  1013. Functions and procedures with array of const go here
  1014. }
  1015. FUNCTION AddChunkyImage(histogram : POINTER; chunky : pByte; width : WORD; height : WORD; palette : POINTER; const taglist : Array Of Const) : longword;
  1016. begin
  1017. AddChunkyImage := AddChunkyImageA(histogram , chunky , width , height , palette , readintags(taglist));
  1018. end;
  1019. FUNCTION AddHistogram(histogram1 : POINTER; histogram2 : POINTER; const taglist : Array Of Const) : longword;
  1020. begin
  1021. AddHistogram := AddHistogramA(histogram1 , histogram2 , readintags(taglist));
  1022. end;
  1023. FUNCTION AddRGBImage(histogram : POINTER; rgb : pULONG; width : WORD; height : WORD; const taglist : Array Of Const) : longword;
  1024. begin
  1025. AddRGBImage := AddRGBImageA(histogram , rgb , width , height , readintags(taglist));
  1026. end;
  1027. PROCEDURE ApplyAlphaChannel(sourcearray : pULONG; width : WORD; height : WORD; destarray : pULONG; const taglist : Array Of Const);
  1028. begin
  1029. ApplyAlphaChannelA(sourcearray , width , height , destarray , readintags(taglist));
  1030. end;
  1031. PROCEDURE Chunky2BitMap(chunky : pByte; sx : WORD; sy : WORD; width : WORD; height : WORD; bitmap : pBitMap; dx : WORD; dy : WORD; const taglist : Array Of Const);
  1032. begin
  1033. Chunky2BitMapA(chunky , sx , sy , width , height , bitmap , dx , dy , readintags(taglist));
  1034. end;
  1035. FUNCTION Chunky2RGB(chunky : pByte; width : WORD; height : WORD; rgb : pULONG; palette : POINTER; const taglist : Array Of Const) : longword;
  1036. begin
  1037. Chunky2RGB := Chunky2RGBA(chunky , width , height , rgb , palette , readintags(taglist));
  1038. end;
  1039. FUNCTION ChunkyArrayDiversity(chunky : pByte; palette : POINTER; width : WORD; height : WORD; const taglist : Array Of Const) : LONGINT;
  1040. begin
  1041. ChunkyArrayDiversity := ChunkyArrayDiversityA(chunky , palette , width , height , readintags(taglist));
  1042. end;
  1043. FUNCTION ConvertChunky(source : pByte; oldpalette : POINTER; width : WORD; height : WORD; dest : pByte; newpalette : POINTER; const taglist : Array Of Const) : longword;
  1044. begin
  1045. ConvertChunky := ConvertChunkyA(source , oldpalette , width , height , dest , newpalette , readintags(taglist));
  1046. end;
  1047. PROCEDURE CreateAlphaArray(rgbarray : pULONG; width : WORD; height : WORD; const taglist : Array Of Const);
  1048. begin
  1049. CreateAlphaArrayA(rgbarray , width , height , readintags(taglist));
  1050. end;
  1051. FUNCTION CreateHistogram(const taglist : Array Of Const) : POINTER;
  1052. begin
  1053. CreateHistogram := CreateHistogramA(readintags(taglist));
  1054. end;
  1055. FUNCTION CreateMapEngine(palette : POINTER; const taglist : Array Of Const) : POINTER;
  1056. begin
  1057. CreateMapEngine := CreateMapEngineA(palette , readintags(taglist));
  1058. end;
  1059. FUNCTION CreatePalette(const taglist : Array Of Const) : POINTER;
  1060. begin
  1061. CreatePalette := CreatePaletteA(readintags(taglist));
  1062. end;
  1063. PROCEDURE CreatePenTable(chunky : pByte; oldpalette : POINTER; width : WORD; height : WORD; newpalette : POINTER; convtab : pByte; const taglist : Array Of Const);
  1064. begin
  1065. CreatePenTableA(chunky , oldpalette , width , height , newpalette , convtab , readintags(taglist));
  1066. end;
  1067. FUNCTION CreateRMHandler(const taglist : Array Of Const) : POINTER;
  1068. begin
  1069. CreateRMHandler := CreateRMHandlerA(readintags(taglist));
  1070. end;
  1071. FUNCTION CreateScaleEngine(sourcewidth : WORD; sourceheight : WORD; destwidth : WORD; destheight : WORD; const taglist : Array Of Const) : POINTER;
  1072. begin
  1073. CreateScaleEngine := CreateScaleEngineA(sourcewidth , sourceheight , destwidth , destheight , readintags(taglist));
  1074. end;
  1075. PROCEDURE ExportPalette(palette : POINTER; coltab : POINTER; const taglist : Array Of Const);
  1076. begin
  1077. ExportPaletteA(palette , coltab , readintags(taglist));
  1078. end;
  1079. PROCEDURE ExtractAlphaChannel(rgbarray : pULONG; width : WORD; height : WORD; chunkyarray : pByte; const taglist : Array Of Const);
  1080. begin
  1081. ExtractAlphaChannelA(rgbarray , width , height , chunkyarray , readintags(taglist));
  1082. end;
  1083. FUNCTION ExtractPalette(histogram : POINTER; palette : pULONG; numcolors : WORD; const taglist : Array Of Const) : longword;
  1084. begin
  1085. ExtractPalette := ExtractPaletteA(histogram , palette , numcolors , readintags(taglist));
  1086. end;
  1087. PROCEDURE ImportPalette(palette : POINTER; coltab : POINTER; numcols : WORD; const taglist : Array Of Const);
  1088. begin
  1089. ImportPaletteA(palette , coltab , numcols , readintags(taglist));
  1090. end;
  1091. PROCEDURE InsertAlphaChannel(maskarray : pByte; width : WORD; height : WORD; rgbarray : pULONG; const taglist : Array Of Const);
  1092. begin
  1093. InsertAlphaChannelA(maskarray , width , height , rgbarray , readintags(taglist));
  1094. end;
  1095. FUNCTION MapChunkyArray(engine : POINTER; source : pByte; palette : POINTER; width : WORD; height : WORD; dest : pByte; const taglist : Array Of Const) : longword;
  1096. begin
  1097. MapChunkyArray := MapChunkyArrayA(engine , source , palette , width , height , dest , readintags(taglist));
  1098. end;
  1099. FUNCTION MapRGBArray(engine : POINTER; rgb : pULONG; width : WORD; height : WORD; chunky : pByte; const taglist : Array Of Const) : longword;
  1100. begin
  1101. MapRGBArray := MapRGBArrayA(engine , rgb , width , height , chunky , readintags(taglist));
  1102. end;
  1103. PROCEDURE MixAlphaChannel(source1 : pULONG; source2 : pULONG; width : WORD; height : WORD; dest : pULONG; const taglist : Array Of Const);
  1104. begin
  1105. MixAlphaChannelA(source1 , source2 , width , height , dest , readintags(taglist));
  1106. end;
  1107. PROCEDURE MixRGBArray(sourcearray : pULONG; width : WORD; height : WORD; destarray : pULONG; ratio : WORD; const taglist : Array Of Const);
  1108. begin
  1109. MixRGBArrayA(sourcearray , width , height , destarray , ratio , readintags(taglist));
  1110. end;
  1111. PROCEDURE Planar2Chunky(planetab : pPLANEPTR; bytewidth : WORD; height : WORD; depth : WORD; bytesperrow : WORD; chunky : pByte; const taglist : Array Of Const);
  1112. begin
  1113. Planar2ChunkyA(planetab , bytewidth , height , depth , bytesperrow , chunky , readintags(taglist));
  1114. end;
  1115. FUNCTION RenderTags(rgb : pULONG; width : WORD; height : WORD; chunky : pByte; palette : POINTER; const taglist : Array Of Const) : longword;
  1116. begin
  1117. RenderTags := RenderA(rgb , width , height , chunky , palette , readintags(taglist));
  1118. end;
  1119. FUNCTION RGBArrayDiversity(rgb : pULONG; width : WORD; height : WORD; const taglist : Array Of Const) : LONGINT;
  1120. begin
  1121. RGBArrayDiversity := RGBArrayDiversityA(rgb , width , height , readintags(taglist));
  1122. end;
  1123. FUNCTION Scale(engine : POINTER; source : POINTER; dest : POINTER; const taglist : Array Of Const) : longword;
  1124. begin
  1125. Scale := ScaleA(engine , source , dest , readintags(taglist));
  1126. end;
  1127. FUNCTION SortPalette(palette : POINTER; mode : longword; const taglist : Array Of Const) : longword;
  1128. begin
  1129. SortPalette := SortPaletteA(palette , mode , readintags(taglist));
  1130. end;
  1131. PROCEDURE TintRGBArray(source : pULONG; width : WORD; height : WORD; RGB : longword; ratio : WORD; dest : pULONG; const taglist : Array Of Const);
  1132. begin
  1133. TintRGBArrayA(source , width , height , RGB , ratio , dest , readintags(taglist));
  1134. end;
  1135. const
  1136. { Change VERSION and LIBVERSION to proper values }
  1137. VERSION : string[2] = '0';
  1138. LIBVERSION : longword = 0;
  1139. {$ifdef use_init_openlib}
  1140. {$Info Compiling initopening of render.library}
  1141. {$Info don't forget to use InitRENDERLibrary in the beginning of your program}
  1142. var
  1143. render_exit : Pointer;
  1144. procedure CloserenderLibrary;
  1145. begin
  1146. ExitProc := render_exit;
  1147. if RenderBase <> nil then begin
  1148. CloseLibrary(RenderBase);
  1149. RenderBase := nil;
  1150. end;
  1151. end;
  1152. procedure InitRENDERLibrary;
  1153. begin
  1154. RenderBase := nil;
  1155. RenderBase := OpenLibrary(RENDERNAME,LIBVERSION);
  1156. if RenderBase <> nil then begin
  1157. render_exit := ExitProc;
  1158. ExitProc := @CloserenderLibrary;
  1159. end else begin
  1160. MessageBox('FPC Pascal Error',
  1161. 'Can''t open render.library version ' + VERSION + #10 +
  1162. 'Deallocating resources and closing down',
  1163. 'Oops');
  1164. halt(20);
  1165. end;
  1166. end;
  1167. begin
  1168. RENDERIsCompiledHow := 2;
  1169. {$endif use_init_openlib}
  1170. {$ifdef use_auto_openlib}
  1171. {$Info Compiling autoopening of render.library}
  1172. var
  1173. render_exit : Pointer;
  1174. procedure CloserenderLibrary;
  1175. begin
  1176. ExitProc := render_exit;
  1177. if RenderBase <> nil then begin
  1178. CloseLibrary(RenderBase);
  1179. RenderBase := nil;
  1180. end;
  1181. end;
  1182. begin
  1183. RenderBase := nil;
  1184. RenderBase := OpenLibrary(RENDERNAME,LIBVERSION);
  1185. if RenderBase <> nil then begin
  1186. render_exit := ExitProc;
  1187. ExitProc := @CloserenderLibrary;
  1188. RENDERIsCompiledHow := 1;
  1189. end else begin
  1190. MessageBox('FPC Pascal Error',
  1191. 'Can''t open render.library version ' + VERSION + #10 +
  1192. 'Deallocating resources and closing down',
  1193. 'Oops');
  1194. halt(20);
  1195. end;
  1196. {$endif use_auto_openlib}
  1197. {$ifdef dont_use_openlib}
  1198. begin
  1199. RENDERIsCompiledHow := 3;
  1200. {$Warning No autoopening of render.library compiled}
  1201. {$Warning Make sure you open render.library yourself}
  1202. {$endif dont_use_openlib}
  1203. END. (* UNIT RENDER *)
  1204. {
  1205. $Log
  1206. }