blob: 87ea09bdc72668e2ba2ecbe36ab722402f28941d [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25
26
27/*
28 * FUNCTIONS
29 * mlib_ImageClear - Clear an image to a specific color.
30 *
31 * SYNOPSIS
32 * mlib_status mlib_ImageClear(mlib_image *img,
33 * const mlib_s32 *color);
34 *
35 * ARGUMENT
36 * img Pointer to an image.
37 * color Pointer to the color that the image is set to.
38 *
39 * RESTRICTION
40 * img can have 1, 2, 3 or 4 channels of MLIB_BIT, MLIB_BYTE,
41 * MLIB_SHORT, MLIB_USHORT or MLIB_INT data type.
42 *
43 * DESCRIPTION
44 * Clear an image to a specific color.
45 */
46
47#include <mlib_image.h>
48#include <mlib_ImageCheck.h>
49#include <mlib_v_ImageClear_f.h>
50
51/***************************************************************/
52
53#if ! defined ( __MEDIALIB_OLD_NAMES )
54#if defined ( __SUNPRO_C )
55
56#pragma weak mlib_ImageClear = __mlib_ImageClear
57
58#elif defined ( __GNUC__ ) /* defined ( __SUNPRO_C ) */
59 __typeof__ (__mlib_ImageClear) mlib_ImageClear
60 __attribute__ ((weak,alias("__mlib_ImageClear")));
61
62#else /* defined ( __SUNPRO_C ) */
63
64#error "unknown platform"
65
66#endif /* defined ( __SUNPRO_C ) */
67#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
68
69/***************************************************************/
70
71mlib_status __mlib_ImageClear(mlib_image *img,
72 const mlib_s32 *color)
73{
74 MLIB_IMAGE_CHECK(img);
75
76 switch (mlib_ImageGetType(img)) {
77
78 case MLIB_BIT:
79 switch (mlib_ImageGetChannels(img)) {
80
81 case 1:
82 mlib_v_ImageClear_BIT_1(img, color);
83 break;
84
85 case 2:
86 mlib_v_ImageClear_BIT_2(img, color);
87 break;
88
89 case 3:
90 mlib_v_ImageClear_BIT_3(img, color);
91 break;
92
93 case 4:
94 mlib_v_ImageClear_BIT_4(img, color);
95 break;
96
97 default:
98 return MLIB_FAILURE;
99 }
100
101 break;
102
103 case MLIB_BYTE:
104 switch (mlib_ImageGetChannels(img)) {
105
106 case 1:
107 mlib_v_ImageClear_U8_1(img, color);
108 break;
109
110 case 2:
111 mlib_v_ImageClear_U8_2(img, color);
112 break;
113
114 case 3:
115 mlib_v_ImageClear_U8_3(img, color);
116 break;
117
118 case 4:
119 mlib_v_ImageClear_U8_4(img, color);
120 break;
121
122 default:
123 return MLIB_FAILURE;
124 }
125
126 break;
127
128 case MLIB_SHORT:
129 switch (mlib_ImageGetChannels(img)) {
130
131 case 1:
132 mlib_v_ImageClear_S16_1(img, color);
133 break;
134
135 case 2:
136 mlib_v_ImageClear_S16_2(img, color);
137 break;
138
139 case 3:
140 mlib_v_ImageClear_S16_3(img, color);
141 break;
142
143 case 4:
144 mlib_v_ImageClear_S16_4(img, color);
145 break;
146
147 default:
148 return MLIB_FAILURE;
149 }
150
151 break;
152
153 case MLIB_INT:
154 switch (mlib_ImageGetChannels(img)) {
155
156 case 1:
157 mlib_v_ImageClear_S32_1(img, color);
158 break;
159
160 case 2:
161 mlib_v_ImageClear_S32_2(img, color);
162 break;
163
164 case 3:
165 mlib_v_ImageClear_S32_3(img, color);
166 break;
167
168 case 4:
169 mlib_v_ImageClear_S32_4(img, color);
170 break;
171
172 default:
173 return MLIB_FAILURE;
174 }
175
176 break;
177
178 default:
179 return MLIB_FAILURE; /* MLIB_BIT is not supported here */
180 }
181
182 return MLIB_SUCCESS;
183}
184
185/***************************************************************/