spandsp  0.0.6
image_translate.h
Go to the documentation of this file.
1 /*
2  * SpanDSP - a series of DSP components for telephony
3  *
4  * image_translate.h - Image translation routines for reworking colour
5  * and gray scale images to be colour, gray scale or
6  * bi-level images of an appropriate size to be FAX
7  * compatible.
8  *
9  * Written by Steve Underwood <steveu@coppice.org>
10  *
11  * Copyright (C) 2009 Steve Underwood
12  *
13  * All rights reserved.
14  *
15  * This program is free software; you can redistribute it and/or modify
16  * it under the terms of the GNU Lesser General Public License version 2.1,
17  * as published by the Free Software Foundation.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU Lesser General Public License for more details.
23  *
24  * You should have received a copy of the GNU Lesser General Public
25  * License along with this program; if not, write to the Free Software
26  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27  */
28 
29 /*! \file */
30 
31 #if !defined(_SPANDSP_IMAGE_TRANSLATE_H_)
32 #define _SPANDSP_IMAGE_TRANSLATE_H_
33 
34 /*! \page image_translate_page Image translation
35 \section image_translate_page_sec_1 What does it do?
36 
37 The image translate functions allow an image to be translated and resized between
38 various colour an monochrome formats. It also allows a colour or gray-scale image
39 to be reduced to a bi-level monochrome image. This is useful for preparing images
40 to be sent as traditional bi-level FAX pages.
41 
42 \section image_translate_page_sec_2 How does it work?
43 
44 \section image_translate_page_sec_3 How do I use it?
45 */
46 
48 
49 enum
50 {
51  IMAGE_TRANSLATE_FROM_MONO = 1,
52  IMAGE_TRANSLATE_FROM_GRAY_8 = 2,
53  IMAGE_TRANSLATE_FROM_GRAY_16 = 3,
54  IMAGE_TRANSLATE_FROM_COLOUR_8 = 4,
55  IMAGE_TRANSLATE_FROM_COLOUR_16 = 5
56 };
57 
58 #if defined(__cplusplus)
59 extern "C"
60 {
61 #endif
62 
63 /*! \brief Get the next row of a translated image.
64  \param s The image translation context.
65  \return the length of the row buffer, in bytes */
66 SPAN_DECLARE(int) image_translate_row(image_translate_state_t *s, uint8_t buf[], size_t len);
67 
68 /*! \brief Get the width of the image being produced by an image translation context.
69  \param s The image translation context.
70  \return The width of the output image, in pixel. */
72 
73 /*! \brief Get the length of the image being produced by an image translation context.
74  \param s The image translation context.
75  \return The length of the output image, in pixel. */
77 
78 /*! \brief Initialise an image translation context for rescaling and squashing a gray scale
79  or colour image to a bi-level FAX type image.
80  \param s The image translation context.
81  \param input_format The type of source image
82  \param input_width The width of the source image, in pixels.
83  \param input_length The length of the source image, in pixels.
84  \param output_width The width of the output image, in pixels. The length of the output image
85  will be derived automatically from this and the source image dimension, to main the
86  geometry of the original image.
87  \param row_read_handler A callback routine used to pull rows of pixels from the source image
88  into the translation process.
89  \param row_read_user_data An opaque pointer passed to read_row_handler
90  \return A pointer to the context, or NULL if there was a problem. */
92  int input_format,
93  int input_width,
94  int input_length,
95  int output_width,
96  t4_row_read_handler_t row_read_handler,
97  void *row_read_user_data);
98 
99 /*! \brief Release the resources associated with an image translation context.
100  \param s The image translation context.
101  \return 0 for success, otherwise -1. */
103 
104 /*! \brief Free the resources associated with an image translation context.
105  \param s The image translation context.
106  \return 0 for success, otherwise -1. */
107 SPAN_DECLARE(int) image_translate_free(image_translate_state_t *s);
108 
109 #if defined(__cplusplus)
110 }
111 #endif
112 
113 #endif
114 /*- End of file ------------------------------------------------------------*/
image_translate_state_t * image_translate_init(image_translate_state_t *s, int input_format, int input_width, int input_length, int output_width, t4_row_read_handler_t row_read_handler, void *row_read_user_data)
Initialise an image translation context for rescaling and squashing a gray scale or colour image to a...
Definition: image_translate.c:365
Definition: private/image_translate.h:31
int image_translate_free(image_translate_state_t *s)
Free the resources associated with an image translation context.
Definition: image_translate.c:465
int image_translate_row(image_translate_state_t *s, uint8_t buf[], size_t len)
Get the next row of a translated image.
Definition: image_translate.c:235
int image_translate_release(image_translate_state_t *s)
Release the resources associated with an image translation context.
Definition: image_translate.c:444
int(* t4_row_read_handler_t)(void *user_data, uint8_t buf[], size_t len)
Definition: t4_tx.h:36
int image_translate_get_output_length(image_translate_state_t *s)
Get the length of the image being produced by an image translation context.
Definition: image_translate.c:359
int image_translate_get_output_width(image_translate_state_t *s)
Get the width of the image being produced by an image translation context.
Definition: image_translate.c:353