sdk-world v2026.11.05
PS2 SDK - world tier (copyleft-allowed, non-essential packages)
Loading...
Searching...
No Matches
ftbitmap.h
Go to the documentation of this file.
1/****************************************************************************
2 *
3 * ftbitmap.h
4 *
5 * FreeType utility functions for bitmaps (specification).
6 *
7 * Copyright (C) 2004-2025 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
23#ifndef FTBITMAP_H_
24#define FTBITMAP_H_
25
26
27#include <freetype/freetype.h>
28#include <freetype/ftcolor.h>
29
30#ifdef FREETYPE_H
31#error "freetype.h of FreeType 1 has been loaded!"
32#error "Please fix the directory search order for header files"
33#error "so that freetype.h of FreeType 2 is found first."
34#endif
35
36
37FT_BEGIN_HEADER
38
39
40 /**************************************************************************
41 *
42 * @section:
43 * bitmap_handling
44 *
45 * @title:
46 * Bitmap Handling
47 *
48 * @abstract:
49 * Handling FT_Bitmap objects.
50 *
51 * @description:
52 * This section contains functions for handling @FT_Bitmap objects,
53 * automatically adjusting the target's bitmap buffer size as needed.
54 *
55 * Note that none of the functions changes the bitmap's 'flow' (as
56 * indicated by the sign of the `pitch` field in @FT_Bitmap).
57 *
58 * To set the flow, assign an appropriate positive or negative value to
59 * the `pitch` field of the target @FT_Bitmap object after calling
60 * @FT_Bitmap_Init but before calling any of the other functions
61 * described here.
62 */
63
64
65 /**************************************************************************
66 *
67 * @function:
68 * FT_Bitmap_Init
69 *
70 * @description:
71 * Initialize a pointer to an @FT_Bitmap structure.
72 *
73 * @inout:
74 * abitmap ::
75 * A pointer to the bitmap structure.
76 *
77 * @note:
78 * A deprecated name for the same function is `FT_Bitmap_New`.
79 */
80 FT_EXPORT( void )
81 FT_Bitmap_Init( FT_Bitmap *abitmap );
82
83
84 /* deprecated */
85 FT_EXPORT( void )
86 FT_Bitmap_New( FT_Bitmap *abitmap );
87
88
89 /**************************************************************************
90 *
91 * @function:
92 * FT_Bitmap_Copy
93 *
94 * @description:
95 * Copy a bitmap into another one.
96 *
97 * @input:
98 * library ::
99 * A handle to a library object.
100 *
101 * source ::
102 * A handle to the source bitmap.
103 *
104 * @output:
105 * target ::
106 * A handle to the target bitmap.
107 *
108 * @return:
109 * FreeType error code. 0~means success.
110 *
111 * @note:
112 * `source->buffer` and `target->buffer` must neither be equal nor
113 * overlap.
114 */
115 FT_EXPORT( FT_Error )
116 FT_Bitmap_Copy( FT_Library library,
117 const FT_Bitmap *source,
118 FT_Bitmap *target );
119
120
121 /**************************************************************************
122 *
123 * @function:
124 * FT_Bitmap_Embolden
125 *
126 * @description:
127 * Embolden a bitmap. The new bitmap will be about `xStrength` pixels
128 * wider and `yStrength` pixels higher. The left and bottom borders are
129 * kept unchanged.
130 *
131 * @input:
132 * library ::
133 * A handle to a library object.
134 *
135 * xStrength ::
136 * How strong the glyph is emboldened horizontally. Expressed in 26.6
137 * pixel format.
138 *
139 * yStrength ::
140 * How strong the glyph is emboldened vertically. Expressed in 26.6
141 * pixel format.
142 *
143 * @inout:
144 * bitmap ::
145 * A handle to the target bitmap.
146 *
147 * @return:
148 * FreeType error code. 0~means success.
149 *
150 * @note:
151 * The current implementation restricts `xStrength` to be less than or
152 * equal to~8 if bitmap is of pixel_mode @FT_PIXEL_MODE_MONO.
153 *
154 * If you want to embolden the bitmap owned by a @FT_GlyphSlotRec, you
155 * should call @FT_GlyphSlot_Own_Bitmap on the slot first.
156 *
157 * Bitmaps in @FT_PIXEL_MODE_GRAY2 and @FT_PIXEL_MODE_GRAY@ format are
158 * converted to @FT_PIXEL_MODE_GRAY format (i.e., 8bpp).
159 */
160 FT_EXPORT( FT_Error )
161 FT_Bitmap_Embolden( FT_Library library,
162 FT_Bitmap* bitmap,
163 FT_Pos xStrength,
164 FT_Pos yStrength );
165
166
167 /**************************************************************************
168 *
169 * @function:
170 * FT_Bitmap_Convert
171 *
172 * @description:
173 * Convert a bitmap object with depth 1bpp, 2bpp, 4bpp, 8bpp or 32bpp to
174 * a bitmap object with depth 8bpp, making the number of used bytes per
175 * line (a.k.a. the 'pitch') a multiple of `alignment`.
176 *
177 * @input:
178 * library ::
179 * A handle to a library object.
180 *
181 * source ::
182 * The source bitmap.
183 *
184 * alignment ::
185 * The pitch of the bitmap is a multiple of this argument. Common
186 * values are 1, 2, or 4.
187 *
188 * @output:
189 * target ::
190 * The target bitmap.
191 *
192 * @return:
193 * FreeType error code. 0~means success.
194 *
195 * @note:
196 * It is possible to call @FT_Bitmap_Convert multiple times without
197 * calling @FT_Bitmap_Done (the memory is simply reallocated).
198 *
199 * Use @FT_Bitmap_Done to finally remove the bitmap object.
200 *
201 * The `library` argument is taken to have access to FreeType's memory
202 * handling functions.
203 *
204 * `source->buffer` and `target->buffer` must neither be equal nor
205 * overlap.
206 */
207 FT_EXPORT( FT_Error )
208 FT_Bitmap_Convert( FT_Library library,
209 const FT_Bitmap *source,
210 FT_Bitmap *target,
211 FT_Int alignment );
212
213
214 /**************************************************************************
215 *
216 * @function:
217 * FT_Bitmap_Blend
218 *
219 * @description:
220 * Blend a bitmap onto another bitmap, using a given color.
221 *
222 * @input:
223 * library ::
224 * A handle to a library object.
225 *
226 * source ::
227 * The source bitmap, which can have any @FT_Pixel_Mode format.
228 *
229 * source_offset ::
230 * The offset vector to the upper left corner of the source bitmap in
231 * 26.6 pixel format. It should represent an integer offset; the
232 * function will set the lowest six bits to zero to enforce that.
233 *
234 * color ::
235 * The color used to draw `source` onto `target`.
236 *
237 * @inout:
238 * target ::
239 * A handle to an `FT_Bitmap` object. It should be either initialized
240 * as empty with a call to @FT_Bitmap_Init, or it should be of type
241 * @FT_PIXEL_MODE_BGRA.
242 *
243 * atarget_offset ::
244 * The offset vector to the upper left corner of the target bitmap in
245 * 26.6 pixel format. It should represent an integer offset; the
246 * function will set the lowest six bits to zero to enforce that.
247 *
248 * @return:
249 * FreeType error code. 0~means success.
250 *
251 * @note:
252 * This function doesn't perform clipping.
253 *
254 * The bitmap in `target` gets allocated or reallocated as needed; the
255 * vector `atarget_offset` is updated accordingly.
256 *
257 * In case of allocation or reallocation, the bitmap's pitch is set to
258 * `4 * width`. Both `source` and `target` must have the same bitmap
259 * flow (as indicated by the sign of the `pitch` field).
260 *
261 * `source->buffer` and `target->buffer` must neither be equal nor
262 * overlap.
263 *
264 * @since:
265 * 2.10
266 */
267 FT_EXPORT( FT_Error )
268 FT_Bitmap_Blend( FT_Library library,
269 const FT_Bitmap* source,
270 const FT_Vector source_offset,
271 FT_Bitmap* target,
272 FT_Vector *atarget_offset,
273 FT_Color color );
274
275
276 /**************************************************************************
277 *
278 * @function:
279 * FT_GlyphSlot_Own_Bitmap
280 *
281 * @description:
282 * Make sure that a glyph slot owns `slot->bitmap`.
283 *
284 * @input:
285 * slot ::
286 * The glyph slot.
287 *
288 * @return:
289 * FreeType error code. 0~means success.
290 *
291 * @note:
292 * This function is to be used in combination with @FT_Bitmap_Embolden.
293 */
294 FT_EXPORT( FT_Error )
295 FT_GlyphSlot_Own_Bitmap( FT_GlyphSlot slot );
296
297
298 /**************************************************************************
299 *
300 * @function:
301 * FT_Bitmap_Done
302 *
303 * @description:
304 * Destroy a bitmap object initialized with @FT_Bitmap_Init.
305 *
306 * @input:
307 * library ::
308 * A handle to a library object.
309 *
310 * bitmap ::
311 * The bitmap object to be freed.
312 *
313 * @return:
314 * FreeType error code. 0~means success.
315 *
316 * @note:
317 * The `library` argument is taken to have access to FreeType's memory
318 * handling functions.
319 */
320 FT_EXPORT( FT_Error )
321 FT_Bitmap_Done( FT_Library library,
322 FT_Bitmap *bitmap );
323
324
325 /* */
326
327
328FT_END_HEADER
329
330#endif /* FTBITMAP_H_ */
331
332
333/* END */