bcfilters.pas 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551
  1. {
  2. Created by BGRA Controls Team
  3. Dibo, Circular, lainz (007) and contributors.
  4. For detailed information see readme.txt
  5. Site: https://sourceforge.net/p/bgra-controls/
  6. Wiki: http://wiki.lazarus.freepascal.org/BGRAControls
  7. Forum: http://forum.lazarus.freepascal.org/index.php/board,46.0.html
  8. }
  9. {******************************* CONTRIBUTOR(S) ******************************
  10. - Edivando S. Santos Brasil | [email protected]
  11. (Compatibility with delphi VCL 11/2018)
  12. ***************************** END CONTRIBUTOR(S) *****************************}
  13. unit BCFilters;
  14. {
  15. // all pixels //
  16. var
  17. i: integer;
  18. p: PBGRAPixel;
  19. begin
  20. p := Bitmap.Data;
  21. for i := Bitmap.NBPixels-1 downto 0 do
  22. begin
  23. p^.red := ;
  24. p^.green := ;
  25. p^.blue := ;
  26. p^.alpha := ;
  27. Inc(p);
  28. end;
  29. // scan line //
  30. var
  31. x, y: integer;
  32. p: PBGRAPixel;
  33. begin
  34. for y := 0 to Bitmap.Height - 1 do
  35. begin
  36. p := Bitmap.Scanline[y];
  37. for x := 0 to Bitmap.Width - 1 do
  38. begin
  39. p^.red := ;
  40. p^.green := ;
  41. p^.blue := ;
  42. p^.alpha := ;
  43. Inc(p);
  44. end;
  45. end;
  46. Bitmap.InvalidateBitmap;
  47. }
  48. {$I bgracontrols.inc}
  49. interface
  50. uses
  51. Classes, SysUtils, {$IFDEF FPC}LCLProc, LazUTF8,{$ELSE}Types, BGRAGraphics, GraphType, FPImage, {$ENDIF} Math, BGRABitmap, BGRABitmapTypes;
  52. type
  53. TBCSimpleFilter = (bcsNone, bcsGameBoyDithering, bcsBlackAndWhiteDithering, bcsInvert,
  54. bcsGrayScale, bcsGrayScaleA,
  55. bcsGrayScaleBGRA, bcsGameBoy, bcsNoise,
  56. bcsNoiseA, bcsNoiseBW, bcsNoiseBWA, bcsTVScanLinesH, bcsTVScanLinesV,
  57. bcsCheckeredL, bcsCheckeredR, bcsBlackAndWhite, bcsInstagram1,
  58. bcsInstagram2, bcsInstagram3, bcsInstagram4, bcsInstagram5, bcsInstagram6,
  59. bcsPhotoNoise, bcsPolaroid, bcsMovement, bcsRBG, bcsGRB, bcsGBR,
  60. bcsBRG, bcsBGR, bcsRRG, bcsRGR, bcsGRR, bcsRRB, bcsRBR, bcsBRR,
  61. bcsGGR, bcsGRG, bcsRGG, bcsGGB, bcsGBG, bcsBGG, bcsBBR, bcsBRB,
  62. bcsRBB, bcsBBG, bcsBGB, bcsGBB, bcsRRR, bcsGGG, bcsBBB);
  63. const
  64. BCSimpleFilterStr: array [TBCSimpleFilter] of string =
  65. ('None', 'GameBoyDithering', 'BlackAndWhiteDithering', 'Invert', 'GrayScale',
  66. 'GrayScaleA', 'GrayScaleBGRA', 'GameBoy',
  67. 'Noise', 'NoiseA', 'NoiseBW', 'NoiseBWA', 'TVScanLinesH', 'TVScanLinesV',
  68. 'CheckeredL', 'CheckeredR', 'BlackAndWhite', 'Instagram1', 'Instagram2',
  69. 'Instagram3', 'Instagram4', 'Instagram5', 'Instagram6', 'PhotoNoise',
  70. 'Polaroid', 'Movement', 'RBG', 'GRB', 'GBR', 'BRG', 'BGR', 'RRG',
  71. 'RGR', 'GRR', 'RRB', 'RBR', 'BRR', 'GGR', 'GRG', 'RGG', 'GGB', 'GBG',
  72. 'BGG', 'BBR', 'BRB', 'RBB', 'BBG', 'BGB', 'GBB', 'RRR', 'GGG', 'BBB');
  73. function StrToTBCSimpleFilter(const s: ansistring): TBCSimpleFilter;
  74. procedure BCSimpleFilterStrList(s: TStrings);
  75. procedure FilterRGB(Bitmap: TBGRABitmap; R, G, B: byte);
  76. procedure RBG(Bitmap: TBGRABitmap);
  77. procedure GRB(Bitmap: TBGRABitmap);
  78. procedure GBR(Bitmap: TBGRABitmap);
  79. procedure BRG(Bitmap: TBGRABitmap);
  80. procedure BGR(Bitmap: TBGRABitmap);
  81. procedure RRG(Bitmap: TBGRABitmap);
  82. procedure RGR(Bitmap: TBGRABitmap);
  83. procedure GRR(Bitmap: TBGRABitmap);
  84. procedure RRB(Bitmap: TBGRABitmap);
  85. procedure RBR(Bitmap: TBGRABitmap);
  86. procedure BRR(Bitmap: TBGRABitmap);
  87. procedure GGR(Bitmap: TBGRABitmap);
  88. procedure GRG(Bitmap: TBGRABitmap);
  89. procedure RGG(Bitmap: TBGRABitmap);
  90. procedure GGB(Bitmap: TBGRABitmap);
  91. procedure GBG(Bitmap: TBGRABitmap);
  92. procedure BGG(Bitmap: TBGRABitmap);
  93. procedure BBR(Bitmap: TBGRABitmap);
  94. procedure BRB(Bitmap: TBGRABitmap);
  95. procedure RBB(Bitmap: TBGRABitmap);
  96. procedure BBG(Bitmap: TBGRABitmap);
  97. procedure BGB(Bitmap: TBGRABitmap);
  98. procedure GBB(Bitmap: TBGRABitmap);
  99. procedure RRR(Bitmap: TBGRABitmap);
  100. procedure GGG(Bitmap: TBGRABitmap);
  101. procedure BBB(Bitmap: TBGRABitmap);
  102. { Invert colors, keep alpha }
  103. procedure Invert(Bitmap: TBGRABitmap); overload;
  104. { Invert colors, advanced options }
  105. procedure Invert(Bitmap: TBGRABitmap; touchR, touchG, touchB, touchA: boolean); overload;
  106. { GrayScale, keep alpha }
  107. procedure GrayScale(Bitmap: TBGRABitmap); overload;
  108. { GrayScale, keep alpha, pallete }
  109. procedure GrayScale(Bitmap: TBGRABitmap; pallete: byte); overload;
  110. { GrayScale, alpha 255}
  111. procedure GrayScaleA(Bitmap: TBGRABitmap);
  112. { GrayScale, using BGRAToGrayScale }
  113. procedure GrayScaleBGRA(Bitmap: TBGRABitmap);
  114. { like GameBoy}
  115. procedure GameBoy(Bitmap: TBGRABitmap);
  116. { Dithering }
  117. procedure GameBoyDithering(Bitmap: TBGRABitmap);
  118. procedure BlackAndWhiteDithering(Bitmap: TBGRABitmap);
  119. { Noise random color, keep alpha }
  120. procedure Noise(Bitmap: TBGRABitmap); overload;
  121. { Noise random color, advanced options }
  122. procedure Noise(Bitmap: TBGRABitmap; touchR, touchG, touchB, touchA: boolean); overload;
  123. { Noise random color, random alpha }
  124. procedure NoiseA(Bitmap: TBGRABitmap);
  125. { Noise random color, set max posible values }
  126. procedure NoiseMax(Bitmap: TBGRABitmap; maxR, maxG, maxB, maxA: byte); overload;
  127. { Noise random color, set max posible values, advanced options }
  128. procedure NoiseMax(Bitmap: TBGRABitmap; maxR, maxG, maxB, maxA: byte;
  129. touchR, touchG, touchB, touchA: boolean); overload;
  130. { Noise black and white, keep alpha }
  131. procedure NoiseBW(Bitmap: TBGRABitmap);
  132. { Noise black and white, random alpha }
  133. procedure NoiseBWA(Bitmap: TBGRABitmap);
  134. { TV Lines Horizontal }
  135. procedure TVScanLinesH(Bitmap: TBGRABitmap);
  136. { TV Lines Vertical }
  137. procedure TVScanLinesV(Bitmap: TBGRABitmap);
  138. { Checkered Left aligned }
  139. procedure CheckeredL(Bitmap: TBGRABitmap);
  140. { Checkered Right aligned }
  141. procedure CheckeredR(Bitmap: TBGRABitmap);
  142. { Black and White, middle 128 }
  143. procedure BlackAndWhite(Bitmap: TBGRABitmap); overload;
  144. { Black and White, custom middle }
  145. procedure BlackAndWhite(Bitmap: TBGRABitmap; middle: byte); overload;
  146. { Instagram Filters }
  147. // sepia
  148. procedure Instagram1(Bitmap: TBGRABitmap);
  149. // blue-green
  150. procedure Instagram2(Bitmap: TBGRABitmap);
  151. // purple
  152. procedure Instagram3(Bitmap: TBGRABitmap);
  153. // blue 3 channels
  154. procedure Instagram4(Bitmap: TBGRABitmap);
  155. // green 3 channels
  156. procedure Instagram5(Bitmap: TBGRABitmap);
  157. // red 3 channels
  158. procedure Instagram6(Bitmap: TBGRABitmap);
  159. // white rounded border
  160. procedure Polaroid(Bitmap: TBGRABitmap);
  161. // blured bw noise
  162. procedure PhotoNoise(Bitmap: TBGRABitmap);
  163. { Pixel movement }
  164. procedure Movement(Bitmap: TBGRABitmap; randXmin: NativeInt = -5;
  165. randXmax: NativeInt = 5; randYmin: NativeInt = -5; randYmax: NativeInt = 5);
  166. procedure Zoomy(Bitmap: TBGRABitmap; xMy, yMy: extended);
  167. { Filters that only need Bitmap as parameter }
  168. procedure SimpleFilter(Bitmap: TBGRABitmap; Filter: TBCSimpleFilter);
  169. implementation
  170. function StrToTBCSimpleFilter(const s: ansistring): TBCSimpleFilter;
  171. var
  172. sf: TBCSimpleFilter;
  173. ls: ansistring;
  174. begin
  175. sf := bcsNone;
  176. Result := sf;
  177. ls := {$IFDEF FPC}UTF8LowerCase{$ELSE}LowerCase{$ENDIF}(s);
  178. for sf := low(TBCSimpleFilter) to high(TBCSimpleFilter) do
  179. if ls = {$IFDEF FPC}UTF8LowerCase{$ELSE}LowerCase{$ENDIF}(BCSimpleFilterStr[sf]) then
  180. begin
  181. Result := sf;
  182. break;
  183. end;
  184. end;
  185. procedure BCSimpleFilterStrList(s: TStrings);
  186. var
  187. sf: TBCSimpleFilter;
  188. begin
  189. for sf := low(TBCSimpleFilter) to high(TBCSimpleFilter) do
  190. s.Add(BCSimpleFilterStr[sf]);
  191. end;
  192. procedure Invert(Bitmap: TBGRABitmap);
  193. var
  194. i: integer;
  195. p: PBGRAPixel;
  196. begin
  197. p := Bitmap.Data;
  198. for i := Bitmap.NBPixels - 1 downto 0 do
  199. begin
  200. p^.red := not p^.red;
  201. p^.green := not p^.green;
  202. p^.blue := not p^.blue;
  203. //p^.alpha := not p^.alpha;
  204. Inc(p);
  205. end;
  206. end;
  207. procedure Invert(Bitmap: TBGRABitmap; touchR, touchG, touchB, touchA: boolean);
  208. var
  209. i: integer;
  210. p: PBGRAPixel;
  211. begin
  212. p := Bitmap.Data;
  213. for i := Bitmap.NBPixels - 1 downto 0 do
  214. begin
  215. if touchR then
  216. p^.red := not p^.red;
  217. if touchG then
  218. p^.green := not p^.green;
  219. if touchB then
  220. p^.blue := not p^.blue;
  221. if touchA then
  222. p^.alpha := not p^.alpha;
  223. Inc(p);
  224. end;
  225. end;
  226. procedure GrayScale(Bitmap: TBGRABitmap);
  227. var
  228. i: integer;
  229. p: PBGRAPixel;
  230. c: byte;
  231. begin
  232. p := Bitmap.Data;
  233. for i := Bitmap.NBPixels - 1 downto 0 do
  234. begin
  235. c := (p^.red + p^.green + p^.blue) div 3;
  236. p^.red := c;
  237. p^.green := c;
  238. p^.blue := c;
  239. //p^.alpha := 255;
  240. Inc(p);
  241. end;
  242. end;
  243. procedure GrayScale(Bitmap: TBGRABitmap; pallete: byte);
  244. var
  245. i, j: integer;
  246. p: PBGRAPixel;
  247. c: byte;
  248. gpallete: array of byte;
  249. begin
  250. if pallete = 0 then
  251. pallete := 1
  252. else if pallete = 255 then
  253. begin
  254. GrayScale(Bitmap);
  255. exit;
  256. end;
  257. SetLength(gpallete, pallete);
  258. for i := 0 to High(gpallete) do
  259. begin
  260. gpallete[i] := (255 * i) div 255;
  261. end;
  262. p := Bitmap.Data;
  263. for i := Bitmap.NBPixels - 1 downto 0 do
  264. begin
  265. c := (p^.red + p^.green + p^.blue) div 3;
  266. for j := 0 to High(gpallete) do
  267. begin
  268. if (c >= gpallete[j]) and (c <= gpallete[j + 1]) then
  269. begin
  270. c := gpallete[j];
  271. break;
  272. end;
  273. end;
  274. p^.red := c;
  275. p^.green := c;
  276. p^.blue := c;
  277. //p^.alpha := 255;
  278. Inc(p);
  279. end;
  280. end;
  281. procedure GrayScaleA(Bitmap: TBGRABitmap);
  282. var
  283. i: integer;
  284. p: PBGRAPixel;
  285. c: byte;
  286. begin
  287. p := Bitmap.Data;
  288. for i := Bitmap.NBPixels - 1 downto 0 do
  289. begin
  290. c := (p^.red + p^.green + p^.blue) div 3;
  291. p^.red := c;
  292. p^.green := c;
  293. p^.blue := c;
  294. p^.alpha := 255;
  295. Inc(p);
  296. end;
  297. end;
  298. procedure GrayScaleBGRA(Bitmap: TBGRABitmap);
  299. begin
  300. Bitmap.InplaceGrayscale;
  301. {var
  302. i: integer;
  303. p: PBGRAPixel;
  304. begin
  305. p := Bitmap.Data;
  306. for i := Bitmap.NBPixels - 1 downto 0 do
  307. begin
  308. p^ := BGRAToGrayscale(p^);
  309. Inc(p);
  310. end;}
  311. end;
  312. procedure GameBoy(Bitmap: TBGRABitmap);
  313. var
  314. i: integer;
  315. p: PBGRAPixel;
  316. c: integer;
  317. begin
  318. p := Bitmap.Data;
  319. for i := Bitmap.NBPixels - 1 downto 0 do
  320. begin
  321. {c := (p^.red + p^.green + p^.blue) div 3;
  322. case c of
  323. 0..63: p^ := BGRA(0,80,32,255);
  324. 64..127: p^ := BGRA(0,104,24,255);
  325. 128..191: p^ := BGRA(0,176,0,255);
  326. 192..255: p^ := BGRA(112,224,48,255);
  327. end;}
  328. c := p^.red + p^.green + p^.blue;
  329. if c <= 382 then
  330. begin
  331. if c <= 191 then
  332. p^ := BGRA(0, 80, 32, 255)
  333. else
  334. p^ := BGRA(0, 104, 24, 255);
  335. end
  336. else
  337. begin
  338. if c <= 573 then
  339. p^ := BGRA(0, 176, 0, 255)
  340. else
  341. p^ := BGRA(112, 224, 48, 255);
  342. end;
  343. Inc(p);
  344. end;
  345. end;
  346. procedure GameBoyDithering(Bitmap: TBGRABitmap);
  347. function find_closest_palette_color(cl: TBGRAPixel): TBGRAPixel;
  348. var
  349. c: integer;
  350. begin
  351. c := cl.red + cl.green + cl.blue;
  352. if c <= 382 then
  353. begin
  354. if c <= 191 then
  355. result := BGRA(0, 80, 32, 255)
  356. else
  357. result := BGRA(0, 104, 24, 255);
  358. end
  359. else
  360. begin
  361. if c <= 573 then
  362. result := BGRA(0, 176, 0, 255)
  363. else
  364. result := BGRA(112, 224, 48, 255);
  365. end;
  366. end;
  367. function multiply_divide(pixel,sum: TBGRAPixel;mult,divi: integer):TBGRAPixel;
  368. begin
  369. result.red := round(pixel.red + sum.red * mult / divi);
  370. result.green := round(pixel.green + sum.green * mult / divi);
  371. result.blue := round(pixel.blue + sum.blue * mult / divi);
  372. end;
  373. var
  374. x, y: integer;
  375. oldpixel, newpixel, quant_error: TBGRAPixel;
  376. begin
  377. for y := 0 to Bitmap.Height do
  378. begin
  379. for x := 0 to Bitmap.Width do
  380. begin
  381. oldpixel := Bitmap.GetPixel(x,y);
  382. newpixel := find_closest_palette_color(oldpixel);
  383. Bitmap.SetPixel(x,y,newpixel);
  384. quant_error.red := oldpixel.red - newpixel.red;
  385. quant_error.green := oldpixel.green - newpixel.green;
  386. quant_error.blue := oldpixel.blue - newpixel.blue;
  387. Bitmap.SetPixel(x + 1, y,multiply_divide(Bitmap.GetPixel(x + 1, y),quant_error,7,16));
  388. Bitmap.SetPixel(x - 1, y + 1,multiply_divide(Bitmap.GetPixel(x - 1, y + 1),quant_error,3,16));
  389. Bitmap.SetPixel(x, y + 1,multiply_divide(Bitmap.GetPixel(x, y + 1),quant_error,5,16));
  390. Bitmap.SetPixel(x + 1, y + 1,multiply_divide(Bitmap.GetPixel(x + 1, y + 1),quant_error,1,16));
  391. end;
  392. end;
  393. end;
  394. procedure BlackAndWhiteDithering(Bitmap: TBGRABitmap);
  395. function find_closest_palette_color(cl: TBGRAPixel): TBGRAPixel;
  396. var
  397. c: integer;
  398. begin
  399. c := cl.red + cl.green + cl.blue;
  400. if c <= 127 then
  401. result := BGRABlack
  402. else
  403. result := BGRAWhite;
  404. end;
  405. function multiply_divide(pixel,sum: TBGRAPixel;mult,divi: integer):TBGRAPixel;
  406. begin
  407. result.red := round(pixel.red + sum.red * mult / divi);
  408. result.green := round(pixel.green + sum.green * mult / divi);
  409. result.blue := round(pixel.blue + sum.blue * mult / divi);
  410. end;
  411. var
  412. x, y: integer;
  413. oldpixel, newpixel, quant_error: TBGRAPixel;
  414. begin
  415. for y := 0 to Bitmap.Height do
  416. begin
  417. for x := 0 to Bitmap.Width do
  418. begin
  419. oldpixel := Bitmap.GetPixel(x,y);
  420. newpixel := find_closest_palette_color(oldpixel);
  421. Bitmap.SetPixel(x,y,newpixel);
  422. quant_error.red := oldpixel.red - newpixel.red;
  423. quant_error.green := oldpixel.green - newpixel.green;
  424. quant_error.blue := oldpixel.blue - newpixel.blue;
  425. Bitmap.SetPixel(x + 1, y,multiply_divide(Bitmap.GetPixel(x + 1, y),quant_error,7,16));
  426. Bitmap.SetPixel(x - 1, y + 1,multiply_divide(Bitmap.GetPixel(x - 1, y + 1),quant_error,3,16));
  427. Bitmap.SetPixel(x, y + 1,multiply_divide(Bitmap.GetPixel(x, y + 1),quant_error,5,16));
  428. Bitmap.SetPixel(x + 1, y + 1,multiply_divide(Bitmap.GetPixel(x + 1, y + 1),quant_error,1,16));
  429. end;
  430. end;
  431. end;
  432. procedure Noise(Bitmap: TBGRABitmap);
  433. var
  434. i: integer;
  435. p: PBGRAPixel;
  436. begin
  437. p := Bitmap.Data;
  438. for i := Bitmap.NBPixels - 1 downto 0 do
  439. begin
  440. p^.red := Random(256);
  441. p^.green := Random(256);
  442. p^.blue := Random(256);
  443. //p^.alpha := Random(256);
  444. Inc(p);
  445. end;
  446. end;
  447. procedure Noise(Bitmap: TBGRABitmap; touchR, touchG, touchB, touchA: boolean);
  448. var
  449. i: integer;
  450. p: PBGRAPixel;
  451. begin
  452. p := Bitmap.Data;
  453. for i := Bitmap.NBPixels - 1 downto 0 do
  454. begin
  455. if touchR then
  456. p^.red := Random(256);
  457. if touchG then
  458. p^.green := Random(256);
  459. if touchB then
  460. p^.blue := Random(256);
  461. if touchA then
  462. p^.alpha := Random(256);
  463. Inc(p);
  464. end;
  465. end;
  466. procedure NoiseA(Bitmap: TBGRABitmap);
  467. var
  468. i: integer;
  469. p: PBGRAPixel;
  470. begin
  471. p := Bitmap.Data;
  472. for i := Bitmap.NBPixels - 1 downto 0 do
  473. begin
  474. p^.red := Random(256);
  475. p^.green := Random(256);
  476. p^.blue := Random(256);
  477. p^.alpha := Random(256);
  478. Inc(p);
  479. end;
  480. end;
  481. procedure NoiseBW(Bitmap: TBGRABitmap);
  482. var
  483. i: integer;
  484. p: PBGRAPixel;
  485. c: byte;
  486. begin
  487. p := Bitmap.Data;
  488. for i := Bitmap.NBPixels - 1 downto 0 do
  489. begin
  490. c := Random(2);
  491. p^.red := c + 255;
  492. p^.green := c + 255;
  493. p^.blue := c + 255;
  494. //p^.alpha := Random(256);
  495. Inc(p);
  496. end;
  497. end;
  498. procedure NoiseBWA(Bitmap: TBGRABitmap);
  499. var
  500. i: integer;
  501. p: PBGRAPixel;
  502. c: byte;
  503. begin
  504. p := Bitmap.Data;
  505. for i := Bitmap.NBPixels - 1 downto 0 do
  506. begin
  507. c := Random(2);
  508. p^.red := c + 255;
  509. p^.green := c + 255;
  510. p^.blue := c + 255;
  511. p^.alpha := Random(256);
  512. Inc(p);
  513. end;
  514. end;
  515. procedure TVScanLinesH(Bitmap: TBGRABitmap);
  516. var
  517. x, y: integer;
  518. p: PBGRAPixel;
  519. begin
  520. for y := 0 to Bitmap.Height - 1 do
  521. begin
  522. p := Bitmap.Scanline[y];
  523. for x := 0 to Bitmap.Width - 1 do
  524. begin
  525. if Odd(y) then
  526. begin
  527. p^.red := 0;
  528. p^.green := 0;
  529. p^.blue := 0;
  530. //p^.alpha := 255;
  531. end;
  532. Inc(p);
  533. end;
  534. end;
  535. Bitmap.InvalidateBitmap;
  536. end;
  537. procedure TVScanLinesV(Bitmap: TBGRABitmap);
  538. var
  539. x, y: integer;
  540. p: PBGRAPixel;
  541. begin
  542. for y := 0 to Bitmap.Height - 1 do
  543. begin
  544. p := Bitmap.Scanline[y];
  545. for x := 0 to Bitmap.Width - 1 do
  546. begin
  547. if Odd(x) then
  548. begin
  549. p^.red := 0;
  550. p^.green := 0;
  551. p^.blue := 0;
  552. //p^.alpha := 255;
  553. end;
  554. Inc(p);
  555. end;
  556. end;
  557. Bitmap.InvalidateBitmap;
  558. end;
  559. procedure CheckeredL(Bitmap: TBGRABitmap);
  560. var
  561. x, y: integer;
  562. p: PBGRAPixel;
  563. begin
  564. for y := 0 to Bitmap.Height - 1 do
  565. begin
  566. p := Bitmap.Scanline[y];
  567. for x := 0 to Bitmap.Width - 1 do
  568. begin
  569. if Odd(y) and Odd(x) or not Odd(y) and not Odd(x) then
  570. begin
  571. p^.red := 0;
  572. p^.green := 0;
  573. p^.blue := 0;
  574. p^.alpha := 255;
  575. end;
  576. Inc(p);
  577. end;
  578. end;
  579. Bitmap.InvalidateBitmap;
  580. end;
  581. procedure CheckeredR(Bitmap: TBGRABitmap);
  582. var
  583. x, y: integer;
  584. p: PBGRAPixel;
  585. begin
  586. for y := 0 to Bitmap.Height - 1 do
  587. begin
  588. p := Bitmap.Scanline[y];
  589. for x := 0 to Bitmap.Width - 1 do
  590. begin
  591. if not Odd(y) and Odd(x) or Odd(y) and not Odd(x) then
  592. begin
  593. p^.red := 0;
  594. p^.green := 0;
  595. p^.blue := 0;
  596. p^.alpha := 255;
  597. end;
  598. Inc(p);
  599. end;
  600. end;
  601. Bitmap.InvalidateBitmap;
  602. end;
  603. procedure BlackAndWhite(Bitmap: TBGRABitmap);
  604. var
  605. i: integer;
  606. p: PBGRAPixel;
  607. c: byte;
  608. begin
  609. p := Bitmap.Data;
  610. for i := Bitmap.NBPixels - 1 downto 0 do
  611. begin
  612. c := (p^.red + p^.green + p^.blue) div 3;
  613. if c >= 128 then
  614. c := 255
  615. else
  616. c := 0;
  617. p^.red := c;
  618. p^.green := c;
  619. p^.blue := c;
  620. if p^.alpha > 0 then
  621. p^.alpha := 255;
  622. Inc(p);
  623. end;
  624. end;
  625. procedure BlackAndWhite(Bitmap: TBGRABitmap; middle: byte);
  626. var
  627. i: integer;
  628. p: PBGRAPixel;
  629. c: byte;
  630. begin
  631. p := Bitmap.Data;
  632. for i := Bitmap.NBPixels - 1 downto 0 do
  633. begin
  634. c := (p^.red + p^.green + p^.blue) div 3;
  635. if c >= middle then
  636. c := 255
  637. else
  638. c := 0;
  639. p^.red := c;
  640. p^.green := c;
  641. p^.blue := c;
  642. if p^.alpha > 0 then
  643. p^.alpha := 255;
  644. Inc(p);
  645. end;
  646. end;
  647. procedure Movement(Bitmap: TBGRABitmap; randXmin: NativeInt = -5;
  648. randXmax: NativeInt = 5; randYmin: NativeInt = -5; randYmax: NativeInt = 5);
  649. var
  650. x, y: integer;
  651. p: PBGRAPixel;
  652. begin
  653. for y := 0 to Bitmap.Height - 1 do
  654. begin
  655. p := Bitmap.Scanline[y];
  656. for x := 0 to Bitmap.Width - 1 do
  657. begin
  658. p^ := Bitmap.GetPixel(x + RandomRange(randXmin, randXmax), y +
  659. RandomRange(randYmin, randYmax));
  660. Inc(p);
  661. end;
  662. end;
  663. Bitmap.InvalidateBitmap;
  664. end;
  665. procedure Zoomy(Bitmap: TBGRABitmap; xMy, yMy: extended);
  666. var
  667. x, y: integer;
  668. p: PBGRAPixel;
  669. begin
  670. for y := 0 to Bitmap.Height - 1 do
  671. begin
  672. p := Bitmap.Scanline[y];
  673. for x := 0 to Bitmap.Width - 1 do
  674. begin
  675. p^{.red} := Bitmap.GetPixel(x * xMy, y * yMy);
  676. {p^.green := 0;
  677. p^.blue := 0;
  678. p^.alpha := 255;}
  679. Inc(p);
  680. end;
  681. end;
  682. Bitmap.InvalidateBitmap;
  683. end;
  684. procedure SimpleFilter(Bitmap: TBGRABitmap; Filter: TBCSimpleFilter);
  685. begin
  686. case Filter of
  687. bcsGameBoyDithering: GameBoyDithering(Bitmap);
  688. bcsBlackAndWhiteDithering: BlackAndWhiteDithering(Bitmap);
  689. bcsInvert: Invert(Bitmap);
  690. bcsGrayScale: GrayScale(Bitmap);
  691. bcsGrayScaleA: GrayScaleA(Bitmap);
  692. bcsGrayScaleBGRA: GrayScaleBGRA(Bitmap);
  693. bcsGameBoy: GameBoy(Bitmap);
  694. bcsNoise: Noise(Bitmap);
  695. bcsNoiseA: NoiseA(Bitmap);
  696. bcsNoiseBW: NoiseBW(Bitmap);
  697. bcsNoiseBWA: NoiseBWA(Bitmap);
  698. bcsTVScanLinesH: TVScanLinesH(Bitmap);
  699. bcsTVScanLinesV: TVScanLinesV(Bitmap);
  700. bcsCheckeredL: CheckeredL(Bitmap);
  701. bcsCheckeredR: CheckeredR(Bitmap);
  702. bcsBlackAndWhite: BlackAndWhite(Bitmap);
  703. bcsInstagram1: Instagram1(Bitmap);
  704. bcsInstagram2: Instagram2(Bitmap);
  705. bcsInstagram3: Instagram3(Bitmap);
  706. bcsInstagram4: Instagram4(Bitmap);
  707. bcsInstagram5: Instagram5(Bitmap);
  708. bcsInstagram6: Instagram6(Bitmap);
  709. bcsPhotoNoise: PhotoNoise(Bitmap);
  710. bcsPolaroid: Polaroid(Bitmap);
  711. bcsMovement: Movement(Bitmap);
  712. bcsRBG: RBG(Bitmap);
  713. bcsGRB: GRB(Bitmap);
  714. bcsGBR: GBR(Bitmap);
  715. bcsBRG: BRG(Bitmap);
  716. bcsBGR: BGR(Bitmap);
  717. bcsRRG: RRG(Bitmap);
  718. bcsRGR: RGR(Bitmap);
  719. bcsGRR: GRR(Bitmap);
  720. bcsRRB: RRB(Bitmap);
  721. bcsRBR: RBR(Bitmap);
  722. bcsBRR: BRR(Bitmap);
  723. bcsGGR: GGR(Bitmap);
  724. bcsGRG: GRG(Bitmap);
  725. bcsRGG: RGG(Bitmap);
  726. bcsGGB: GGB(Bitmap);
  727. bcsGBG: GBG(Bitmap);
  728. bcsBGG: BGG(Bitmap);
  729. bcsBBR: BBR(Bitmap);
  730. bcsBRB: BRB(Bitmap);
  731. bcsRBB: RBB(Bitmap);
  732. bcsBBG: BBG(Bitmap);
  733. bcsBGB: BGB(Bitmap);
  734. bcsGBB: GBB(Bitmap);
  735. bcsRRR: RRR(Bitmap);
  736. bcsGGG: GGG(Bitmap);
  737. bcsBBB: BBB(Bitmap);
  738. end;
  739. end;
  740. procedure NoiseMax(Bitmap: TBGRABitmap; maxR, maxG, maxB, maxA: byte);
  741. var
  742. i: integer;
  743. p: PBGRAPixel;
  744. begin
  745. p := Bitmap.Data;
  746. for i := Bitmap.NBPixels - 1 downto 0 do
  747. begin
  748. p^.red := Random(maxR + 1);
  749. p^.green := Random(maxG + 1);
  750. p^.blue := Random(maxB + 1);
  751. p^.alpha := Random(maxA + 1);
  752. Inc(p);
  753. end;
  754. end;
  755. procedure NoiseMax(Bitmap: TBGRABitmap; maxR, maxG, maxB, maxA: byte;
  756. touchR, touchG, touchB, touchA: boolean);
  757. var
  758. i: integer;
  759. p: PBGRAPixel;
  760. begin
  761. p := Bitmap.Data;
  762. for i := Bitmap.NBPixels - 1 downto 0 do
  763. begin
  764. if touchR then
  765. p^.red := Random(maxR + 1);
  766. if touchG then
  767. p^.green := Random(maxG + 1);
  768. if touchB then
  769. p^.blue := Random(maxB + 1);
  770. if touchA then
  771. p^.alpha := Random(maxA + 1);
  772. Inc(p);
  773. end;
  774. end;
  775. // 1
  776. procedure Instagram1(Bitmap: TBGRABitmap);
  777. var
  778. i: integer;
  779. p: PBGRAPixel;
  780. begin
  781. p := Bitmap.Data;
  782. for i := Bitmap.NBPixels - 1 downto 0 do
  783. begin
  784. p^.red := round(p^.red * 0.75);
  785. p^.green := round(p^.red * 0.50);
  786. p^.blue := round(p^.red * 0.25);
  787. //p^.alpha := ;
  788. Inc(p);
  789. end;
  790. end;
  791. // 2
  792. procedure Instagram2(Bitmap: TBGRABitmap);
  793. var
  794. i: integer;
  795. p: PBGRAPixel;
  796. begin
  797. p := Bitmap.Data;
  798. for i := Bitmap.NBPixels - 1 downto 0 do
  799. begin
  800. p^.red := round(p^.red * 0.75);
  801. p^.green := round(p^.green * 0.50);
  802. p^.blue := round(p^.blue * 0.25);
  803. //p^.alpha := ;
  804. Inc(p);
  805. end;
  806. end;
  807. // 3
  808. procedure Instagram3(Bitmap: TBGRABitmap);
  809. var
  810. i: integer;
  811. p: PBGRAPixel;
  812. begin
  813. p := Bitmap.Data;
  814. for i := Bitmap.NBPixels - 1 downto 0 do
  815. begin
  816. p^.red := p^.red;
  817. p^.green := round(p^.green * 0.50);
  818. p^.blue := round(p^.blue * 0.50);
  819. //p^.alpha := ;
  820. Inc(p);
  821. end;
  822. end;
  823. // 4
  824. procedure Instagram4(Bitmap: TBGRABitmap);
  825. begin
  826. BBB(Bitmap);
  827. end;
  828. // 5
  829. procedure Instagram5(Bitmap: TBGRABitmap);
  830. begin
  831. GGG(Bitmap);
  832. end;
  833. // 6
  834. procedure Instagram6(Bitmap: TBGRABitmap);
  835. begin
  836. RRR(Bitmap);
  837. end;
  838. procedure Polaroid(Bitmap: TBGRABitmap);
  839. var
  840. tmp: TBGRABitmap;
  841. begin
  842. tmp := TBGRABitmap.Create(Bitmap.Width, Bitmap.Height, BGRAWhite);
  843. tmp.EraseRoundRectAntialias(
  844. Round(Bitmap.Width * 0.05),
  845. Round(Bitmap.Height * 0.05),
  846. Bitmap.Width - Round(Bitmap.Width * 0.05),
  847. Bitmap.Height - Round(Bitmap.Height * 0.05),
  848. Round(Bitmap.Width * 0.05),
  849. Round(Bitmap.Height * 0.05),
  850. 255, []);
  851. Bitmap.BlendImage(0, 0, tmp, boLinearBlend);
  852. tmp.Free;
  853. end;
  854. procedure PhotoNoise(Bitmap: TBGRABitmap);
  855. var
  856. tmp: TBGRABitmap;
  857. begin
  858. tmp := TBGRABitmap.Create(Bitmap.Width, Bitmap.Height);
  859. NoiseBWA(tmp);
  860. BGRAReplace(tmp, tmp.FilterBlurRadial(1, rbFast));
  861. Bitmap.BlendImageOver(0, 0, tmp, boLinearBlend, 25);
  862. tmp.Free;
  863. end;
  864. {Change colors}
  865. procedure FilterRGB(Bitmap: TBGRABitmap; R, G, B: byte);
  866. var
  867. x, y: integer;
  868. p: PBGRAPixel;
  869. begin
  870. for y := 0 to Bitmap.Height - 1 do
  871. begin
  872. p := Bitmap.Scanline[y];
  873. for x := 0 to Bitmap.Width - 1 do
  874. begin
  875. p^.red := round(p^.red * (R / 100));
  876. p^.green := round(p^.green * (G / 100));
  877. p^.blue := round(p^.blue * (B / 100));
  878. Inc(p);
  879. end;
  880. end;
  881. Bitmap.InvalidateBitmap;
  882. end;
  883. procedure RBG(Bitmap: TBGRABitmap);
  884. var
  885. x, y: integer;
  886. p: PBGRAPixel;
  887. r, g, b: byte;
  888. begin
  889. for y := 0 to Bitmap.Height - 1 do
  890. begin
  891. p := Bitmap.Scanline[y];
  892. for x := 0 to Bitmap.Width - 1 do
  893. begin
  894. r := p^.red;
  895. g := p^.green;
  896. b := p^.blue;
  897. p^.red := r;
  898. p^.green := b;
  899. p^.blue := g;
  900. Inc(p);
  901. end;
  902. end;
  903. Bitmap.InvalidateBitmap;
  904. end;
  905. procedure GRB(Bitmap: TBGRABitmap);
  906. var
  907. x, y: integer;
  908. p: PBGRAPixel;
  909. r, g, b: byte;
  910. begin
  911. for y := 0 to Bitmap.Height - 1 do
  912. begin
  913. p := Bitmap.Scanline[y];
  914. for x := 0 to Bitmap.Width - 1 do
  915. begin
  916. r := p^.red;
  917. g := p^.green;
  918. b := p^.blue;
  919. p^.red := g;
  920. p^.green := r;
  921. p^.blue := b;
  922. Inc(p);
  923. end;
  924. end;
  925. Bitmap.InvalidateBitmap;
  926. end;
  927. procedure GBR(Bitmap: TBGRABitmap);
  928. var
  929. x, y: integer;
  930. p: PBGRAPixel;
  931. r, g, b: byte;
  932. begin
  933. for y := 0 to Bitmap.Height - 1 do
  934. begin
  935. p := Bitmap.Scanline[y];
  936. for x := 0 to Bitmap.Width - 1 do
  937. begin
  938. r := p^.red;
  939. g := p^.green;
  940. b := p^.blue;
  941. p^.red := g;
  942. p^.green := b;
  943. p^.blue := r;
  944. Inc(p);
  945. end;
  946. end;
  947. Bitmap.InvalidateBitmap;
  948. end;
  949. procedure BRG(Bitmap: TBGRABitmap);
  950. var
  951. x, y: integer;
  952. p: PBGRAPixel;
  953. r, g, b: byte;
  954. begin
  955. for y := 0 to Bitmap.Height - 1 do
  956. begin
  957. p := Bitmap.Scanline[y];
  958. for x := 0 to Bitmap.Width - 1 do
  959. begin
  960. r := p^.red;
  961. g := p^.green;
  962. b := p^.blue;
  963. p^.red := b;
  964. p^.green := r;
  965. p^.blue := g;
  966. Inc(p);
  967. end;
  968. end;
  969. Bitmap.InvalidateBitmap;
  970. end;
  971. procedure BGR(Bitmap: TBGRABitmap);
  972. var
  973. x, y: integer;
  974. p: PBGRAPixel;
  975. r, g, b: byte;
  976. begin
  977. for y := 0 to Bitmap.Height - 1 do
  978. begin
  979. p := Bitmap.Scanline[y];
  980. for x := 0 to Bitmap.Width - 1 do
  981. begin
  982. r := p^.red;
  983. g := p^.green;
  984. b := p^.blue;
  985. p^.red := b;
  986. p^.green := g;
  987. p^.blue := r;
  988. Inc(p);
  989. end;
  990. end;
  991. Bitmap.InvalidateBitmap;
  992. end;
  993. procedure RRG(Bitmap: TBGRABitmap);
  994. var
  995. x, y: integer;
  996. p: PBGRAPixel;
  997. r, g: byte;
  998. begin
  999. for y := 0 to Bitmap.Height - 1 do
  1000. begin
  1001. p := Bitmap.Scanline[y];
  1002. for x := 0 to Bitmap.Width - 1 do
  1003. begin
  1004. r := p^.red;
  1005. g := p^.green;
  1006. p^.red := r;
  1007. p^.green := r;
  1008. p^.blue := g;
  1009. Inc(p);
  1010. end;
  1011. end;
  1012. Bitmap.InvalidateBitmap;
  1013. end;
  1014. procedure RGR(Bitmap: TBGRABitmap);
  1015. var
  1016. x, y: integer;
  1017. p: PBGRAPixel;
  1018. r, g: byte;
  1019. begin
  1020. for y := 0 to Bitmap.Height - 1 do
  1021. begin
  1022. p := Bitmap.Scanline[y];
  1023. for x := 0 to Bitmap.Width - 1 do
  1024. begin
  1025. r := p^.red;
  1026. g := p^.green;
  1027. p^.red := r;
  1028. p^.green := g;
  1029. p^.blue := r;
  1030. Inc(p);
  1031. end;
  1032. end;
  1033. Bitmap.InvalidateBitmap;
  1034. end;
  1035. procedure GRR(Bitmap: TBGRABitmap);
  1036. var
  1037. x, y: integer;
  1038. p: PBGRAPixel;
  1039. r, g: byte;
  1040. begin
  1041. for y := 0 to Bitmap.Height - 1 do
  1042. begin
  1043. p := Bitmap.Scanline[y];
  1044. for x := 0 to Bitmap.Width - 1 do
  1045. begin
  1046. r := p^.red;
  1047. g := p^.green;
  1048. p^.red := g;
  1049. p^.green := r;
  1050. p^.blue := r;
  1051. Inc(p);
  1052. end;
  1053. end;
  1054. Bitmap.InvalidateBitmap;
  1055. end;
  1056. procedure RRB(Bitmap: TBGRABitmap);
  1057. var
  1058. x, y: integer;
  1059. p: PBGRAPixel;
  1060. r, b: byte;
  1061. begin
  1062. for y := 0 to Bitmap.Height - 1 do
  1063. begin
  1064. p := Bitmap.Scanline[y];
  1065. for x := 0 to Bitmap.Width - 1 do
  1066. begin
  1067. r := p^.red;
  1068. b := p^.blue;
  1069. p^.red := r;
  1070. p^.green := r;
  1071. p^.blue := b;
  1072. Inc(p);
  1073. end;
  1074. end;
  1075. Bitmap.InvalidateBitmap;
  1076. end;
  1077. procedure RBR(Bitmap: TBGRABitmap);
  1078. var
  1079. x, y: integer;
  1080. p: PBGRAPixel;
  1081. r, b: byte;
  1082. begin
  1083. for y := 0 to Bitmap.Height - 1 do
  1084. begin
  1085. p := Bitmap.Scanline[y];
  1086. for x := 0 to Bitmap.Width - 1 do
  1087. begin
  1088. r := p^.red;
  1089. b := p^.blue;
  1090. p^.red := r;
  1091. p^.green := b;
  1092. p^.blue := r;
  1093. Inc(p);
  1094. end;
  1095. end;
  1096. Bitmap.InvalidateBitmap;
  1097. end;
  1098. procedure BRR(Bitmap: TBGRABitmap);
  1099. var
  1100. x, y: integer;
  1101. p: PBGRAPixel;
  1102. r, b: byte;
  1103. begin
  1104. for y := 0 to Bitmap.Height - 1 do
  1105. begin
  1106. p := Bitmap.Scanline[y];
  1107. for x := 0 to Bitmap.Width - 1 do
  1108. begin
  1109. r := p^.red;
  1110. b := p^.blue;
  1111. p^.red := b;
  1112. p^.green := r;
  1113. p^.blue := r;
  1114. Inc(p);
  1115. end;
  1116. end;
  1117. Bitmap.InvalidateBitmap;
  1118. end;
  1119. procedure GGR(Bitmap: TBGRABitmap);
  1120. var
  1121. x, y: integer;
  1122. p: PBGRAPixel;
  1123. r, g: byte;
  1124. begin
  1125. for y := 0 to Bitmap.Height - 1 do
  1126. begin
  1127. p := Bitmap.Scanline[y];
  1128. for x := 0 to Bitmap.Width - 1 do
  1129. begin
  1130. r := p^.red;
  1131. g := p^.green;
  1132. p^.red := g;
  1133. p^.green := g;
  1134. p^.blue := r;
  1135. Inc(p);
  1136. end;
  1137. end;
  1138. Bitmap.InvalidateBitmap;
  1139. end;
  1140. procedure GRG(Bitmap: TBGRABitmap);
  1141. var
  1142. x, y: integer;
  1143. p: PBGRAPixel;
  1144. r, g: byte;
  1145. begin
  1146. for y := 0 to Bitmap.Height - 1 do
  1147. begin
  1148. p := Bitmap.Scanline[y];
  1149. for x := 0 to Bitmap.Width - 1 do
  1150. begin
  1151. r := p^.red;
  1152. g := p^.green;
  1153. p^.red := g;
  1154. p^.green := r;
  1155. p^.blue := g;
  1156. Inc(p);
  1157. end;
  1158. end;
  1159. Bitmap.InvalidateBitmap;
  1160. end;
  1161. procedure RGG(Bitmap: TBGRABitmap);
  1162. var
  1163. x, y: integer;
  1164. p: PBGRAPixel;
  1165. r, g: byte;
  1166. begin
  1167. for y := 0 to Bitmap.Height - 1 do
  1168. begin
  1169. p := Bitmap.Scanline[y];
  1170. for x := 0 to Bitmap.Width - 1 do
  1171. begin
  1172. r := p^.red;
  1173. g := p^.green;
  1174. p^.red := r;
  1175. p^.green := g;
  1176. p^.blue := g;
  1177. Inc(p);
  1178. end;
  1179. end;
  1180. Bitmap.InvalidateBitmap;
  1181. end;
  1182. procedure GGB(Bitmap: TBGRABitmap);
  1183. var
  1184. x, y: integer;
  1185. p: PBGRAPixel;
  1186. g, b: byte;
  1187. begin
  1188. for y := 0 to Bitmap.Height - 1 do
  1189. begin
  1190. p := Bitmap.Scanline[y];
  1191. for x := 0 to Bitmap.Width - 1 do
  1192. begin
  1193. g := p^.green;
  1194. b := p^.blue;
  1195. p^.red := g;
  1196. p^.green := g;
  1197. p^.blue := b;
  1198. Inc(p);
  1199. end;
  1200. end;
  1201. Bitmap.InvalidateBitmap;
  1202. end;
  1203. procedure GBG(Bitmap: TBGRABitmap);
  1204. var
  1205. x, y: integer;
  1206. p: PBGRAPixel;
  1207. g, b: byte;
  1208. begin
  1209. for y := 0 to Bitmap.Height - 1 do
  1210. begin
  1211. p := Bitmap.Scanline[y];
  1212. for x := 0 to Bitmap.Width - 1 do
  1213. begin
  1214. g := p^.green;
  1215. b := p^.blue;
  1216. p^.red := g;
  1217. p^.green := b;
  1218. p^.blue := g;
  1219. Inc(p);
  1220. end;
  1221. end;
  1222. Bitmap.InvalidateBitmap;
  1223. end;
  1224. procedure BGG(Bitmap: TBGRABitmap);
  1225. var
  1226. x, y: integer;
  1227. p: PBGRAPixel;
  1228. g, b: byte;
  1229. begin
  1230. for y := 0 to Bitmap.Height - 1 do
  1231. begin
  1232. p := Bitmap.Scanline[y];
  1233. for x := 0 to Bitmap.Width - 1 do
  1234. begin
  1235. g := p^.green;
  1236. b := p^.blue;
  1237. p^.red := b;
  1238. p^.green := g;
  1239. p^.blue := g;
  1240. Inc(p);
  1241. end;
  1242. end;
  1243. Bitmap.InvalidateBitmap;
  1244. end;
  1245. procedure BBR(Bitmap: TBGRABitmap);
  1246. var
  1247. x, y: integer;
  1248. p: PBGRAPixel;
  1249. r, b: byte;
  1250. begin
  1251. for y := 0 to Bitmap.Height - 1 do
  1252. begin
  1253. p := Bitmap.Scanline[y];
  1254. for x := 0 to Bitmap.Width - 1 do
  1255. begin
  1256. r := p^.red;
  1257. b := p^.blue;
  1258. p^.red := b;
  1259. p^.green := b;
  1260. p^.blue := r;
  1261. Inc(p);
  1262. end;
  1263. end;
  1264. Bitmap.InvalidateBitmap;
  1265. end;
  1266. procedure BRB(Bitmap: TBGRABitmap);
  1267. var
  1268. x, y: integer;
  1269. p: PBGRAPixel;
  1270. r, b: byte;
  1271. begin
  1272. for y := 0 to Bitmap.Height - 1 do
  1273. begin
  1274. p := Bitmap.Scanline[y];
  1275. for x := 0 to Bitmap.Width - 1 do
  1276. begin
  1277. r := p^.red;
  1278. b := p^.blue;
  1279. p^.red := b;
  1280. p^.green := r;
  1281. p^.blue := b;
  1282. Inc(p);
  1283. end;
  1284. end;
  1285. Bitmap.InvalidateBitmap;
  1286. end;
  1287. procedure RBB(Bitmap: TBGRABitmap);
  1288. var
  1289. x, y: integer;
  1290. p: PBGRAPixel;
  1291. r, b: byte;
  1292. begin
  1293. for y := 0 to Bitmap.Height - 1 do
  1294. begin
  1295. p := Bitmap.Scanline[y];
  1296. for x := 0 to Bitmap.Width - 1 do
  1297. begin
  1298. r := p^.red;
  1299. b := p^.blue;
  1300. p^.red := r;
  1301. p^.green := b;
  1302. p^.blue := b;
  1303. Inc(p);
  1304. end;
  1305. end;
  1306. Bitmap.InvalidateBitmap;
  1307. end;
  1308. procedure BBG(Bitmap: TBGRABitmap);
  1309. var
  1310. x, y: integer;
  1311. p: PBGRAPixel;
  1312. g, b: byte;
  1313. begin
  1314. for y := 0 to Bitmap.Height - 1 do
  1315. begin
  1316. p := Bitmap.Scanline[y];
  1317. for x := 0 to Bitmap.Width - 1 do
  1318. begin
  1319. g := p^.green;
  1320. b := p^.blue;
  1321. p^.red := b;
  1322. p^.green := b;
  1323. p^.blue := g;
  1324. Inc(p);
  1325. end;
  1326. end;
  1327. Bitmap.InvalidateBitmap;
  1328. end;
  1329. procedure BGB(Bitmap: TBGRABitmap);
  1330. var
  1331. x, y: integer;
  1332. p: PBGRAPixel;
  1333. g, b: byte;
  1334. begin
  1335. for y := 0 to Bitmap.Height - 1 do
  1336. begin
  1337. p := Bitmap.Scanline[y];
  1338. for x := 0 to Bitmap.Width - 1 do
  1339. begin
  1340. g := p^.green;
  1341. b := p^.blue;
  1342. p^.red := b;
  1343. p^.green := g;
  1344. p^.blue := b;
  1345. Inc(p);
  1346. end;
  1347. end;
  1348. Bitmap.InvalidateBitmap;
  1349. end;
  1350. procedure GBB(Bitmap: TBGRABitmap);
  1351. var
  1352. x, y: integer;
  1353. p: PBGRAPixel;
  1354. g, b: byte;
  1355. begin
  1356. for y := 0 to Bitmap.Height - 1 do
  1357. begin
  1358. p := Bitmap.Scanline[y];
  1359. for x := 0 to Bitmap.Width - 1 do
  1360. begin
  1361. g := p^.green;
  1362. b := p^.blue;
  1363. p^.red := g;
  1364. p^.green := b;
  1365. p^.blue := b;
  1366. Inc(p);
  1367. end;
  1368. end;
  1369. Bitmap.InvalidateBitmap;
  1370. end;
  1371. procedure RRR(Bitmap: TBGRABitmap);
  1372. var
  1373. x, y: integer;
  1374. p: PBGRAPixel;
  1375. begin
  1376. for y := 0 to Bitmap.Height - 1 do
  1377. begin
  1378. p := Bitmap.Scanline[y];
  1379. for x := 0 to Bitmap.Width - 1 do
  1380. begin
  1381. p^.green := p^.red;
  1382. p^.blue := p^.red;
  1383. Inc(p);
  1384. end;
  1385. end;
  1386. Bitmap.InvalidateBitmap;
  1387. end;
  1388. procedure GGG(Bitmap: TBGRABitmap);
  1389. var
  1390. x, y: integer;
  1391. p: PBGRAPixel;
  1392. begin
  1393. for y := 0 to Bitmap.Height - 1 do
  1394. begin
  1395. p := Bitmap.Scanline[y];
  1396. for x := 0 to Bitmap.Width - 1 do
  1397. begin
  1398. p^.red := p^.green;
  1399. p^.blue := p^.green;
  1400. Inc(p);
  1401. end;
  1402. end;
  1403. Bitmap.InvalidateBitmap;
  1404. end;
  1405. procedure BBB(Bitmap: TBGRABitmap);
  1406. var
  1407. x, y: integer;
  1408. p: PBGRAPixel;
  1409. begin
  1410. for y := 0 to Bitmap.Height - 1 do
  1411. begin
  1412. p := Bitmap.Scanline[y];
  1413. for x := 0 to Bitmap.Width - 1 do
  1414. begin
  1415. p^.red := p^.blue;
  1416. p^.green := p^.blue;
  1417. Inc(p);
  1418. end;
  1419. end;
  1420. Bitmap.InvalidateBitmap;
  1421. end;
  1422. end.