This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git.
The branch, master has been updated via 9343d659869c792243a9ebb1ff6ea1e84323ead8 (commit) via 85c87f6ee96aff1c67e18736a6a4d03e00df2f32 (commit) from 150cfc91b719470c2f7beedd4f67e974ab755dd2 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- http://repo.or.cz/w/gfxprim.git/commit/9343d659869c792243a9ebb1ff6ea1e84323e...
commit 9343d659869c792243a9ebb1ff6ea1e84323ead8 Author: Cyril Hrubis metan@ucw.cz Date: Sun Jan 13 16:16:34 2013 +0100
loaders: Start TIFF loader, currently broken.
diff --git a/configure b/configure index d2f2d43..44bcc96 100755 --- a/configure +++ b/configure @@ -250,6 +250,9 @@ if __name__ == '__main__': ["giflib", "Library to handle, display and manipulate GIF images", [header_exists, "gif_lib.h"], "", "-lgif", ["loaders"]], + ["tiff", + "Tag Image File Format (TIFF) library", + [header_exists, "tiffio.h"], "", "-ltiff", ["loaders"]], ["libX11", "X11 library", [header_exists, "X11/Xlib.h"], "", "-lX11", ["backends"]], @@ -262,13 +265,13 @@ if __name__ == '__main__': ["dl", "Dynamic linker", [header_exists, "dlfcn.h"], "", "-ldl", ["core"]], + ["V4L2", + "Video for linux 2", + [header_exists, "linux/videodev2.h"], "", "", ["grabbers"]], ["backtrace", "C stack trace writeout", [c_try_compile, "#include <execinfo.h>nint main(void) { backtrace(0, 0); }", - "Checking for backtrace() ... "], "", "", ["core"]], - ["V4L2", - "Video for linux 2", - [header_exists, "linux/videodev2.h"], "", "", ["grabbers"]]], cfg) + "Checking for backtrace() ... "], "", "", ["core"]]], cfg)
parser = OptionParser();
diff --git a/include/loaders/GP_Loaders.h b/include/loaders/GP_Loaders.h index d523494..5ee30b3 100644 --- a/include/loaders/GP_Loaders.h +++ b/include/loaders/GP_Loaders.h @@ -19,7 +19,7 @@ * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos * * jiri.bluebear.dluhos@gmail.com * * * - * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
@@ -43,6 +43,7 @@ #include "GP_PNG.h" #include "GP_JPG.h" #include "GP_GIF.h" +#include "GP_TIFF.h" #include "GP_PSP.h"
#include "GP_TmpFile.h" diff --git a/include/loaders/GP_Loaders.h b/include/loaders/GP_TIFF.h similarity index 58% copy from include/loaders/GP_Loaders.h copy to include/loaders/GP_TIFF.h index d523494..f6cb428 100644 --- a/include/loaders/GP_Loaders.h +++ b/include/loaders/GP_TIFF.h @@ -16,39 +16,54 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301 USA * * * - * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos * - * jiri.bluebear.dluhos@gmail.com * - * * - * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
- /* - - Core include file for loaders API. - - */ - -#ifndef LOADERS_GP_LOADERS_H -#define LOADERS_GP_LOADERS_H +#ifndef LOADERS_GP_TIFF_H +#define LOADERS_GP_TIFF_H
#include "core/GP_Context.h" #include "core/GP_ProgressCallback.h"
-#include "GP_PBM.h" -#include "GP_PGM.h" -#include "GP_PPM.h" +/* + * The possible errno values: + * + * - Anything FILE operation may return (fopen(), fclose(), fseek(), ...). + * - EIO for fread()/fwrite() failure + * - ENOSYS for not implemented bitmap format + * - ENOMEM from malloc() + * - EILSEQ for wrong image signature/data + * - ECANCELED when call was aborted from callback + */
-#include "GP_BMP.h" -#include "GP_PNG.h" -#include "GP_JPG.h" -#include "GP_GIF.h" -#include "GP_PSP.h" +/* + * Opens up a bmp file, checks signature, parses metadata. + * + * The file, width, height and pixel type are filled upon succcessful return. + * + * Upon failure, non zero return value is returned and errno is filled. + */ +int GP_OpenTIFF(const char *src_path, void **t);
-#include "GP_TmpFile.h" +/* + * Reads a TIFF from a opened file. + * + * Upon successful return, context to store bitmap is allocated and image is + * loaded. + * + * Upon failure NULL is returned and errno is filled. + */ +GP_Context *GP_ReadTIFF(void *t, GP_ProgressCallback *callback);
-#include "GP_MetaData.h" +/* + * Does both GP_OpenTIFF and GP_ReadTIFF. + */ +GP_Context *GP_LoadTIFF(const char *src_path, GP_ProgressCallback *callback);
-#include "GP_Loader.h" +/* + * Match TIFF signature. + */ +int GP_MatchTIFF(const void *buf);
-#endif /* LOADERS_GP_LOADERS_H */ +#endif /* LOADERS_GP_TIFF_H */ diff --git a/libs/loaders/GP_Loader.c b/libs/loaders/GP_Loader.c index c3769a6..0cce654 100644 --- a/libs/loaders/GP_Loader.c +++ b/libs/loaders/GP_Loader.c @@ -16,7 +16,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301 USA * * * - * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
@@ -93,12 +93,21 @@ static GP_Loader gif_loader = { .extensions = {"gif", NULL}, };
+static GP_Loader tiff_loader = { + .Load = GP_LoadTIFF, + .Save = NULL, + .Match = GP_MatchTIFF, + .fmt_name = "Tag Image File Format", + .next = &gif_loader, + .extensions = {"tif", "tiff", NULL}, +}; + static GP_Loader png_loader = { .Load = GP_LoadPNG, .Save = GP_SavePNG, .Match = GP_MatchPNG, .fmt_name = "Portable Network Graphics", - .next = &gif_loader, + .next = &tiff_loader, .extensions = {"png", NULL}, };
diff --git a/libs/loaders/GP_TIFF.c b/libs/loaders/GP_TIFF.c new file mode 100644 index 0000000..058f4e2 --- /dev/null +++ b/libs/loaders/GP_TIFF.c @@ -0,0 +1,222 @@ +/***************************************************************************** + * This file is part of gfxprim library. * + * * + * Gfxprim is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * Gfxprim is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with gfxprim; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * + * * + *****************************************************************************/ + +/* + + TIFF image support using libtiff. + + */ + +#include <stdint.h> +#include <inttypes.h> + +#include <errno.h> +#include <string.h> + +#include "../../config.h" +#include "core/GP_Debug.h" + +#include "GP_TIFF.h" + +#ifdef HAVE_TIFF + +#include <tiffio.h> + +#define TIFF_HEADER_LITTLE "IIx2a0" +#define TIFF_HEADER_BIG "BB0x2a" + +int GP_MatchTIFF(const void *buf) +{ + if (!memcmp(buf, TIFF_HEADER_LITTLE, 4)) + return 1; + + if (!memcmp(buf, TIFF_HEADER_BIG, 4)) + return 1; + + return 0; +} + +int GP_OpenTIFF(const char *src_path, void **t) +{ + TIFF *tiff = TIFFOpen(src_path, "r"); + + if (tiff == NULL) + return 1; + + *t = tiff; + return 0; +} + +const char *compression_name(uint16_t compression) +{ + switch (compression) { + case COMPRESSION_NONE: + return "None"; + case COMPRESSION_CCITTRLE: + return "CCITT modified Huffman RLE"; + /* COMPRESSION_CCITTFAX3 == COMPRESSION_CCITT_T4 */ + case COMPRESSION_CCITTFAX3: + return "CCITT Group 3 fax encoding / CCITT T.4 (TIFF 6 name)"; + /* COMPRESSION_CCITTFAX4 == COMPRESSION_CCITT_T6 */ + case COMPRESSION_CCITTFAX4: + return "CCITT Group 4 fax encoding / CCITT T.6 (TIFF 6 name)"; + case COMPRESSION_LZW: + return "LZW"; + case COMPRESSION_OJPEG: + return "JPEG 6.0"; + case COMPRESSION_JPEG: + return "JPEG DCT"; + case COMPRESSION_NEXT: + return "NeXT 2 bit RLE"; + case COMPRESSION_CCITTRLEW: + return "#1 w/ word alignment"; + case COMPRESSION_PACKBITS: + return "Macintosh RLE"; + case COMPRESSION_THUNDERSCAN: + return "ThunderScan RLE"; + } + + return "Unknown"; +} + +GP_Context *GP_ReadTIFF(void *t, GP_ProgressCallback *callback) +{ + uint32_t w, h, y, tile_w, tile_h, rows_per_strip; + uint16_t compression, bpp; + TIFF *tiff = t; + TIFFRGBAImage img; + GP_Context *res; + int err; + + /* all these fields are compulsory in tiff image */ + TIFFGetField(tiff, TIFFTAG_IMAGEWIDTH, &w); + TIFFGetField(tiff, TIFFTAG_IMAGELENGTH, &h); + TIFFGetField(tiff, TIFFTAG_COMPRESSION, &compression); + TIFFGetField(tiff, TIFFTAG_BITSPERSAMPLE, &bpp); + + GP_DEBUG(1, "TIFF image %ux%u compression: %s, bpp: %u", + w, h, compression_name(compression), bpp); + + /* If set tiff is saved in tiles */ + if (TIFFGetField(tiff, TIFFTAG_TILEWIDTH, &tile_w) && + TIFFGetField(tiff, TIFFTAG_TILELENGTH, &tile_h)) { + GP_DEBUG(1, "TIFF is tiled in %ux%u", tile_w, tile_h); + err = ENOSYS; + goto err1; + } + + if (!TIFFGetField(tiff, TIFFTAG_ROWSPERSTRIP, &rows_per_strip)) { + GP_DEBUG(1, "TIFF is not stored in strips"); + err = ENOSYS; + goto err1; + } else { + GP_DEBUG(1, "TIFF rows_per_strip = %u", rows_per_strip); + } + + res = GP_ContextAlloc(w, h, GP_PIXEL_xRGB8888); + + if (res == NULL) { + err = errno; + GP_WARN("Malloc failed"); + goto err1; + } + + char emsg[1024]; + + if (TIFFRGBAImageBegin(&img, tiff, 0, emsg) != 1) { + GP_DEBUG(1, "TIFFRGBAImageBegin failed: %s", emsg); + err = EINVAL; + goto err2; + } + + for (y = 0; y < h; y += rows_per_strip) { + void *row = GP_PIXEL_ADDR(res, 0, y); + + if (TIFFReadRGBAStrip(tiff, y, row) != 1) { + err = EINVAL; + goto err2; + } + + if (GP_ProgressCallbackReport(callback, y, h, w)) { + GP_DEBUG(1, "Operation aborted"); + err = ECANCELED; + goto err2; + } + } + + TIFFRGBAImageEnd(&img); + + GP_ProgressCallbackDone(callback); + return res; + +err2: + GP_ContextFree(res); +err1: + errno = err; + return NULL; +} + +GP_Context *GP_LoadTIFF(const char *src_path, GP_ProgressCallback *callback) +{ + void *t; + GP_Context *res; + + if (GP_OpenTIFF(src_path, &t)) + return NULL; + + res = GP_ReadTIFF(t, callback); + + TIFFClose(t); + + return res; +} + +#else + +int GP_MatchTIFF(const void GP_UNUSED(*buf)) +{ + errno = ENOSYS; + return -1; +} + +int GP_OpenTIFF(const char GP_UNUSED(*src_path), + void GP_UNUSED(**t)) +{ + errno = ENOSYS; + return 1; +} + +GP_Context *GP_ReadTIFF(void GP_UNUSED(*t), + GP_ProgressCallback GP_UNUSED(*callback)) +{ + errno = ENOSYS; + return NULL; +} + +GP_Context *GP_LoadTIFF(const char GP_UNUSED(*src_path), + GP_ProgressCallback GP_UNUSED(*callback)) +{ + errno = ENOSYS; + return NULL; +} + +#endif /* HAVE_TIFF */
http://repo.or.cz/w/gfxprim.git/commit/85c87f6ee96aff1c67e18736a6a4d03e00df2...
commit 85c87f6ee96aff1c67e18736a6a4d03e00df2f32 Author: Cyril Hrubis metan@ucw.cz Date: Sun Jan 13 14:33:34 2013 +0100
doc: Finish rewrite of general information page.
diff --git a/doc/Makefile b/doc/Makefile index a43432d..db44fbc 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -2,7 +2,7 @@ SOURCES=general.txt context.txt loaders.txt filters.txt basic_types.txt drawing_api.txt backends.txt gamma.txt grabbers.txt environment_variables.txt debug.txt core.txt api.txt input.txt gen.txt pixels.txt coordinate_system.txt coding_style.txt - get_put_pixel.txt blits.txt progress_callback.txt + get_put_pixel.txt blits.txt progress_callback.txt text_api.txt
EXAMPLE_SOURCES=$(wildcard example_*.txt)
@@ -44,7 +44,7 @@ toolcheck: $(PAGES): %.html: %.txt asciidoc $(ASCIIDOC_PARAMS) $<
-examples.html: examples.txt ../demos/c_simple/*.c ../demos/py_simple/*.py +examples.html: examples.txt ../demos/c_simple/*.c ../demos/py_simple/*.py asciidoc.conf asciidoc $(ASCIIDOC_PARAMS) -a toc examples.txt
# diff --git a/doc/asciidoc.conf b/doc/asciidoc.conf index 1b4a0b6..4294c56 100644 --- a/doc/asciidoc.conf +++ b/doc/asciidoc.conf @@ -45,6 +45,16 @@ endif::disable-javascript[] <li><a href="api.html">API</a></li> <li><a href="examples.html">Examples</a></li> </ul> + + <h4>API Pages</h4> + <ul> + <li><a href="drawing_api.html">Gfx</a></li> + <li><a href="text_api.html">Text</a></li> + <li><a href="filters.html">Filters</a></li> + <li><a href="loaders.html">Loaders</a></li> + <li><a href="backends.html">Backends</a></li> + <li><a href="input.html">Input</a></li> + </ul> </div>
# Rest of the content diff --git a/doc/drawing_api.txt b/doc/drawing_api.txt index e2e50db..948dea0 100644 --- a/doc/drawing_api.txt +++ b/doc/drawing_api.txt @@ -227,73 +227,3 @@ void GP_FillTetragon(GP_Context *context, GP_Coord x0, GP_Coord y0, --------------------------------------------------------------------------------
Draws a filled tetragon. - -Text -~~~~ - -Text drawing is controlled by the 'GP_TextStyle' structure defined in -'core/GP_TextStyle.h'. This structure carries the information about font, -letter spacing and pixel multiplication and spacing. (If no font is specified, -the default monospace font is used.) - -[source,c] --------------------------------------------------------------------------------- -/* Where the text should be drawn relatively to the specified point */ -typedef enum GP_TextAlign { - GP_ALIGN_LEFT = 0x01, /* to the left from the point */ - GP_ALIGN_CENTER = 0x02, /* centered on the point */ - GP_ALIGN_RIGHT = 0x03, /* to the right from the point */ - GP_VALIGN_ABOVE = 0x10, /* above the point */ - GP_VALIGN_CENTER = 0x20, /* centered on the point */ - GP_VALIGN_BASELINE = 0x30, /* baseline is on the point */ - GP_VALIGN_BELOW = 0x40 /* below the point */ -} GP_TextAlign; - -void GP_Text(GP_Context *context, const GP_TextStyle *style, - int x, int y, int align, const char *str, GP_Pixel pixel); --------------------------------------------------------------------------------- - -Draws text at the position x and y; the alignment of the text in relation -to the point is specified by alignment flags. -If the 'style' argument is 'NULL', a default style is used. - -The text size can be computed by following functions: - -[source,c] --------------------------------------------------------------------------------- -unsigned int GP_TextWidth(const GP_TextStyle *style, const char *str); --------------------------------------------------------------------------------- - -Returns the width (in pixels) that would be occupied by the string if rendered -using the specified style. - -[source,c] --------------------------------------------------------------------------------- -unsigned int GP_TextMaxWidth(const GP_TextStyle *style, unsigned int len); --------------------------------------------------------------------------------- - -Returns maximum text width, in pixels, for string with 'len' letters. This call -is useful for variable letter size fonts. - -[source,c] --------------------------------------------------------------------------------- -unsigned int GP_TextAscent(const GP_TextStyle *style); --------------------------------------------------------------------------------- - -The Ascent is the height in pixels from the top to the baseline. - -[source,c] --------------------------------------------------------------------------------- -unsigned int GP_TextDescent(const GP_TextStyle *style); --------------------------------------------------------------------------------- - -The Descent is the height in pixels from baseline to the bottom. - -[source,c] --------------------------------------------------------------------------------- -unsigned int GP_TextHeight(const GP_TextStyle *style); --------------------------------------------------------------------------------- - -The Height is size of the font from top to the bottom, i.e. equals exactly to -the sum of ascent and descent. - diff --git a/doc/general.txt b/doc/general.txt index 2cd8776..34bc888 100644 --- a/doc/general.txt +++ b/doc/general.txt @@ -1,5 +1,6 @@ General information -------------------- +=================== + Gfxprim is simple modular 2D bitmap graphics library with emphasis on speed and correctness.
@@ -10,11 +11,8 @@ programmming language. Creating code that works with less usuall pixel types should be as easy as adding pixel definition into the configuration and rebuilding the library. Read more link:gen.html[here].
-Parts of the library -~~~~~~~~~~~~~~~~~~~~ - Core -^^^^ +----
Core of the library contains minimal amount of code to define interface that is shared between all parts of the library. @@ -47,77 +45,163 @@ not all parts of library use it at the moment. And last but not least Core is a home for some link:core.html[common macros] that are used from different parts of the library.
-Graphics Rendering -^^^^^^^^^^^^^^^^^^ -* Basic Graphics Primitives (with and without fill) -** PutPixel/GetPixel -** Lines -** Circles -** Ellipses -** Polygons - -* Text Drawing -** Supports both proportional and non proportional fonts -** Basic fonts are compiled in the library -** Font rendering can be altered by style attributes -** Supports, for example, pixel multiplication and tracking -** Includes basic support for freetype - -* Bitmaps and Blitting -** Create, Destroy bitmap -** Subcontext, rectangular region in one context could be used as a context -** Fast specialized blits (with 90, 180 and 270 degree rotation) - -* Image loading/saving -** Read and Write support for PNG -** Read and Write support for JPEG -** Read support for BMP -** Read support for GIF - -* Graphic backed input event handling -** Linux Frame-buffer -** SDL support -** Experimental X11 support - -Bitmap Filters -^^^^^^^^^^^^^^ -* Point filters -** Brightness -** Contrast -** General Point filter - -* Linear filters -** Specialized Gaussian blur -** Separable Convolution -** General Convolution - -* Arithmetics filters -** Addition -** Multiplication -** Difference -** Maximum, Minimum - -* Floyd Steinberg dithering - -* Bitmap resampling algorithms -** Nearest Neighbour -** Bilinear -** Cubic - -* Bitmap rotation and mirroring -** 90 180 and 170 degree rotation - -* Histogram generator +Gfx +--- + +link:drawing_api.html[Gfx] is part of the library that implements basic +graphics primitives such as lines, circles, polygons, etc. Clasicall +primitives are nearly finished. Work on anti aliased primitives has been +started. + +Text +---- + +link:text_api.html[Text] part of the library implements basic support for +printing text into the bitmap. There are two bitmap fonts compiled directly +into the library and we support True Type fonts through +link:http://freetype.org%5BFreeType] (so far ASCII printable characters only). + +Loaders +------- + +link:loaders.html[Loaders] are part that is resposible for loading and saving +images into various standard formats (PNG, JPEG, GIF, BMP, PNM, etc...). + +.Currently supported formats +[width="100%",options="header"] +|============================================================================= +| Extension | Format Name | Signature | Read Support | Write Support + +| JPEG | | [green]*Yes* | [green]*Yes* | [green]*Yes* + +| PNG | + Portable Network Graphics | + [green]*Yes* | + [green]#16 Bit RGB not supported# | + [green]#16 Bit RGB not supported# + +| GIF | + Graphics Interchange Format | + [green]*Yes* | + [green]*Yes* | + [black]*No* + +| BMP | | + [green]*Yes* | + [green]#RLE and RGB Bitfields not implemented# | + [black]*No* + +| PSP | + Paint Shop Pro Image | + [green]*Yes* | + [green]#Composite image only for newer formats than 3.0# | + [black]*No* + +| PBM PGM PNM | + Netpbm portable bitmap | + [black]*No* | + [gray]#Not finished# | + [gray]#Not finished# + +|============================================================================= + + +Filters +------- + +link:filters.html[Filters] are part of the library that implements bitmap +image filters. + +.Currently Implemented Point Filters +[width="100%",options="header"] +|============================================================================= +| Filter Name | Supported Pixel Type | Multithreaded +| Brightness | All | No +| Contrast | All | No +|============================================================================= + +.Currently Implemented Linear Filters +[width="100%",options="header"] +|============================================================================= +| Filter Name | Supported Pixel Type | Mutithreaded +| Convolution | RGB888 | Yes +| Separable Convolution | RGB888 | Yes +| Gaussian Blur | RGB888 | Yes +| Sobel Edge Detection | RGB888 | Yes +| Prewitt Edge Detection | RGB888 | Yes +|============================================================================= + +NOTE: Linear filters are implemented using generic convolution filters, once + convolution is rewritten to run for all pixel types the rest of filters + will support them automatically. + + +.Currently Implemented Linear Filters +[width="100%",options="header"] +|============================================================================= +| Filter Name | Supported Pixel Type | Multithreaded +| Addition | All | No +| Multiplication | All | No +| Difference | All | No +| Max, Min | All | No +|============================================================================= + +.Currently Implemented Ditherings +[width="100%",options="header"] +|============================================================================= +| Filter Name | Supported Pixel Type | Multithreaded +| Floyd Steinberg | RGB888 -> Any | No +| Hilbert Peano | RGB888 -> Any | No +|============================================================================= + +.Currently Implemented Resamplings +[width="100%",options="header"] +|============================================================================= +| Filter Name | Supported Pixel Type | Multithreaded +| Nearest Neighbour | All | No +| Bilinear (Integer Arithmetics) | RGB888 | No +| Bicubic (Integer Arithmetics) | All | No +| Bicubic (Float Arithmetics) | RGB888 | No +|============================================================================= + +.Rotation and mirroring +[width="100%",options="header"] +|============================================================================= +| Filter Name | Supported Pixel Type | Multithreaded +| Rotate 90 | All | No +| Rotate 180 | All | No +| Rotate 270 | All | No +| Mirror Vertically | All | No +| Mirror Horizontally | All | No +|============================================================================= + +.Misc filters +[width="100%",options="header"] +|============================================================================= +| Filter Name | Supported Pixel Type | Multithreaded +| Histogram | All | No +| Additive Gaussian Noise | All | No +| Median | RGB888 | No +| Weighted Median | RGB888 | No +| Sigma Lee | RGB888 | No +|============================================================================= + +Backends +-------- + +link:backends.html[Backends] together with link:input.html[Input] are API for +drawing on screen (or into a window) and for getting keystrokes/mouse +coordinates. So far we support X11, linux framebuffer and SDL as a graphics +backend. +
Work in progress -~~~~~~~~~~~~~~~~ +----------------
* Python bindings -** basic support works now -** could be combined with PyGTK for GUI drawing (experimental)
* Anti Aliased drawing -** Line and PutPixel are finished
* Gamma correction and color profiles
+* Alfa channel blits diff --git a/doc/text_api.txt b/doc/text_api.txt new file mode 100644 index 0000000..0f3484c --- /dev/null +++ b/doc/text_api.txt @@ -0,0 +1,74 @@ +Text +---- + +NOTE: You may want to see the link:coordinate_system.html[coordinate system] first. + +Text +~~~~ + +Text drawing is controlled by the 'GP_TextStyle' structure defined in +'core/GP_TextStyle.h'. This structure carries the information about font, +letter spacing and pixel multiplication and spacing. (If no font is specified, +the default monospace font is used.) + +[source,c] +-------------------------------------------------------------------------------- +/* Where the text should be drawn relatively to the specified point */ +typedef enum GP_TextAlign { + GP_ALIGN_LEFT = 0x01, /* to the left from the point */ + GP_ALIGN_CENTER = 0x02, /* centered on the point */ + GP_ALIGN_RIGHT = 0x03, /* to the right from the point */ + GP_VALIGN_ABOVE = 0x10, /* above the point */ + GP_VALIGN_CENTER = 0x20, /* centered on the point */ + GP_VALIGN_BASELINE = 0x30, /* baseline is on the point */ + GP_VALIGN_BELOW = 0x40 /* below the point */ +} GP_TextAlign; + +void GP_Text(GP_Context *context, const GP_TextStyle *style, + int x, int y, int align, const char *str, GP_Pixel pixel); +-------------------------------------------------------------------------------- + +Draws text at the position x and y; the alignment of the text in relation +to the point is specified by alignment flags. +If the 'style' argument is 'NULL', a default style is used. + +The text size can be computed by following functions: + +[source,c] +-------------------------------------------------------------------------------- +unsigned int GP_TextWidth(const GP_TextStyle *style, const char *str); +-------------------------------------------------------------------------------- + +Returns the width (in pixels) that would be occupied by the string if rendered +using the specified style. + +[source,c] +-------------------------------------------------------------------------------- +unsigned int GP_TextMaxWidth(const GP_TextStyle *style, unsigned int len); +-------------------------------------------------------------------------------- + +Returns maximum text width, in pixels, for string with 'len' letters. This call +is useful for variable letter size fonts. + +[source,c] +-------------------------------------------------------------------------------- +unsigned int GP_TextAscent(const GP_TextStyle *style); +-------------------------------------------------------------------------------- + +The Ascent is the height in pixels from the top to the baseline. + +[source,c] +-------------------------------------------------------------------------------- +unsigned int GP_TextDescent(const GP_TextStyle *style); +-------------------------------------------------------------------------------- + +The Descent is the height in pixels from baseline to the bottom. + +[source,c] +-------------------------------------------------------------------------------- +unsigned int GP_TextHeight(const GP_TextStyle *style); +-------------------------------------------------------------------------------- + +The Height is size of the font from top to the bottom, i.e. equals exactly to +the sum of ascent and descent. +
-----------------------------------------------------------------------
Summary of changes: configure | 11 +- doc/Makefile | 4 +- doc/asciidoc.conf | 10 ++ doc/drawing_api.txt | 70 ---------- doc/general.txt | 224 +++++++++++++++++++++---------- doc/text_api.txt | 74 ++++++++++ include/loaders/GP_Loaders.h | 3 +- include/loaders/{GP_BMP.h => GP_TIFF.h} | 23 ++-- libs/loaders/GP_Loader.c | 13 ++- libs/loaders/GP_TIFF.c | 222 ++++++++++++++++++++++++++++++ 10 files changed, 493 insertions(+), 161 deletions(-) create mode 100644 doc/text_api.txt copy include/loaders/{GP_BMP.h => GP_TIFF.h} (81%) create mode 100644 libs/loaders/GP_TIFF.c
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.