1 /****************************************************************************
5 * FreeType utility functions for bitmaps (specification).
7 * Copyright (C) 2004-2020 by
8 * David Turner, Robert Wilhelm, and Werner Lemberg.
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.
23 #include <freetype/freetype.h>
24 #include <freetype/ftcolor.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."
36 /**************************************************************************
45 * Handling FT_Bitmap objects.
48 * This section contains functions for handling @FT_Bitmap objects,
49 * automatically adjusting the target's bitmap buffer size as needed.
51 * Note that none of the functions changes the bitmap's 'flow' (as
52 * indicated by the sign of the `pitch` field in @FT_Bitmap).
54 * To set the flow, assign an appropriate positive or negative value to
55 * the `pitch` field of the target @FT_Bitmap object after calling
56 * @FT_Bitmap_Init but before calling any of the other functions
61 /**************************************************************************
67 * Initialize a pointer to an @FT_Bitmap structure.
71 * A pointer to the bitmap structure.
74 * A deprecated name for the same function is `FT_Bitmap_New`.
77 FT_Bitmap_Init( FT_Bitmap *abitmap );
82 FT_Bitmap_New( FT_Bitmap *abitmap );
85 /**************************************************************************
91 * Copy a bitmap into another one.
95 * A handle to a library object.
98 * A handle to the source bitmap.
102 * A handle to the target bitmap.
105 * FreeType error code. 0~means success.
108 * `source->buffer` and `target->buffer` must neither be equal nor
111 FT_EXPORT( FT_Error )
112 FT_Bitmap_Copy( FT_Library library,
113 const FT_Bitmap *source,
117 /**************************************************************************
123 * Embolden a bitmap. The new bitmap will be about `xStrength` pixels
124 * wider and `yStrength` pixels higher. The left and bottom borders are
129 * A handle to a library object.
132 * How strong the glyph is emboldened horizontally. Expressed in 26.6
136 * How strong the glyph is emboldened vertically. Expressed in 26.6
141 * A handle to the target bitmap.
144 * FreeType error code. 0~means success.
147 * The current implementation restricts `xStrength` to be less than or
148 * equal to~8 if bitmap is of pixel_mode @FT_PIXEL_MODE_MONO.
150 * If you want to embolden the bitmap owned by a @FT_GlyphSlotRec, you
151 * should call @FT_GlyphSlot_Own_Bitmap on the slot first.
153 * Bitmaps in @FT_PIXEL_MODE_GRAY2 and @FT_PIXEL_MODE_GRAY@ format are
154 * converted to @FT_PIXEL_MODE_GRAY format (i.e., 8bpp).
156 FT_EXPORT( FT_Error )
157 FT_Bitmap_Embolden( FT_Library library,
163 /**************************************************************************
169 * Convert a bitmap object with depth 1bpp, 2bpp, 4bpp, 8bpp or 32bpp to
170 * a bitmap object with depth 8bpp, making the number of used bytes per
171 * line (a.k.a. the 'pitch') a multiple of `alignment`.
175 * A handle to a library object.
181 * The pitch of the bitmap is a multiple of this argument. Common
182 * values are 1, 2, or 4.
189 * FreeType error code. 0~means success.
192 * It is possible to call @FT_Bitmap_Convert multiple times without
193 * calling @FT_Bitmap_Done (the memory is simply reallocated).
195 * Use @FT_Bitmap_Done to finally remove the bitmap object.
197 * The `library` argument is taken to have access to FreeType's memory
198 * handling functions.
200 * `source->buffer` and `target->buffer` must neither be equal nor
203 FT_EXPORT( FT_Error )
204 FT_Bitmap_Convert( FT_Library library,
205 const FT_Bitmap *source,
210 /**************************************************************************
216 * Blend a bitmap onto another bitmap, using a given color.
220 * A handle to a library object.
223 * The source bitmap, which can have any @FT_Pixel_Mode format.
226 * The offset vector to the upper left corner of the source bitmap in
227 * 26.6 pixel format. It should represent an integer offset; the
228 * function will set the lowest six bits to zero to enforce that.
231 * The color used to draw `source` onto `target`.
235 * A handle to an `FT_Bitmap` object. It should be either initialized
236 * as empty with a call to @FT_Bitmap_Init, or it should be of type
237 * @FT_PIXEL_MODE_BGRA.
240 * The offset vector to the upper left corner of the target bitmap in
241 * 26.6 pixel format. It should represent an integer offset; the
242 * function will set the lowest six bits to zero to enforce that.
245 * FreeType error code. 0~means success.
248 * This function doesn't perform clipping.
250 * The bitmap in `target` gets allocated or reallocated as needed; the
251 * vector `atarget_offset` is updated accordingly.
253 * In case of allocation or reallocation, the bitmap's pitch is set to
254 * `4 * width`. Both `source` and `target` must have the same bitmap
255 * flow (as indicated by the sign of the `pitch` field).
257 * `source->buffer` and `target->buffer` must neither be equal nor
263 FT_EXPORT( FT_Error )
264 FT_Bitmap_Blend( FT_Library library,
265 const FT_Bitmap* source,
266 const FT_Vector source_offset,
268 FT_Vector *atarget_offset,
272 /**************************************************************************
275 * FT_GlyphSlot_Own_Bitmap
278 * Make sure that a glyph slot owns `slot->bitmap`.
285 * FreeType error code. 0~means success.
288 * This function is to be used in combination with @FT_Bitmap_Embolden.
290 FT_EXPORT( FT_Error )
291 FT_GlyphSlot_Own_Bitmap( FT_GlyphSlot slot );
294 /**************************************************************************
300 * Destroy a bitmap object initialized with @FT_Bitmap_Init.
304 * A handle to a library object.
307 * The bitmap object to be freed.
310 * FreeType error code. 0~means success.
313 * The `library` argument is taken to have access to FreeType's memory
314 * handling functions.
316 FT_EXPORT( FT_Error )
317 FT_Bitmap_Done( FT_Library library,
326 #endif /* FTBITMAP_H_ */