image_translate.h

Go to the documentation of this file.
00001 /*
00002  * SpanDSP - a series of DSP components for telephony
00003  *
00004  * image_translate.h - Image translation routines for reworking colour
00005  *                     and gray scale images to be bi-level images of an
00006  *                     appropriate size to be FAX compatible.
00007  *
00008  * Written by Steve Underwood <steveu@coppice.org>
00009  *
00010  * Copyright (C) 2009 Steve Underwood
00011  *
00012  * All rights reserved.
00013  *
00014  * This program is free software; you can redistribute it and/or modify
00015  * it under the terms of the GNU Lesser General Public License version 2.1,
00016  * as published by the Free Software Foundation.
00017  *
00018  * This program is distributed in the hope that it will be useful,
00019  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021  * GNU Lesser General Public License for more details.
00022  *
00023  * You should have received a copy of the GNU Lesser General Public
00024  * License along with this program; if not, write to the Free Software
00025  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00026  */
00027 
00028 /*! \file */
00029 
00030 #if !defined(_SPANDSP_IMAGE_TRANSLATE_H_)
00031 #define _SPANDSP_IMAGE_TRANSLATE_H_
00032 
00033 /*! \page image_translate_page Image translation
00034 \section image_translate_page_sec_1 What does it do?
00035 
00036 \section image_translate_page_sec_2 How does it work?
00037 
00038 \section image_translate_page_sec_3 How do I use it?
00039 */
00040 
00041 typedef struct image_translate_state_s image_translate_state_t;
00042 
00043 enum
00044 {
00045     IMAGE_TRANSLATE_FROM_MONO = 1,
00046     IMAGE_TRANSLATE_FROM_GRAY_8 = 2,
00047     IMAGE_TRANSLATE_FROM_GRAY_16 = 3,
00048     IMAGE_TRANSLATE_FROM_COLOUR_8 = 4,
00049     IMAGE_TRANSLATE_FROM_COLOUR_16 = 5
00050 };
00051 
00052 #if defined(__cplusplus)
00053 extern "C"
00054 {
00055 #endif
00056 
00057 /*! \brief Get the next row of a translated image.
00058     \param s The image translation context.
00059     \return the length of the row buffer, in bytes */
00060 SPAN_DECLARE(int) image_translate_row(image_translate_state_t *s, uint8_t buf[], size_t len);
00061 
00062 /*! \brief Get the width of the image being produced by an image translation context.
00063     \param s The image translation context.
00064     \return The width of the output image, in pixel. */
00065 SPAN_DECLARE(int) image_translate_get_output_width(image_translate_state_t *s);
00066 
00067 /*! \brief Get the length of the image being produced by an image translation context.
00068     \param s The image translation context.
00069     \return The length of the output image, in pixel. */
00070 SPAN_DECLARE(int) image_translate_get_output_length(image_translate_state_t *s);
00071 
00072 /*! \brief Initialise an image translation context for rescaling and squashing a gray scale
00073            or colour image to a bi-level FAX type image.
00074     \param s The image translation context.
00075     \param input_format x
00076     \param input_width The width of the source image, in pixels.
00077     \param input_length The length of the source image, in pixels.
00078     \param output_width The width of the output image, in pixels. The length of the output image
00079            will be derived automatically from this and the source image dimension, to main the
00080            geometry of the original image.
00081     \param row_read_handler A callback routine used to pull rows of pixels from the source image
00082            into the translation process.
00083     \param row_read_user_data An opaque point passed to read_row_handler
00084     \return A pointer to the context, or NULL if there was a problem. */
00085 SPAN_DECLARE(image_translate_state_t *) image_translate_init(image_translate_state_t *s,
00086                                                              int input_format,
00087                                                              int input_width,
00088                                                              int input_length,
00089                                                              int output_width,
00090                                                              t4_row_read_handler_t row_read_handler,
00091                                                              void *row_read_user_data);
00092 
00093 /*! \brief Release the resources associated with an image translation context.
00094     \param s The image translation context.
00095     \return 0 for success, otherwise -1. */
00096 SPAN_DECLARE(int) image_translate_release(image_translate_state_t *s);
00097 
00098 /*! \brief Free the resources associated with an image translation context.
00099     \param s The image translation context.
00100     \return 0 for success, otherwise -1. */
00101 SPAN_DECLARE(int) image_translate_free(image_translate_state_t *s);
00102 
00103 #if defined(__cplusplus)
00104 }
00105 #endif
00106 
00107 #endif
00108 /*- End of file ------------------------------------------------------------*/

Generated on Thu Dec 9 21:11:49 2010 for spandsp by  doxygen 1.5.9