summaryrefslogtreecommitdiff
path: root/include/gutenprint/image.h
blob: ab9902df399826a542c943a37cd4df3d1441087c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/*
 * "$Id: image.h,v 1.1 2004/09/17 18:38:01 rleigh Exp $"
 *
 *   libgimpprint image functions.
 *
 *   Copyright 1997-2000 Michael Sweet (mike@easysw.com) and
 *	Robert Krawitz (rlk@alum.mit.edu)
 *
 *   This program is free software; you can redistribute it and/or modify it
 *   under the terms of the GNU General Public License as published by the Free
 *   Software Foundation; either version 2 of the License, or (at your option)
 *   any later version.
 *
 *   This program 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 General Public License
 *   for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program; if not, write to the Free Software
 *   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

/**
 * @file gutenprint/image.h
 * @brief Image functions.
 */

#ifndef GUTENPRINT_IMAGE_H
#define GUTENPRINT_IMAGE_H

#ifdef __cplusplus
extern "C" {
#endif

/**
 * The image type is an abstract data type for interfacing with the
 * image creation program.
 *
 * @defgroup image image
 * @{
 */

/*
 * Constants...
 */

/*! The maximum number of channels. */
#define STP_CHANNEL_LIMIT	(32)


/** Image status. */
typedef enum
{
  STP_IMAGE_STATUS_OK,   /*!< Everything is OK. */
  STP_IMAGE_STATUS_ABORT /*!< An error occured, or the job was aborted. */
} stp_image_status_t;

/**
 * The image type is an abstract data type for interfacing with the
 * image creation program.  It provides callbacks to functions defined
 * within the client application which are called while printing the
 * image.
 */
typedef struct stp_image
{
  /**
   * This callback is used to perform any initialization required by
   * the image layer for the image.  It will be called once per image.
   * @param image the image in use.
   */
  void (*init)(struct stp_image *image);
  /**
   * This callback is called to reset the image to the beginning.  It
   * may (in principle) be called multiple times if a page is being
   * printed more than once.
   * @warning The reset() call may be removed in the future.
   * @param image the image in use.
   */
  void (*reset)(struct stp_image *image);
  /**
   * This callback returns the width of the image in pixels.
   * @param image the image in use.
   */
  int  (*width)(struct stp_image *image);
  /**
   * This callback returns the height of the image in pixels.
   * @param image the image in use.
   */
  int  (*height)(struct stp_image *image);
  /**
   * This callback transfers the data from the image to the gimp-print
   * library.  It is called from the driver layer.  It should copy
   * WIDTH (as returned by the width() member) pixels of data into the
   * data buffer.  It normally returns STP_IMAGE_STATUS_OK; if
   * something goes wrong, or the application wishes to stop producing
   * any further output (e. g. because the user cancelled the print
   * job), it should return STP_IMAGE_STATUS_ABORT.  This will cause
   * the driver to flush any remaining data to the output.  It will
   * always request rows in monotonically ascending order, but it may
   * skip rows (if, for example, the resolution of the input is higher
   * than the resolution of the output).
   * @param image the image in use.
   * @param data a pointer to width() bytes of pixel data.
   * @param byte_limit (image width * number of channels).
   * @param row (unused).
   */
  stp_image_status_t (*get_row)(struct stp_image *image, unsigned char *data,
                                size_t byte_limit, int row);

  /**
   * This callback returns the name of the application.  This is
   * embedded in the output by some drivers.
   */
  const char *(*get_appname)(struct stp_image *image);
  /**
   * This callback is called at the end of each page.
   */
  void (*conclude)(struct stp_image *image);
  /**
   * A pointer to an application-specific state information that might
   * need to be associated with the image object.
   */
  void *rep;
} stp_image_t;

extern void stp_image_init(stp_image_t *image);
extern void stp_image_reset(stp_image_t *image);
extern int stp_image_width(stp_image_t *image);
extern int stp_image_height(stp_image_t *image);
extern stp_image_status_t stp_image_get_row(stp_image_t *image,
					    unsigned char *data,
					    size_t limit, int row);
extern const char *stp_image_get_appname(stp_image_t *image);
extern void stp_image_conclude(stp_image_t *image);

#ifdef __cplusplus
  }
#endif

#endif /* GUTENPRINT_IMAGE_H */
/*
 * End of "$Id: image.h,v 1.1 2004/09/17 18:38:01 rleigh Exp $".
 */