1mlib_ImageReformat(3MLIB) mediaLib Library Functions mlib_ImageReformat(3MLIB)
2
3
4

NAME

6       mlib_ImageReformat - image data buffer reformat
7

SYNOPSIS

9       cc [ flag... ] file... -lmlib [ library... ]
10       #include <mlib.h>
11
12       mlib_status mlib_ImageReformat(void **dstData, const void **srcData,
13            mlib_s32 numBands, mlib_s32 xSize, mlib_s32 ySize,
14            mlib_type dstDataType, const mlib_s32 *dstBandoffsets,
15            mlib_s32 dstScanlinestride, mlib_s32 dstPixelstride,
16            mlib_type srcDataType, const mlib_s32 *srcBandoffsets,
17            mlib_s32 srcScanlinestride, mlib_s32 srcPixelstride);
18
19

DESCRIPTION

21       The mlib_ImageReformat() function copies and casts, if needed, an image
22       from one buffer to another. The formats and data types of the two  buf‐
23       fers may be different.
24
25         dstPixel[x][y][i] = (dstDataType) srcPixel[x][y][i]
26
27
28
29       where the values of a pixel at position (x, y) and in channel i are:
30
31         srcPixel[x][y][i] = srcData[i][srcBandoffsets[i] +
32                                        srcScanlinestride*y +
33                                        srcPixelstride*x]
34
35         dstPixel[x][y][i] = dstData[i][dstBandoffsets[i] +
36                                        dstScanlinestride*y +
37                                        dstPixelstride*x]
38
39
40
41       It is the user's responsibility to make sure that the data buffers sup‐
42       plied are suitable for this operation. The srcData and dstData can have
43       1, 2, 3, or 4 channels, and they must have the same number of channels.
44       The  srcDataType  and  dstDataType  can   be   MLIB_BYTE,   MLIB_SHORT,
45       MLIB_USHORT, MLIB_INT, MLIB_FLOAT, or MLIB_DOUBLE.
46
47
48       The  conversions  between  different  data  types  are  implemented  as
49       described in the following table:
50
51
52
53
54       Source Type   Dest. Type                            Action
55       ────────────────────────────────────────────────────────────────────────────────────
56       MLIB_SHORT    MLIB_BYTE     (mlib_u8)clamp(x, 0, 255)
57       MLIB_USHORT   MLIB_BYTE     (mlib_u8)clamp(x, 0, 255)
58       ────────────────────────────────────────────────────────────────────────────────────
59       MLIB_INT      MLIB_BYTE     (mlib_u8)clamp(x, 0, 255)
60       ────────────────────────────────────────────────────────────────────────────────────
61       MLIB_FLOAT    MLIB_BYTE     (mlib_u8)clamp(x, 0, 255)
62       ────────────────────────────────────────────────────────────────────────────────────
63       MLIB_DOUBLE   MLIB_BYTE     (mlib_u8)clamp(x, 0, 255)
64       ────────────────────────────────────────────────────────────────────────────────────
65
66
67       MLIB_BYTE     MLIB_SHORT    (mlib_s16)x
68       ────────────────────────────────────────────────────────────────────────────────────
69       MLIB_USHORT   MLIB_SHORT    (mlib_s16)clamp(x, -32768, 32767)
70       ────────────────────────────────────────────────────────────────────────────────────
71       MLIB_INT      MLIB_SHORT    (mlib_s16)clamp(x, -32768, 32767)
72       ────────────────────────────────────────────────────────────────────────────────────
73       MLIB_FLOAT    MLIB_SHORT    (mlib_s16)clamp(x, -32768, 32767)
74       ────────────────────────────────────────────────────────────────────────────────────
75       MLIB_DOUBLE   MLIB_SHORT    (mlib_s16)clamp(x, -32768, 32767)
76       ────────────────────────────────────────────────────────────────────────────────────
77       MLIB_BYTE     MLIB_USHORT   (mlib_u16)x
78       ────────────────────────────────────────────────────────────────────────────────────
79       MLIB_SHORT    MLIB_USHORT   (mlib_u16)clamp(x, 0, 65535)
80       ────────────────────────────────────────────────────────────────────────────────────
81       MLIB_INT      MLIB_USHORT   (mlib_u16)clamp(x, 0, 65535)
82       ────────────────────────────────────────────────────────────────────────────────────
83       MLIB_FLOAT    MLIB_USHORT   (mlib_u16)clamp(x, 0, 65535)
84       ────────────────────────────────────────────────────────────────────────────────────
85       MLIB_DOUBLE   MLIB_USHORT   (mlib_u16)clamp(x, 0, 65535)
86       ────────────────────────────────────────────────────────────────────────────────────
87       MLIB_BYTE     MLIB_INT      (mlib_s32)x
88       ────────────────────────────────────────────────────────────────────────────────────
89       MLIB_SHORT    MLIB_INT      (mlib_s32)x
90       ────────────────────────────────────────────────────────────────────────────────────
91       MLIB_USHORT   MLIB_INT      (mlib_s32)x
92       ────────────────────────────────────────────────────────────────────────────────────
93       MLIB_FLOAT    MLIB_INT      (mlib_s32)clamp(x, -2147483647-1, 2147483647)
94       ────────────────────────────────────────────────────────────────────────────────────
95       MLIB_DOUBLE   MLIB_INT      (mlib_s32)clamp(x, -2147483647-1, 2147483647)
96       ────────────────────────────────────────────────────────────────────────────────────
97       MLIB_BYTE     MLIB_FLOAT    (mlib_f32)x
98       ────────────────────────────────────────────────────────────────────────────────────
99       MLIB_SHORT    MLIB_FLOAT    (mlib_f32)x
100       ────────────────────────────────────────────────────────────────────────────────────
101       MLIB_USHORT   MLIB_FLOAT    (mlib_f32)x
102       ────────────────────────────────────────────────────────────────────────────────────
103       MLIB_INT      MLIB_FLOAT    (mlib_f32)x
104       ────────────────────────────────────────────────────────────────────────────────────
105       MLIB_DOUBLE   MLIB_FLOAT    (mlib_f32)x
106       ────────────────────────────────────────────────────────────────────────────────────
107       MLIB_BYTE     MLIB_DOUBLE   (mlib_d64)x
108       ────────────────────────────────────────────────────────────────────────────────────
109       MLIB_SHORT    MLIB_DOUBLE   (mlib_d64)x
110       ────────────────────────────────────────────────────────────────────────────────────
111       MLIB_USHORT   MLIB_DOUBLE   (mlib_d64)x
112       ────────────────────────────────────────────────────────────────────────────────────
113       MLIB_INT      MLIB_DOUBLE   (mlib_d64)x
114       ────────────────────────────────────────────────────────────────────────────────────
115       MLIB_FLOAT    MLIB_DOUBLE   (mlib_d64)x
116
117
118
119       The actions are defined in C-style pseudo-code. All type  casts  follow
120       the  rules  of  standard  C. clamp() can be defined as a macro: #define
121       clamp(x, low, high) (((x) < (low)) ? (low) : (((x) > (high)) ? (high) :
122       (x)))
123

