blending.inc 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /**--------------------------------------------------------------------------**\
  2. =================================
  3. y_bitmap - Generate bitmaps.
  4. =================================
  5. Description:
  6. Code to generate images on the server in the bitmap format. This is by far
  7. the simplest format to write to as it is just a huge array of colours (at
  8. least 24-bit bitmaps are, and we only do them).
  9. This file combines a colour with alpha on to the pixel already at the given
  10. location.
  11. Legal:
  12. Version: MPL 1.1
  13. The contents of this file are subject to the Mozilla Public License Version
  14. 1.1 (the "License"); you may not use this file except in compliance with
  15. the License. You may obtain a copy of the License at
  16. http://www.mozilla.org/MPL/
  17. Software distributed under the License is distributed on an "AS IS" basis,
  18. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  19. for the specific language governing rights and limitations under the
  20. License.
  21. The Original Code is the YSI utils include.
  22. The Initial Developer of the Original Code is Alex "Y_Less" Cole.
  23. Portions created by the Initial Developer are Copyright (C) 2011
  24. the Initial Developer. All Rights Reserved.
  25. Contributors:
  26. ZeeX, koolk, JoeBullet/Google63, g_aSlice/Slice
  27. Thanks:
  28. JoeBullet/Google63 - Handy arbitrary ASM jump code using SCTRL.
  29. ZeeX - Very productive conversations.
  30. koolk - IsPlayerinAreaEx code.
  31. TheAlpha - Danish translation.
  32. breadfish - German translation.
  33. Fireburn - Dutch translation.
  34. yom - French translation.
  35. 50p - Polish translation.
  36. Zamaroht - Spanish translation.
  37. Dracoblue, sintax, mabako, Xtreme, other coders - Producing other modes
  38. for me to strive to better.
  39. Pixels^ - Running XScripters where the idea was born.
  40. Matite - Pestering me to release it and using it.
  41. Very special thanks to:
  42. Thiadmer - PAWN, whose limits continue to amaze me!
  43. Kye/Kalcor - SA:MP.
  44. SA:MP Team past, present and future - SA:MP.
  45. Version:
  46. 0.1
  47. Changelog:
  48. 29/03/13:
  49. First version.
  50. Functions:
  51. Stock:
  52. -
  53. Inline:
  54. -
  55. Variables:
  56. Global:
  57. -
  58. \**--------------------------------------------------------------------------**/
  59. stock Bitmap_WritePixel(Bitmap:ctx, const x, const y, const colour)
  60. {
  61. new
  62. a = colour & 0xFF;
  63. switch (a)
  64. {
  65. case 0: return;
  66. case 0xFF: Bitmap_WriteCtx(ctx, x, y, colour);
  67. default:
  68. {
  69. new
  70. r = ((colour & 0xFF000000) >>> 8) * a,
  71. g = ((colour & 0x00FF0000) >>> 8) * a,
  72. b = ((colour & 0x0000FF00) >>> 8) * a,
  73. oc = Bitmap_ReadCtx(ctx, x, y);
  74. a = 256 - a;
  75. oc =
  76. ((((oc & 0xFF000000) >>> 8) * a + r) & 0xFF000000) |
  77. ((((oc & 0x00FF0000) >>> 8) * a + g) & 0x00FF0000) |
  78. ((((oc & 0x0000FF00) >>> 8) * a + b) & 0x0000FF00) ;
  79. Bitmap_WriteCtx(ctx, x, y, oc);
  80. }
  81. }
  82. }