dithermatch.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. ////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright 2016 RWS Inc, All Rights Reserved
  4. //
  5. // This program is free software; you can redistribute it and/or modify
  6. // it under the terms of version 2 of the GNU General Public License as published by
  7. // the Free Software Foundation
  8. //
  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. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License along
  15. // with this program; if not, write to the Free Software Foundation, Inc.,
  16. // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. //
  18. #ifndef DITHER_MATCH_H
  19. #define DITHER_MATCH_H
  20. //==============================================
  21. #include "System.h"
  22. #ifdef PATHS_IN_INCLUDES
  23. #include "GREEN/Image/Image.h"
  24. #include "ORANGE/color/colormatch.h"
  25. #else
  26. #include "Image.h"
  27. #include "colormatch.h"
  28. #endif
  29. //==============================================
  30. //==============================================
  31. // Here is the optional user-interactive callback procedure,
  32. // used for long, slow, color mappings.
  33. //==============================================
  34. // dProgress: A value between 0.0 (just started) and
  35. // 1.0 (done). Use can display as he wishes.
  36. // RETURN: User should return 0 for CONTINUE, and
  37. // -1 to ABORT the conversion early! (User hits cancel)
  38. //
  39. //
  40. typedef short (*PDitherCallBack) (double dProgress);
  41. //==============================================
  42. // You supply a general palette to match to,
  43. // a BMP24 image as a TC source, and an
  44. // instantiated, but NOT allocated BMP8 as a
  45. // destination.
  46. //
  47. // THIS WILL Dither to background!
  48. //==============================================
  49. // The optional area parameter sets the approximate
  50. // interval for the callback function (it is not
  51. // time based!) I find 32000 good for a P6/200, but
  52. // smaller numbers can be used for slower machines.
  53. //
  54. extern short rspDither(
  55. RImage* pimSrc, // MUST BE 24-bit!
  56. RImage* pimDst, // MUST be 8-bit
  57. short sStartMap, // palette index
  58. short sNumMap, // # of colors
  59. UCHAR* pRed, // Palette to match to
  60. UCHAR* pGreen,
  61. UCHAR* pBlue,
  62. long lInc = 4,
  63. // User interaction
  64. PDitherCallBack func = NULL,
  65. long lMilli = 500 // time between callbacks
  66. );
  67. //==============================================
  68. // You supply a general palette to match to,
  69. // a BMP24 image as a TC source, and an
  70. // instantiated, but NOT allocated BMP8 as a
  71. // destination.
  72. //
  73. // Does NOT dither at all!
  74. //==============================================
  75. // The optional area parameter sets the approximate
  76. // interval for the callback function (it is not
  77. // time based!) I find 32000 good for a P6/200, but
  78. // smaller numbers can be used for slower machines.
  79. //
  80. extern short rspSimpleMap(
  81. RImage* pimSrc, // MUST BE 24-bit!
  82. RImage* pimDst, // MUST be 8-bit
  83. short sStartMap, // palette index
  84. short sNumMap, // # of colors
  85. UCHAR* pRed, // Palette to match to
  86. UCHAR* pGreen,
  87. UCHAR* pBlue,
  88. long lInc = 4,
  89. // User interaction
  90. PDitherCallBack func = NULL,
  91. long lMilli = 500 // time between callbacks
  92. );
  93. //==============================================
  94. // You supply a general palette to match to,
  95. // a BMP24 image as a TC source, and an
  96. // instantiated, but NOT allocated BMP8 as a
  97. // destination.
  98. //
  99. // this will NOT Dither to the specified background color!
  100. //
  101. // Returns 0 for SUCCESS, -1 for ERROR, 1 for user cancel
  102. //==============================================
  103. //
  104. extern short rspDither(
  105. long lBackR, // Don't dither to this color!
  106. long lBackG,
  107. long lBackB,
  108. UCHAR ucBack, // index to make BKGD
  109. RImage* pimSrc, // MUST BE 24-bit!
  110. RImage* pimDst, // MUST be 8-bit
  111. short sStartMap, // palette index
  112. short sNumMap, // # of colors
  113. UCHAR* pRed, // Palette to match to
  114. UCHAR* pGreen,
  115. UCHAR* pBlue,
  116. long lInc = 4,
  117. // User interaction
  118. PDitherCallBack func = NULL,
  119. long lMilli = 500 // time between callbacks
  120. );
  121. //==============================================
  122. // You supply a general palette to match to,
  123. // a BMP32 image as a TC source, and an
  124. // instantiated, but NOT allocated BMP8 as a
  125. // destination.
  126. //
  127. // THIS WILL NOT Dither to the specified background, which
  128. // is determined by the alpha channel being less than the
  129. // value specified by the user.
  130. //
  131. // Returns 0 for SUCCESS, -1 for ERROR, 1 for user cancel
  132. //==============================================
  133. //
  134. short rspDither(
  135. UCHAR ucForeAlpha, // lower limit for foreground
  136. UCHAR ucBack, // index to make BKGD
  137. RImage* pimSrc, // MUST BE 24-bit!
  138. RImage* pimDst, // MUST be 8-bit
  139. short sStartMap, // palette index
  140. short sNumMap, // # of colors
  141. UCHAR* pRed, // Palette to match to
  142. UCHAR* pGreen,
  143. UCHAR* pBlue,
  144. long lInc = 4,
  145. // User interaction
  146. PDitherCallBack func = NULL,
  147. long lMilli = 500 // time between callbacks
  148. );
  149. //==============================================
  150. // You supply a general palette to match to,
  151. // a BMP32 image as a TC source, and an
  152. // instantiated, but NOT allocated BMP8 as a
  153. // destination.
  154. //
  155. // Does NOT dither at all!
  156. //
  157. // As with dithering, anything below the
  158. // specified alpha threshold is considered a
  159. // background and set to the specified background
  160. // color. If a 0 value is specified for the
  161. // alpha threshold, than no special background
  162. // treatment will occur.
  163. //==============================================
  164. //
  165. short rspSimpleMap(
  166. UCHAR ucForeAlpha, // alpha threshhold
  167. UCHAR ucBack, // map background to this index
  168. RImage* pimSrc, // MUST BE 32-bit!
  169. RImage* pimDst, // MUST be 8-bit
  170. short sStartMap, // palette index
  171. short sNumMap, // # of colors
  172. UCHAR* pRed, // Palette to match to
  173. UCHAR* pGreen,
  174. UCHAR* pBlue,
  175. long lInc = 4,
  176. // User interaction
  177. PDitherCallBack func = NULL,
  178. long lMilli = 500 // time between callbacks
  179. );
  180. //==============================================
  181. //==============================================
  182. //==============================================
  183. #endif