2018-06-03 22:00:42 +02:00
|
|
|
/****************************************************************************
|
|
|
|
*
|
|
|
|
* ftbitmap.h
|
|
|
|
*
|
|
|
|
* FreeType utility functions for bitmaps (specification).
|
|
|
|
*
|
2024-01-27 17:11:22 +01:00
|
|
|
* Copyright (C) 2004-2024 by
|
2018-06-03 22:00:42 +02:00
|
|
|
* David Turner, Robert Wilhelm, and Werner Lemberg.
|
|
|
|
*
|
|
|
|
* This file is part of the FreeType project, and may only be used,
|
|
|
|
* modified, and distributed under the terms of the FreeType project
|
|
|
|
* license, LICENSE.TXT. By continuing to use, modify, or distribute
|
|
|
|
* this file you indicate that you have read the license and
|
|
|
|
* understand and accept it fully.
|
|
|
|
*
|
|
|
|
*/
|
2004-12-14 17:01:29 +01:00
|
|
|
|
|
|
|
|
2016-01-12 21:37:13 +01:00
|
|
|
#ifndef FTBITMAP_H_
|
|
|
|
#define FTBITMAP_H_
|
2004-12-14 17:01:29 +01:00
|
|
|
|
|
|
|
|
2020-06-08 13:31:55 +02:00
|
|
|
#include <freetype/freetype.h>
|
|
|
|
#include <freetype/ftcolor.h>
|
2004-12-14 17:01:29 +01:00
|
|
|
|
|
|
|
#ifdef FREETYPE_H
|
|
|
|
#error "freetype.h of FreeType 1 has been loaded!"
|
|
|
|
#error "Please fix the directory search order for header files"
|
|
|
|
#error "so that freetype.h of FreeType 2 is found first."
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
FT_BEGIN_HEADER
|
|
|
|
|
|
|
|
|
2018-06-03 22:00:42 +02:00
|
|
|
/**************************************************************************
|
|
|
|
*
|
2018-06-17 21:08:36 +02:00
|
|
|
* @section:
|
2018-06-03 22:00:42 +02:00
|
|
|
* bitmap_handling
|
|
|
|
*
|
2018-06-17 21:08:36 +02:00
|
|
|
* @title:
|
2018-06-03 22:00:42 +02:00
|
|
|
* Bitmap Handling
|
|
|
|
*
|
2018-06-17 21:08:36 +02:00
|
|
|
* @abstract:
|
2018-06-03 22:00:42 +02:00
|
|
|
* Handling FT_Bitmap objects.
|
|
|
|
*
|
2018-06-17 21:08:36 +02:00
|
|
|
* @description:
|
2018-08-23 13:13:20 +02:00
|
|
|
* This section contains functions for handling @FT_Bitmap objects,
|
|
|
|
* automatically adjusting the target's bitmap buffer size as needed.
|
|
|
|
*
|
2018-08-24 18:52:30 +02:00
|
|
|
* Note that none of the functions changes the bitmap's 'flow' (as
|
2018-09-04 10:37:44 +02:00
|
|
|
* indicated by the sign of the `pitch` field in @FT_Bitmap).
|
2018-06-03 22:00:42 +02:00
|
|
|
*
|
2018-08-23 13:13:20 +02:00
|
|
|
* To set the flow, assign an appropriate positive or negative value to
|
2018-09-04 10:37:44 +02:00
|
|
|
* the `pitch` field of the target @FT_Bitmap object after calling
|
2018-08-23 13:13:20 +02:00
|
|
|
* @FT_Bitmap_Init but before calling any of the other functions
|
|
|
|
* described here.
|
2018-06-03 22:00:42 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
*
|
2018-06-17 21:08:36 +02:00
|
|
|
* @function:
|
2018-06-03 22:00:42 +02:00
|
|
|
* FT_Bitmap_Init
|
|
|
|
*
|
2018-06-17 21:08:36 +02:00
|
|
|
* @description:
|
2018-06-03 22:00:42 +02:00
|
|
|
* Initialize a pointer to an @FT_Bitmap structure.
|
|
|
|
*
|
2018-06-17 21:08:36 +02:00
|
|
|
* @inout:
|
2018-06-03 22:00:42 +02:00
|
|
|
* abitmap ::
|
|
|
|
* A pointer to the bitmap structure.
|
|
|
|
*
|
2018-06-17 21:08:36 +02:00
|
|
|
* @note:
|
2018-08-24 18:52:30 +02:00
|
|
|
* A deprecated name for the same function is `FT_Bitmap_New`.
|
2018-06-03 22:00:42 +02:00
|
|
|
*/
|
2015-03-10 11:15:15 +01:00
|
|
|
FT_EXPORT( void )
|
|
|
|
FT_Bitmap_Init( FT_Bitmap *abitmap );
|
|
|
|
|
|
|
|
|
|
|
|
/* deprecated */
|
2004-12-14 17:01:29 +01:00
|
|
|
FT_EXPORT( void )
|
|
|
|
FT_Bitmap_New( FT_Bitmap *abitmap );
|
|
|
|
|
|
|
|
|
2018-06-03 22:00:42 +02:00
|
|
|
/**************************************************************************
|
|
|
|
*
|
2018-06-17 21:08:36 +02:00
|
|
|
* @function:
|
2018-06-03 22:00:42 +02:00
|
|
|
* FT_Bitmap_Copy
|
|
|
|
*
|
2018-06-17 21:08:36 +02:00
|
|
|
* @description:
|
2018-06-03 22:00:42 +02:00
|
|
|
* Copy a bitmap into another one.
|
|
|
|
*
|
2018-06-17 21:08:36 +02:00
|
|
|
* @input:
|
2018-06-03 22:00:42 +02:00
|
|
|
* library ::
|
|
|
|
* A handle to a library object.
|
|
|
|
*
|
|
|
|
* source ::
|
|
|
|
* A handle to the source bitmap.
|
|
|
|
*
|
2018-06-17 21:08:36 +02:00
|
|
|
* @output:
|
2018-06-03 22:00:42 +02:00
|
|
|
* target ::
|
|
|
|
* A handle to the target bitmap.
|
|
|
|
*
|
2018-06-17 21:08:36 +02:00
|
|
|
* @return:
|
2018-06-03 22:00:42 +02:00
|
|
|
* FreeType error code. 0~means success.
|
2018-08-23 13:13:20 +02:00
|
|
|
*
|
|
|
|
* @note:
|
2018-08-24 18:52:30 +02:00
|
|
|
* `source->buffer` and `target->buffer` must neither be equal nor
|
2018-08-23 13:13:20 +02:00
|
|
|
* overlap.
|
2018-06-03 22:00:42 +02:00
|
|
|
*/
|
2005-10-20 04:13:46 +02:00
|
|
|
FT_EXPORT( FT_Error )
|
2005-05-20 23:52:19 +02:00
|
|
|
FT_Bitmap_Copy( FT_Library library,
|
|
|
|
const FT_Bitmap *source,
|
2017-09-30 16:16:03 +02:00
|
|
|
FT_Bitmap *target );
|
2005-05-20 23:52:19 +02:00
|
|
|
|
|
|
|
|
2018-06-03 22:00:42 +02:00
|
|
|
/**************************************************************************
|
|
|
|
*
|
2018-06-17 21:08:36 +02:00
|
|
|
* @function:
|
2018-06-03 22:00:42 +02:00
|
|
|
* FT_Bitmap_Embolden
|
|
|
|
*
|
2018-06-17 21:08:36 +02:00
|
|
|
* @description:
|
2018-08-24 18:52:30 +02:00
|
|
|
* Embolden a bitmap. The new bitmap will be about `xStrength` pixels
|
|
|
|
* wider and `yStrength` pixels higher. The left and bottom borders are
|
|
|
|
* kept unchanged.
|
2018-06-03 22:00:42 +02:00
|
|
|
*
|
2018-06-17 21:08:36 +02:00
|
|
|
* @input:
|
2018-06-03 22:00:42 +02:00
|
|
|
* library ::
|
|
|
|
* A handle to a library object.
|
|
|
|
*
|
|
|
|
* xStrength ::
|
2018-08-24 18:52:30 +02:00
|
|
|
* How strong the glyph is emboldened horizontally. Expressed in 26.6
|
|
|
|
* pixel format.
|
2018-06-03 22:00:42 +02:00
|
|
|
*
|
|
|
|
* yStrength ::
|
2018-08-24 18:52:30 +02:00
|
|
|
* How strong the glyph is emboldened vertically. Expressed in 26.6
|
|
|
|
* pixel format.
|
2018-06-03 22:00:42 +02:00
|
|
|
*
|
2018-06-17 21:08:36 +02:00
|
|
|
* @inout:
|
2018-06-03 22:00:42 +02:00
|
|
|
* bitmap ::
|
|
|
|
* A handle to the target bitmap.
|
|
|
|
*
|
2018-06-17 21:08:36 +02:00
|
|
|
* @return:
|
2018-06-03 22:00:42 +02:00
|
|
|
* FreeType error code. 0~means success.
|
|
|
|
*
|
2018-06-17 21:08:36 +02:00
|
|
|
* @note:
|
2018-08-24 18:52:30 +02:00
|
|
|
* The current implementation restricts `xStrength` to be less than or
|
|
|
|
* equal to~8 if bitmap is of pixel_mode @FT_PIXEL_MODE_MONO.
|
2018-06-03 22:00:42 +02:00
|
|
|
*
|
2018-08-24 18:52:30 +02:00
|
|
|
* If you want to embolden the bitmap owned by a @FT_GlyphSlotRec, you
|
|
|
|
* should call @FT_GlyphSlot_Own_Bitmap on the slot first.
|
2018-06-03 22:00:42 +02:00
|
|
|
*
|
2018-08-24 18:52:30 +02:00
|
|
|
* Bitmaps in @FT_PIXEL_MODE_GRAY2 and @FT_PIXEL_MODE_GRAY@ format are
|
|
|
|
* converted to @FT_PIXEL_MODE_GRAY format (i.e., 8bpp).
|
2018-06-03 22:00:42 +02:00
|
|
|
*/
|
2005-10-20 04:13:46 +02:00
|
|
|
FT_EXPORT( FT_Error )
|
2005-05-25 07:51:01 +02:00
|
|
|
FT_Bitmap_Embolden( FT_Library library,
|
|
|
|
FT_Bitmap* bitmap,
|
|
|
|
FT_Pos xStrength,
|
|
|
|
FT_Pos yStrength );
|
|
|
|
|
|
|
|
|
2018-06-03 22:00:42 +02:00
|
|
|
/**************************************************************************
|
|
|
|
*
|
2018-06-17 21:08:36 +02:00
|
|
|
* @function:
|
2018-06-03 22:00:42 +02:00
|
|
|
* FT_Bitmap_Convert
|
|
|
|
*
|
2018-06-17 21:08:36 +02:00
|
|
|
* @description:
|
2018-08-24 18:52:30 +02:00
|
|
|
* Convert a bitmap object with depth 1bpp, 2bpp, 4bpp, 8bpp or 32bpp to
|
|
|
|
* a bitmap object with depth 8bpp, making the number of used bytes per
|
2018-09-04 10:37:44 +02:00
|
|
|
* line (a.k.a. the 'pitch') a multiple of `alignment`.
|
2018-06-03 22:00:42 +02:00
|
|
|
*
|
2018-06-17 21:08:36 +02:00
|
|
|
* @input:
|
2018-06-03 22:00:42 +02:00
|
|
|
* library ::
|
|
|
|
* A handle to a library object.
|
|
|
|
*
|
|
|
|
* source ::
|
|
|
|
* The source bitmap.
|
|
|
|
*
|
|
|
|
* alignment ::
|
2018-08-24 18:52:30 +02:00
|
|
|
* The pitch of the bitmap is a multiple of this argument. Common
|
|
|
|
* values are 1, 2, or 4.
|
2018-06-03 22:00:42 +02:00
|
|
|
*
|
2018-06-17 21:08:36 +02:00
|
|
|
* @output:
|
2018-06-03 22:00:42 +02:00
|
|
|
* target ::
|
|
|
|
* The target bitmap.
|
|
|
|
*
|
2018-06-17 21:08:36 +02:00
|
|
|
* @return:
|
2018-06-03 22:00:42 +02:00
|
|
|
* FreeType error code. 0~means success.
|
|
|
|
*
|
2018-06-17 21:08:36 +02:00
|
|
|
* @note:
|
2018-06-03 22:00:42 +02:00
|
|
|
* It is possible to call @FT_Bitmap_Convert multiple times without
|
|
|
|
* calling @FT_Bitmap_Done (the memory is simply reallocated).
|
|
|
|
*
|
|
|
|
* Use @FT_Bitmap_Done to finally remove the bitmap object.
|
|
|
|
*
|
2018-09-04 10:37:44 +02:00
|
|
|
* The `library` argument is taken to have access to FreeType's memory
|
2018-08-24 18:52:30 +02:00
|
|
|
* handling functions.
|
2018-08-23 13:13:20 +02:00
|
|
|
*
|
2018-08-24 18:52:30 +02:00
|
|
|
* `source->buffer` and `target->buffer` must neither be equal nor
|
2018-08-23 13:13:20 +02:00
|
|
|
* overlap.
|
2018-06-03 22:00:42 +02:00
|
|
|
*/
|
2004-12-14 17:01:29 +01:00
|
|
|
FT_EXPORT( FT_Error )
|
|
|
|
FT_Bitmap_Convert( FT_Library library,
|
|
|
|
const FT_Bitmap *source,
|
|
|
|
FT_Bitmap *target,
|
|
|
|
FT_Int alignment );
|
|
|
|
|
|
|
|
|
2018-06-16 09:39:29 +02:00
|
|
|
/**************************************************************************
|
|
|
|
*
|
2018-06-17 21:08:36 +02:00
|
|
|
* @function:
|
2018-06-16 09:39:29 +02:00
|
|
|
* FT_Bitmap_Blend
|
|
|
|
*
|
2018-06-17 21:08:36 +02:00
|
|
|
* @description:
|
2018-06-16 09:39:29 +02:00
|
|
|
* Blend a bitmap onto another bitmap, using a given color.
|
|
|
|
*
|
2018-06-17 21:08:36 +02:00
|
|
|
* @input:
|
2018-06-16 09:39:29 +02:00
|
|
|
* library ::
|
|
|
|
* A handle to a library object.
|
|
|
|
*
|
|
|
|
* source ::
|
|
|
|
* The source bitmap, which can have any @FT_Pixel_Mode format.
|
|
|
|
*
|
|
|
|
* source_offset ::
|
|
|
|
* The offset vector to the upper left corner of the source bitmap in
|
2019-02-23 11:18:39 +01:00
|
|
|
* 26.6 pixel format. It should represent an integer offset; the
|
|
|
|
* function will set the lowest six bits to zero to enforce that.
|
2018-06-16 09:39:29 +02:00
|
|
|
*
|
|
|
|
* color ::
|
2018-09-04 10:37:44 +02:00
|
|
|
* The color used to draw `source` onto `target`.
|
2018-06-16 09:39:29 +02:00
|
|
|
*
|
2018-06-17 21:08:36 +02:00
|
|
|
* @inout:
|
2018-06-16 09:39:29 +02:00
|
|
|
* target ::
|
2018-08-24 18:52:30 +02:00
|
|
|
* A handle to an `FT_Bitmap` object. It should be either initialized
|
2018-06-16 09:39:29 +02:00
|
|
|
* as empty with a call to @FT_Bitmap_Init, or it should be of type
|
|
|
|
* @FT_PIXEL_MODE_BGRA.
|
|
|
|
*
|
|
|
|
* atarget_offset ::
|
|
|
|
* The offset vector to the upper left corner of the target bitmap in
|
|
|
|
* 26.6 pixel format. It should represent an integer offset; the
|
|
|
|
* function will set the lowest six bits to zero to enforce that.
|
|
|
|
*
|
2018-06-17 21:08:36 +02:00
|
|
|
* @return:
|
2018-06-16 09:39:29 +02:00
|
|
|
* FreeType error code. 0~means success.
|
|
|
|
*
|
2018-06-17 21:08:36 +02:00
|
|
|
* @note:
|
2018-06-16 09:39:29 +02:00
|
|
|
* This function doesn't perform clipping.
|
|
|
|
*
|
2018-09-04 10:37:44 +02:00
|
|
|
* The bitmap in `target` gets allocated or reallocated as needed; the
|
2018-08-24 18:52:30 +02:00
|
|
|
* vector `atarget_offset` is updated accordingly.
|
2018-06-16 09:39:29 +02:00
|
|
|
*
|
|
|
|
* In case of allocation or reallocation, the bitmap's pitch is set to
|
2018-09-04 10:37:44 +02:00
|
|
|
* `4 * width`. Both `source` and `target` must have the same bitmap
|
|
|
|
* flow (as indicated by the sign of the `pitch` field).
|
2018-06-16 09:39:29 +02:00
|
|
|
*
|
2018-08-24 18:52:30 +02:00
|
|
|
* `source->buffer` and `target->buffer` must neither be equal nor
|
2018-08-23 13:13:20 +02:00
|
|
|
* overlap.
|
|
|
|
*
|
2018-06-17 21:08:36 +02:00
|
|
|
* @since:
|
2018-06-16 09:39:29 +02:00
|
|
|
* 2.10
|
|
|
|
*/
|
|
|
|
FT_EXPORT( FT_Error )
|
|
|
|
FT_Bitmap_Blend( FT_Library library,
|
|
|
|
const FT_Bitmap* source,
|
|
|
|
const FT_Vector source_offset,
|
|
|
|
FT_Bitmap* target,
|
|
|
|
FT_Vector *atarget_offset,
|
|
|
|
FT_Color color );
|
|
|
|
|
|
|
|
|
2018-06-03 22:00:42 +02:00
|
|
|
/**************************************************************************
|
|
|
|
*
|
2018-06-17 21:08:36 +02:00
|
|
|
* @function:
|
2018-06-03 22:00:42 +02:00
|
|
|
* FT_GlyphSlot_Own_Bitmap
|
|
|
|
*
|
2018-06-17 21:08:36 +02:00
|
|
|
* @description:
|
2018-08-24 18:52:30 +02:00
|
|
|
* Make sure that a glyph slot owns `slot->bitmap`.
|
2018-06-03 22:00:42 +02:00
|
|
|
*
|
2018-06-17 21:08:36 +02:00
|
|
|
* @input:
|
2018-06-03 22:00:42 +02:00
|
|
|
* slot ::
|
|
|
|
* The glyph slot.
|
|
|
|
*
|
2018-06-17 21:08:36 +02:00
|
|
|
* @return:
|
2018-06-03 22:00:42 +02:00
|
|
|
* FreeType error code. 0~means success.
|
|
|
|
*
|
2018-06-17 21:08:36 +02:00
|
|
|
* @note:
|
2018-08-24 18:52:30 +02:00
|
|
|
* This function is to be used in combination with @FT_Bitmap_Embolden.
|
2018-06-03 22:00:42 +02:00
|
|
|
*/
|
2008-12-17 11:50:31 +01:00
|
|
|
FT_EXPORT( FT_Error )
|
|
|
|
FT_GlyphSlot_Own_Bitmap( FT_GlyphSlot slot );
|
|
|
|
|
|
|
|
|
2018-06-03 22:00:42 +02:00
|
|
|
/**************************************************************************
|
|
|
|
*
|
2018-06-17 21:08:36 +02:00
|
|
|
* @function:
|
2018-06-03 22:00:42 +02:00
|
|
|
* FT_Bitmap_Done
|
|
|
|
*
|
2018-06-17 21:08:36 +02:00
|
|
|
* @description:
|
2018-06-03 22:00:42 +02:00
|
|
|
* Destroy a bitmap object initialized with @FT_Bitmap_Init.
|
|
|
|
*
|
2018-06-17 21:08:36 +02:00
|
|
|
* @input:
|
2018-06-03 22:00:42 +02:00
|
|
|
* library ::
|
|
|
|
* A handle to a library object.
|
|
|
|
*
|
|
|
|
* bitmap ::
|
|
|
|
* The bitmap object to be freed.
|
|
|
|
*
|
2018-06-17 21:08:36 +02:00
|
|
|
* @return:
|
2018-06-03 22:00:42 +02:00
|
|
|
* FreeType error code. 0~means success.
|
|
|
|
*
|
2018-06-17 21:08:36 +02:00
|
|
|
* @note:
|
2018-09-04 10:37:44 +02:00
|
|
|
* The `library` argument is taken to have access to FreeType's memory
|
2018-08-24 18:52:30 +02:00
|
|
|
* handling functions.
|
2018-06-03 22:00:42 +02:00
|
|
|
*/
|
2004-12-14 17:01:29 +01:00
|
|
|
FT_EXPORT( FT_Error )
|
|
|
|
FT_Bitmap_Done( FT_Library library,
|
|
|
|
FT_Bitmap *bitmap );
|
|
|
|
|
|
|
|
|
|
|
|
/* */
|
|
|
|
|
|
|
|
|
|
|
|
FT_END_HEADER
|
|
|
|
|
2016-01-12 21:37:13 +01:00
|
|
|
#endif /* FTBITMAP_H_ */
|
2004-12-14 17:01:29 +01:00
|
|
|
|
|
|
|
|
|
|
|
/* END */
|