ftbitmap.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. /***************************************************************************/
  2. /* */
  3. /* ftbitmap.h */
  4. /* */
  5. /* FreeType utility functions for bitmaps (specification). */
  6. /* */
  7. /* Copyright 2004-2015 by */
  8. /* David Turner, Robert Wilhelm, and Werner Lemberg. */
  9. /* */
  10. /* This file is part of the FreeType project, and may only be used, */
  11. /* modified, and distributed under the terms of the FreeType project */
  12. /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
  13. /* this file you indicate that you have read the license and */
  14. /* understand and accept it fully. */
  15. /* */
  16. /***************************************************************************/
  17. #ifndef __FTBITMAP_H__
  18. #define __FTBITMAP_H__
  19. #include <ft2build.h>
  20. #include FT_FREETYPE_H
  21. #ifdef FREETYPE_H
  22. #error "freetype.h of FreeType 1 has been loaded!"
  23. #error "Please fix the directory search order for header files"
  24. #error "so that freetype.h of FreeType 2 is found first."
  25. #endif
  26. FT_BEGIN_HEADER
  27. /*************************************************************************/
  28. /* */
  29. /* <Section> */
  30. /* bitmap_handling */
  31. /* */
  32. /* <Title> */
  33. /* Bitmap Handling */
  34. /* */
  35. /* <Abstract> */
  36. /* Handling FT_Bitmap objects. */
  37. /* */
  38. /* <Description> */
  39. /* This section contains functions for handling @FT_Bitmap objects. */
  40. /* Note that none of the functions changes the bitmap's `flow' (as */
  41. /* indicated by the sign of the `pitch' field in `FT_Bitmap'). */
  42. /* */
  43. /*************************************************************************/
  44. /*************************************************************************/
  45. /* */
  46. /* <Function> */
  47. /* FT_Bitmap_Init */
  48. /* */
  49. /* <Description> */
  50. /* Initialize a pointer to an @FT_Bitmap structure. */
  51. /* */
  52. /* <InOut> */
  53. /* abitmap :: A pointer to the bitmap structure. */
  54. /* */
  55. /* <Note> */
  56. /* A deprecated name for the same function is `FT_Bitmap_New'. */
  57. /* */
  58. FT_EXPORT( void )
  59. FT_Bitmap_Init( FT_Bitmap *abitmap );
  60. /* deprecated */
  61. FT_EXPORT( void )
  62. FT_Bitmap_New( FT_Bitmap *abitmap );
  63. /*************************************************************************/
  64. /* */
  65. /* <Function> */
  66. /* FT_Bitmap_Copy */
  67. /* */
  68. /* <Description> */
  69. /* Copy a bitmap into another one. */
  70. /* */
  71. /* <Input> */
  72. /* library :: A handle to a library object. */
  73. /* */
  74. /* source :: A handle to the source bitmap. */
  75. /* */
  76. /* <Output> */
  77. /* target :: A handle to the target bitmap. */
  78. /* */
  79. /* <Return> */
  80. /* FreeType error code. 0~means success. */
  81. /* */
  82. FT_EXPORT( FT_Error )
  83. FT_Bitmap_Copy( FT_Library library,
  84. const FT_Bitmap *source,
  85. FT_Bitmap *target);
  86. /*************************************************************************/
  87. /* */
  88. /* <Function> */
  89. /* FT_Bitmap_Embolden */
  90. /* */
  91. /* <Description> */
  92. /* Embolden a bitmap. The new bitmap will be about `xStrength' */
  93. /* pixels wider and `yStrength' pixels higher. The left and bottom */
  94. /* borders are kept unchanged. */
  95. /* */
  96. /* <Input> */
  97. /* library :: A handle to a library object. */
  98. /* */
  99. /* xStrength :: How strong the glyph is emboldened horizontally. */
  100. /* Expressed in 26.6 pixel format. */
  101. /* */
  102. /* yStrength :: How strong the glyph is emboldened vertically. */
  103. /* Expressed in 26.6 pixel format. */
  104. /* */
  105. /* <InOut> */
  106. /* bitmap :: A handle to the target bitmap. */
  107. /* */
  108. /* <Return> */
  109. /* FreeType error code. 0~means success. */
  110. /* */
  111. /* <Note> */
  112. /* The current implementation restricts `xStrength' to be less than */
  113. /* or equal to~8 if bitmap is of pixel_mode @FT_PIXEL_MODE_MONO. */
  114. /* */
  115. /* If you want to embolden the bitmap owned by a @FT_GlyphSlotRec, */
  116. /* you should call @FT_GlyphSlot_Own_Bitmap on the slot first. */
  117. /* */
  118. /* Bitmaps in @FT_PIXEL_MODE_GRAY2 and @FT_PIXEL_MODE_GRAY@ format */
  119. /* are converted to @FT_PIXEL_MODE_GRAY format (i.e., 8bpp). */
  120. /* */
  121. FT_EXPORT( FT_Error )
  122. FT_Bitmap_Embolden( FT_Library library,
  123. FT_Bitmap* bitmap,
  124. FT_Pos xStrength,
  125. FT_Pos yStrength );
  126. /*************************************************************************/
  127. /* */
  128. /* <Function> */
  129. /* FT_Bitmap_Convert */
  130. /* */
  131. /* <Description> */
  132. /* Convert a bitmap object with depth 1bpp, 2bpp, 4bpp, 8bpp or 32bpp */
  133. /* to a bitmap object with depth 8bpp, making the number of used */
  134. /* bytes line (a.k.a. the `pitch') a multiple of `alignment'. */
  135. /* */
  136. /* <Input> */
  137. /* library :: A handle to a library object. */
  138. /* */
  139. /* source :: The source bitmap. */
  140. /* */
  141. /* alignment :: The pitch of the bitmap is a multiple of this */
  142. /* parameter. Common values are 1, 2, or 4. */
  143. /* */
  144. /* <Output> */
  145. /* target :: The target bitmap. */
  146. /* */
  147. /* <Return> */
  148. /* FreeType error code. 0~means success. */
  149. /* */
  150. /* <Note> */
  151. /* It is possible to call @FT_Bitmap_Convert multiple times without */
  152. /* calling @FT_Bitmap_Done (the memory is simply reallocated). */
  153. /* */
  154. /* Use @FT_Bitmap_Done to finally remove the bitmap object. */
  155. /* */
  156. /* The `library' argument is taken to have access to FreeType's */
  157. /* memory handling functions. */
  158. /* */
  159. FT_EXPORT( FT_Error )
  160. FT_Bitmap_Convert( FT_Library library,
  161. const FT_Bitmap *source,
  162. FT_Bitmap *target,
  163. FT_Int alignment );
  164. /*************************************************************************/
  165. /* */
  166. /* <Function> */
  167. /* FT_GlyphSlot_Own_Bitmap */
  168. /* */
  169. /* <Description> */
  170. /* Make sure that a glyph slot owns `slot->bitmap'. */
  171. /* */
  172. /* <Input> */
  173. /* slot :: The glyph slot. */
  174. /* */
  175. /* <Return> */
  176. /* FreeType error code. 0~means success. */
  177. /* */
  178. /* <Note> */
  179. /* This function is to be used in combination with */
  180. /* @FT_Bitmap_Embolden. */
  181. /* */
  182. FT_EXPORT( FT_Error )
  183. FT_GlyphSlot_Own_Bitmap( FT_GlyphSlot slot );
  184. /*************************************************************************/
  185. /* */
  186. /* <Function> */
  187. /* FT_Bitmap_Done */
  188. /* */
  189. /* <Description> */
  190. /* Destroy a bitmap object initialized with @FT_Bitmap_Init. */
  191. /* */
  192. /* <Input> */
  193. /* library :: A handle to a library object. */
  194. /* */
  195. /* bitmap :: The bitmap object to be freed. */
  196. /* */
  197. /* <Return> */
  198. /* FreeType error code. 0~means success. */
  199. /* */
  200. /* <Note> */
  201. /* The `library' argument is taken to have access to FreeType's */
  202. /* memory handling functions. */
  203. /* */
  204. FT_EXPORT( FT_Error )
  205. FT_Bitmap_Done( FT_Library library,
  206. FT_Bitmap *bitmap );
  207. /* */
  208. FT_END_HEADER
  209. #endif /* __FTBITMAP_H__ */
  210. /* END */