summaryrefslogtreecommitdiff
path: root/Build/source/libs/gd/libgd-src/src/gd_bmp.c
diff options
context:
space:
mode:
authorAkira Kakuto <kakuto@fuk.kindai.ac.jp>2017-01-18 23:13:46 +0000
committerAkira Kakuto <kakuto@fuk.kindai.ac.jp>2017-01-18 23:13:46 +0000
commit1f3a1e3f83772c4ccc91a723000fb2374014a4d2 (patch)
treeb165bf15729fa287a73aaa13fb97333d3cafef85 /Build/source/libs/gd/libgd-src/src/gd_bmp.c
parentbe747857c72b720d2b81baead7c10f043e8a2588 (diff)
libgd 2.2.4
git-svn-id: svn://tug.org/texlive/trunk@42987 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/libs/gd/libgd-src/src/gd_bmp.c')
-rw-r--r--Build/source/libs/gd/libgd-src/src/gd_bmp.c58
1 files changed, 54 insertions, 4 deletions
diff --git a/Build/source/libs/gd/libgd-src/src/gd_bmp.c b/Build/source/libs/gd/libgd-src/src/gd_bmp.c
index e1194c54d80..1eb2ebe0a39 100644
--- a/Build/source/libs/gd/libgd-src/src/gd_bmp.c
+++ b/Build/source/libs/gd/libgd-src/src/gd_bmp.c
@@ -12,6 +12,13 @@
----------------------------------------------------------------------------
*/
+
+/**
+ * File: BMP IO
+ *
+ * Read and write BMP images.
+ */
+
/* $Id$ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -62,6 +69,18 @@ static int gdBMPPutInt(gdIOCtx *out, int w)
/*
Function: gdImageBmpPtr
+
+ Outputs the given image as BMP data, but using a <gdIOCtx> instead
+ of a file. See <gdImageBmp>.
+
+ Parameters:
+ im - the image to save.
+ size - Output: size in bytes of the result.
+ compression - whether to apply RLE or not.
+
+ Returns:
+
+ A pointer to memory containing the image data or NULL on error.
*/
BGD_DECLARE(void *) gdImageBmpPtr(gdImagePtr im, int *size, int compression)
{
@@ -76,6 +95,31 @@ BGD_DECLARE(void *) gdImageBmpPtr(gdImagePtr im, int *size, int compression)
/*
Function: gdImageBmp
+
+ <gdImageBmp> outputs the specified image to the specified file in
+ BMP format. The file must be open for writing. Under MSDOS and all
+ versions of Windows, it is important to use "wb" as opposed to
+ simply "w" as the mode when opening the file, and under Unix there
+ is no penalty for doing so. <gdImageBmp> does not close the file;
+ your code must do so.
+
+ In addition, <gdImageBmp> allows to specify whether RLE compression
+ should be applied.
+
+ Variants:
+
+ <gdImageBmpCtx> write via a <gdIOCtx> instead of a file handle.
+
+ <gdImageBmpPtr> store the image file to memory.
+
+ Parameters:
+
+ im - the image to save.
+ outFile - the output FILE* object.
+ compression - whether to apply RLE or not.
+
+ Returns:
+ nothing
*/
BGD_DECLARE(void) gdImageBmp(gdImagePtr im, FILE *outFile, int compression)
{
@@ -87,6 +131,14 @@ BGD_DECLARE(void) gdImageBmp(gdImagePtr im, FILE *outFile, int compression)
/*
Function: gdImageBmpCtx
+
+ Outputs the given image as BMP data, but using a <gdIOCtx> instead
+ of a file. See <gdImageBmp>.
+
+ Parameters:
+ im - the image to save.
+ out - the <gdIOCtx> to write to.
+ compression - whether to apply RLE or not.
*/
BGD_DECLARE(void) gdImageBmpCtx(gdImagePtr im, gdIOCtxPtr out, int compression)
{
@@ -102,7 +154,7 @@ BGD_DECLARE(void) gdImageBmpCtx(gdImagePtr im, gdIOCtxPtr out, int compression)
compression = 0;
}
- if (compression == 1 && !out->seek) {
+ if (compression && !out->seek) {
/* Try to create a temp file where we can seek */
if ((tmpfile_for_compression = tmpfile()) == NULL) {
compression = 0;
@@ -350,9 +402,7 @@ static int compress_row(unsigned char *row, int length)
}
if (compressed_run) {
- if (rle_type == BMP_RLE_TYPE_RLE) {
- compressed_length += build_rle_packet(row, rle_type, compressed_run, uncompressed_row);
- }
+ compressed_length += build_rle_packet(row, rle_type, compressed_run, uncompressed_row);
}
gdFree(uncompressed_start);