2004-12-14 17:01:29 +01:00
|
|
|
/***************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* ftbitmap.h */
|
|
|
|
/* */
|
2008-12-17 11:50:31 +01:00
|
|
|
/* FreeType utility functions for bitmaps (specification). */
|
2004-12-14 17:01:29 +01:00
|
|
|
/* */
|
2017-01-04 20:16:34 +01:00
|
|
|
/* Copyright 2004-2017 by */
|
2004-12-14 17:01:29 +01: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. */
|
|
|
|
/* */
|
|
|
|
/***************************************************************************/
|
|
|
|
|
|
|
|
|
2016-01-12 21:37:13 +01:00
|
|
|
#ifndef FTBITMAP_H_
|
|
|
|
#define FTBITMAP_H_
|
2004-12-14 17:01:29 +01:00
|
|
|
|
|
|
|
|
|
|
|
#include <ft2build.h>
|
|
|
|
#include FT_FREETYPE_H
|
|
|
|
|
|
|
|
#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
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Section> */
|
|
|
|
/* bitmap_handling */
|
|
|
|
/* */
|
2004-12-14 23:32:34 +01:00
|
|
|
/* <Title> */
|
|
|
|
/* Bitmap Handling */
|
|
|
|
/* */
|
|
|
|
/* <Abstract> */
|
|
|
|
/* Handling FT_Bitmap objects. */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
2014-11-19 21:07:59 +01:00
|
|
|
/* This section contains functions for handling @FT_Bitmap objects. */
|
|
|
|
/* Note that none of the functions changes the bitmap's `flow' (as */
|
|
|
|
/* indicated by the sign of the `pitch' field in `FT_Bitmap'). */
|
2004-12-14 23:32:34 +01:00
|
|
|
/* */
|
2004-12-14 17:01:29 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
2015-03-10 11:15:15 +01:00
|
|
|
/* FT_Bitmap_Init */
|
2004-12-14 17:01:29 +01:00
|
|
|
/* */
|
|
|
|
/* <Description> */
|
2006-05-12 10:00:13 +02:00
|
|
|
/* Initialize a pointer to an @FT_Bitmap structure. */
|
2004-12-14 17:01:29 +01:00
|
|
|
/* */
|
|
|
|
/* <InOut> */
|
|
|
|
/* abitmap :: A pointer to the bitmap structure. */
|
|
|
|
/* */
|
2015-03-10 11:15:15 +01:00
|
|
|
/* <Note> */
|
|
|
|
/* A deprecated name for the same function is `FT_Bitmap_New'. */
|
|
|
|
/* */
|
|
|
|
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 );
|
|
|
|
|
|
|
|
|
2005-05-20 23:52:19 +02:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* FT_Bitmap_Copy */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
2008-06-26 21:56:51 +02:00
|
|
|
/* Copy a bitmap into another one. */
|
2005-05-20 23:52:19 +02:00
|
|
|
/* */
|
|
|
|
/* <Input> */
|
2005-05-27 08:01:28 +02:00
|
|
|
/* library :: A handle to a library object. */
|
|
|
|
/* */
|
|
|
|
/* source :: A handle to the source bitmap. */
|
2005-05-20 23:52:19 +02:00
|
|
|
/* */
|
|
|
|
/* <Output> */
|
2005-05-27 08:01:28 +02:00
|
|
|
/* target :: A handle to the target bitmap. */
|
2005-05-20 23:52:19 +02:00
|
|
|
/* */
|
|
|
|
/* <Return> */
|
2008-06-26 21:56:51 +02:00
|
|
|
/* FreeType error code. 0~means success. */
|
2005-05-20 23:52:19 +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,
|
|
|
|
FT_Bitmap *target);
|
|
|
|
|
|
|
|
|
2005-05-25 07:51:01 +02:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* FT_Bitmap_Embolden */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
2005-05-30 21:22:44 +02:00
|
|
|
/* Embolden a bitmap. The new bitmap will be about `xStrength' */
|
2005-05-25 07:51:01 +02:00
|
|
|
/* pixels wider and `yStrength' pixels higher. The left and bottom */
|
|
|
|
/* borders are kept unchanged. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* library :: A handle to a library object. */
|
|
|
|
/* */
|
|
|
|
/* xStrength :: How strong the glyph is emboldened horizontally. */
|
2005-05-30 21:22:44 +02:00
|
|
|
/* Expressed in 26.6 pixel format. */
|
2005-05-25 07:51:01 +02:00
|
|
|
/* */
|
|
|
|
/* yStrength :: How strong the glyph is emboldened vertically. */
|
2005-05-30 21:22:44 +02:00
|
|
|
/* Expressed in 26.6 pixel format. */
|
2005-05-25 07:51:01 +02:00
|
|
|
/* */
|
|
|
|
/* <InOut> */
|
|
|
|
/* bitmap :: A handle to the target bitmap. */
|
|
|
|
/* */
|
|
|
|
/* <Return> */
|
2008-06-26 21:56:51 +02:00
|
|
|
/* FreeType error code. 0~means success. */
|
2005-05-25 07:51:01 +02:00
|
|
|
/* */
|
|
|
|
/* <Note> */
|
|
|
|
/* The current implementation restricts `xStrength' to be less than */
|
2008-06-26 21:56:51 +02:00
|
|
|
/* or equal to~8 if bitmap is of pixel_mode @FT_PIXEL_MODE_MONO. */
|
2005-05-25 07:51:01 +02:00
|
|
|
/* */
|
2006-02-24 12:18:40 +01:00
|
|
|
/* If you want to embolden the bitmap owned by a @FT_GlyphSlotRec, */
|
2008-12-17 11:50:31 +01:00
|
|
|
/* you should call @FT_GlyphSlot_Own_Bitmap on the slot first. */
|
2005-05-26 23:02:25 +02:00
|
|
|
/* */
|
2014-11-19 21:07:59 +01:00
|
|
|
/* Bitmaps in @FT_PIXEL_MODE_GRAY2 and @FT_PIXEL_MODE_GRAY@ format */
|
|
|
|
/* are converted to @FT_PIXEL_MODE_GRAY format (i.e., 8bpp). */
|
|
|
|
/* */
|
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 );
|
|
|
|
|
|
|
|
|
2004-12-14 17:01:29 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* FT_Bitmap_Convert */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
Add support for color embedded bitmaps (eg. color emoji).
A new load flag, FT_LOAD_COLOR, makes FreeType load color
embedded-bitmaps, following this draft specification
https://color-emoji.googlecode.com/git/specification/v1.html
which defines two new SFNT tables, `CBDT' and `CBLC' (named and
modeled after `EBDT' and `EBLC', respectively). The color bitmaps
are stored in the new FT_PIXEL_MODE_BGRA format to represent BGRA
pre-multiplied sRGB images. If PNG support is available, PNG color
images as defined in the same proposed specification are supported
also.
Note that color bitmaps are converted to grayscale if client didn't
ask for color.
* builds/unix/configure.raw: Search for libpng.
Add `--without-png' option.
* devel/ftoption.h, include/freetype/config/ftoption.h
(FT_CONFIG_OPTION_USE_PNG): New macro.
* include/freetype/freetype.h (FT_LOAD_COLOR): New load flag.
* include/freetype/ftimage.h (FT_Pixel_Mode): Add
`FT_PIXEL_MODE_BGRA'.
* include/freetype/tttags.h (TTAG_CBDT, TTAG_CBLC): New tags.
* src/base/ftbitmap.c (FT_Bitmap_Embolden): Updated.
(ft_gray_for_premultiplied_srgb_bgra): New function.
(FT_Bitmap_Convert): Handle FT_PIXEL_MODE_BGRA.
* src/sfnt/pngshim.c, src/sfnt/pngshim.h: New files.
* src/sfnt/sfnt.c: Include `pngshim.c'.
* src/sfnt/ttsbit.c: Include FT_BITMAP_H and `pngshim.h'
(tt_face_load_eblc): Load `CBLC'.
(tt_sbit_decoder_init): Load `CBDT'.
(tt_sbit_decoder_alloc_bitmap): Pass load flags to select between
color and grayscale bitmaps.
Set `num_grays'. This is used by `ftview' to choose the blending
algorithm.
(tt_sbit_decoder_load_byte_aligned,
tt_sbit_decoder_load_bit_aligned, tt_sbit_decoder_load_compound,
tt_sbit_decoder_load_image): Pass load flag.
s/write/pwrite/.
Don't call `tt_sbit_decoder_alloc_bitmap'.
Updated.
(tt_sbit_decoder_load_png) [FT_CONFIG_OPTION_USE_PNG]: New function.
(tt_sbit_decoder_load_bitmap): Pass load flag.
Handle new glyph formats 17, 18, and 19.
Call `tt_sbit_decoder_alloc_bitmap'.
Flatten color bitmaps if necessary.
(tt_face_load_sbit_image): Updated.
* src/sfnt/rules.mk (SFNT_DRV_SRC): Add `pngshim.c'.
* docs/CHANGES: Updated.
2013-05-29 11:36:18 +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 line (a.k.a. the `pitch') a multiple of `alignment'. */
|
2004-12-14 17:01:29 +01:00
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* library :: A handle to a library object. */
|
|
|
|
/* */
|
|
|
|
/* source :: The source bitmap. */
|
|
|
|
/* */
|
|
|
|
/* alignment :: The pitch of the bitmap is a multiple of this */
|
|
|
|
/* parameter. Common values are 1, 2, or 4. */
|
|
|
|
/* */
|
|
|
|
/* <Output> */
|
|
|
|
/* target :: The target bitmap. */
|
|
|
|
/* */
|
|
|
|
/* <Return> */
|
2008-06-26 21:56:51 +02:00
|
|
|
/* FreeType error code. 0~means success. */
|
2004-12-14 17:01:29 +01:00
|
|
|
/* */
|
|
|
|
/* <Note> */
|
|
|
|
/* 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. */
|
|
|
|
/* */
|
|
|
|
/* The `library' argument is taken to have access to FreeType's */
|
|
|
|
/* memory handling functions. */
|
|
|
|
/* */
|
|
|
|
FT_EXPORT( FT_Error )
|
|
|
|
FT_Bitmap_Convert( FT_Library library,
|
|
|
|
const FT_Bitmap *source,
|
|
|
|
FT_Bitmap *target,
|
|
|
|
FT_Int alignment );
|
|
|
|
|
|
|
|
|
2008-12-17 11:50:31 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* FT_GlyphSlot_Own_Bitmap */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
|
|
|
/* Make sure that a glyph slot owns `slot->bitmap'. */
|
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* slot :: The glyph slot. */
|
|
|
|
/* */
|
|
|
|
/* <Return> */
|
|
|
|
/* FreeType error code. 0~means success. */
|
|
|
|
/* */
|
|
|
|
/* <Note> */
|
|
|
|
/* This function is to be used in combination with */
|
|
|
|
/* @FT_Bitmap_Embolden. */
|
|
|
|
/* */
|
|
|
|
FT_EXPORT( FT_Error )
|
|
|
|
FT_GlyphSlot_Own_Bitmap( FT_GlyphSlot slot );
|
|
|
|
|
|
|
|
|
2004-12-14 17:01:29 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* <Function> */
|
|
|
|
/* FT_Bitmap_Done */
|
|
|
|
/* */
|
|
|
|
/* <Description> */
|
2015-03-10 11:15:15 +01:00
|
|
|
/* Destroy a bitmap object initialized with @FT_Bitmap_Init. */
|
2004-12-14 17:01:29 +01:00
|
|
|
/* */
|
|
|
|
/* <Input> */
|
|
|
|
/* library :: A handle to a library object. */
|
|
|
|
/* */
|
|
|
|
/* bitmap :: The bitmap object to be freed. */
|
|
|
|
/* */
|
|
|
|
/* <Return> */
|
2008-06-26 21:56:51 +02:00
|
|
|
/* FreeType error code. 0~means success. */
|
2004-12-14 17:01:29 +01:00
|
|
|
/* */
|
|
|
|
/* <Note> */
|
|
|
|
/* The `library' argument is taken to have access to FreeType's */
|
|
|
|
/* memory handling functions. */
|
|
|
|
/* */
|
|
|
|
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 */
|