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 colour, gray scale or 00006 * bi-level images of an appropriate size to be FAX 00007 * compatible. 00008 * 00009 * Written by Steve Underwood <steveu@coppice.org> 00010 * 00011 * Copyright (C) 2009 Steve Underwood 00012 * 00013 * All rights reserved. 00014 * 00015 * This program is free software; you can redistribute it and/or modify 00016 * it under the terms of the GNU Lesser General Public License version 2.1, 00017 * as published by the Free Software Foundation. 00018 * 00019 * This program is distributed in the hope that it will be useful, 00020 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00021 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00022 * GNU Lesser General Public License for more details. 00023 * 00024 * You should have received a copy of the GNU Lesser General Public 00025 * License along with this program; if not, write to the Free Software 00026 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00027 */ 00028 00029 /*! \file */ 00030 00031 #if !defined(_SPANDSP_IMAGE_TRANSLATE_H_) 00032 #define _SPANDSP_IMAGE_TRANSLATE_H_ 00033 00034 /*! \page image_translate_page Image translation 00035 \section image_translate_page_sec_1 What does it do? 00036 00037 The image translate functions allow an image to be translated and resized between 00038 various colour an monochrome formats. It also allows a colour or gray-scale image 00039 to be reduced to a bi-level monochrome image. This is useful for preparing images 00040 to be sent as traditional bi-level FAX pages. 00041 00042 \section image_translate_page_sec_2 How does it work? 00043 00044 \section image_translate_page_sec_3 How do I use it? 00045 */ 00046 00047 typedef struct image_translate_state_s image_translate_state_t; 00048 00049 #if defined(__cplusplus) 00050 extern "C" 00051 { 00052 #endif 00053 00054 /*! \brief Get the next row of a translated image. 00055 \param s The image translation context. 00056 \return the length of the row buffer, in bytes */ 00057 SPAN_DECLARE(int) image_translate_row(image_translate_state_t *s, uint8_t buf[], size_t len); 00058 00059 /*! \brief Get the width of the image being produced by an image translation context. 00060 \param s The image translation context. 00061 \return The width of the output image, in pixel. */ 00062 SPAN_DECLARE(int) image_translate_get_output_width(image_translate_state_t *s); 00063 00064 /*! \brief Get the length of the image being produced by an image translation context. 00065 \param s The image translation context. 00066 \return The length of the output image, in pixel. */ 00067 SPAN_DECLARE(int) image_translate_get_output_length(image_translate_state_t *s); 00068 00069 /*! \brief Initialise an image translation context for rescaling and squashing a gray scale 00070 or colour image to a bi-level FAX type image. 00071 \param s The image translation context. 00072 \param input_format x 00073 \param input_width The width of the source image, in pixels. 00074 \param input_length The length of the source image, in pixels. 00075 \param output_format x 00076 \param output_width The width of the output image, in pixels. If this is set <= 0 the image 00077 will not be resized. 00078 \param output_length The length of the output image, in pixels. If this is set to <= 0 the 00079 output length will be derived automatically from the width, to maintain the geometry 00080 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_format, 00090 int output_width, 00091 int output_length, 00092 t4_row_read_handler_t row_read_handler, 00093 void *row_read_user_data); 00094 00095 /*! \brief Release the resources associated with an image translation context. 00096 \param s The image translation context. 00097 \return 0 for success, otherwise -1. */ 00098 SPAN_DECLARE(int) image_translate_release(image_translate_state_t *s); 00099 00100 /*! \brief Free the resources associated with an image translation context. 00101 \param s The image translation context. 00102 \return 0 for success, otherwise -1. */ 00103 SPAN_DECLARE(int) image_translate_free(image_translate_state_t *s); 00104 00105 #if defined(__cplusplus) 00106 } 00107 #endif 00108 00109 #endif 00110 /*- End of file ------------------------------------------------------------*/
1.6.1