PARAMETERS

125       The function takes the following arguments:
126
127       dstData              The pointer to the destination image data buffer.
128
129
130       srcData              The pointer to the source image data buffer.
131
132
133       numBands             The number of channels of the image data buffers.
134
135
136       xSize                The width of the image.
137
138
139       ySize                The height of the image.
140
141
142       dstDataType          The data type of the dstData buffer.
143
144
145       dstBandoffsets       The  initial pixel's offsets in the dstData buffer
146                            in terms of destination data buffer elements.
147
148
149       dstScanlinestride    The scanline stride of the dstData buffer in terms
150                            of destination data buffer elements.
151
152
153       dstPixelstride       The pixel stride of the dstData buffer in terms of
154                            destination data buffer elements.
155
156
157       srcDataType          The data type of the srcData buffer.
158
159
160       srcBandoffsets       The initial pixel's offsets in the srcData  buffer
161                            in terms of source data buffer elements.
162
163
164       srcScanlinestride    The scanline stride of the srcData buffer in terms
165                            of source data buffer elements.
166
167
168       srcPixelstride       The pixel stride of the srcData buffer in terms of
169                            source data buffer elements.
170
171

RETURN VALUES

173       The  function  returns MLIB_SUCCESS if successful. Otherwise it returns
174       MLIB_FAILURE.
175

ATTRIBUTES

177       See attributes(5) for descriptions of the following attributes:
178
179
180
181
182       ┌─────────────────────────────┬─────────────────────────────┐
183       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
184       ├─────────────────────────────┼─────────────────────────────┤
185       │Interface Stability          │Committed                    │
186       ├─────────────────────────────┼─────────────────────────────┤
187       │MT-Level                     │MT-Safe                      │
188       └─────────────────────────────┴─────────────────────────────┘
189

SEE ALSO

191       mlib_ImageDataTypeConvert(3MLIB), attributes(5)
192
193
194
195SunOS 5.11                        2 Mar 2007         mlib_ImageReformat(3MLIB)
Impressum