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