FILE COMPARISON
Produced: 2/18/2011 1:24:50 AM
   
Mode:  All Lines  
Left base folder: C:\Documents and Settings\krollins\My Documents\Admin\OpenSource\eRCP\eSWT\eSWT-1.2.orig  
Right base folder: C:\Documents and Settings\krollins\My Documents\Admin\OpenSource\eRCP\eSWT\eSWT-1.2.today  
   
File: org.eclipse.ercp.swt.core.win\common-native\impl\jni_Image.c  
1 /******************************************************************************* = 1 /*******************************************************************************
2 * Copyright (c) 2000, 2005 IBM Corporation and others.   2 * Copyright (c) 2000, 2005 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials   3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0   4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at   5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html   6 * http://www.eclipse.org/legal/epl-v10.html
7 *   7 *
8 * Contributors:   8 * Contributors:
9 *     IBM Corporation - initial API and implementation   9 *     IBM Corporation - initial API and implementation
10 *******************************************************************************/   10 *******************************************************************************/
11     11  
    <> 12 /*******************************************************************************
      13 * Additions/modifications to this source file by Oracle America, Inc. 2011
      14 *******************************************************************************/
      15  
12 #include "UGL_ErrorImpl.h" = 16 #include "UGL_ErrorImpl.h"
13 #include "UGL_Error.h"   17 #include "UGL_Error.h"
14 #include "TypeConverter.h"   18 #include "TypeConverter.h"
15 #include <jni.h>   19 #include <jni.h>
16 #include "Image.h"   20 #include "Image.h"
17 #include "JNIHelpers.h"   21 #include "JNIHelpers.h"
18 #include "UGLTypes.h"   22 #include "UGLTypes.h"
19     23  
20 #ifdef __cplusplus   24 #ifdef __cplusplus
21 #define UNUSED(var)   25 #define UNUSED(var)
22 #else   26 #else
23 #define UNUSED(var) var   27 #define UNUSED(var) var
24 #endif   28 #endif
25     29  
26 #ifdef __cplusplus   30 #ifdef __cplusplus
27 extern "C" {   31 extern "C" {
28 #endif   32 #endif
29     33  
30     34  
31 /**   35 /**
32 * Frees the platform resources associated with the image identified by   36 * Frees the platform resources associated with the image identified by
33 * <code>handle</code>.   37 * <code>handle</code>.
34 */   38 */
35 JNIEXPORT void JNICALL Java_com_ibm_ugl_p3ml_OS_Image_1Dispose(JNIEnv* env, jclass UNUSED(clazz), jint handle)   39 JNIEXPORT void JNICALL Java_com_ibm_ugl_p3ml_OS_Image_1Dispose(JNIEnv* env, jclass UNUSED(clazz), jint handle)
36 {   40 {
37     UGL_ErrorStruct error;   41     UGL_ErrorStruct error;
38       42    
39     error.error_code = 0;   43     error.error_code = 0;
40       44    
41     #ifdef debug_print   45     #ifdef debug_print
42     APITRACE(env, "Entering - Image_Dispose\n");   46     APITRACE(env, "Entering - Image_Dispose\n");
43     APIARGTRACE(env, "\thandle=%d\n" , handle);   47     APIARGTRACE(env, "\thandle=%d\n" , handle);
44     #endif   48     #endif
45     49  
46     Image_Dispose(handle, &error);   50     Image_Dispose(handle, &error);
47     if (error.error_code == 0) {   51     if (error.error_code == 0) {
48         return;   52         return;
49     } else {   53     } else {
50         UGL_ErrorHandler(env, "Image_Dispose", &error);   54         UGL_ErrorHandler(env, "Image_Dispose", &error);
51     }   55     }
52 }   56 }
53     57  
54 /**   58 /**
55 * Returns the position and size of the image identified by <code>handle</code>.   59 * Returns the position and size of the image identified by <code>handle</code>.
56 */   60 */
57 JNIEXPORT jintArray JNICALL Java_com_ibm_ugl_p3ml_OS_Image_1GetBounds(JNIEnv* env, jclass UNUSED(clazz), jint handle)   61 JNIEXPORT jintArray JNICALL Java_com_ibm_ugl_p3ml_OS_Image_1GetBounds(JNIEnv* env, jclass UNUSED(clazz), jint handle)
58 {   62 {
59     UGL_ErrorStruct error;   63     UGL_ErrorStruct error;
60     UGL_Int returnHeight;   64     UGL_Int returnHeight;
61     UGL_Int returnWidth;   65     UGL_Int returnWidth;
62     UGL_Int returnX;   66     UGL_Int returnX;
63     UGL_Int returnY;   67     UGL_Int returnY;
64       68    
65     error.error_code = 0;   69     error.error_code = 0;
66       70    
67     #ifdef debug_print   71     #ifdef debug_print
68     APITRACE(env, "Entering - Image_GetBounds\n");   72     APITRACE(env, "Entering - Image_GetBounds\n");
69     APIARGTRACE(env, "\thandle=%d\n" , handle);   73     APIARGTRACE(env, "\thandle=%d\n" , handle);
70     #endif   74     #endif
71     75  
72     Image_GetBounds(handle, &returnX, &returnY, &returnWidth, &returnHeight, &error);   76     Image_GetBounds(handle, &returnX, &returnY, &returnWidth, &returnHeight, &error);
73     if (error.error_code == 0) {   77     if (error.error_code == 0) {
74         return createJavaRect(env, returnX, returnY, returnWidth, returnHeight);   78         return createJavaRect(env, returnX, returnY, returnWidth, returnHeight);
75     } else {   79     } else {
76         UGL_ErrorHandler(env, "Image_GetBounds", &error);   80         UGL_ErrorHandler(env, "Image_GetBounds", &error);
77         return 0;   81         return 0;
78     }   82     }
79 }   83 }
80     84  
81 /**   85 /**
82 * Returns the color depth of the image identified by <code>handle</code>.   86 * Returns the color depth of the image identified by <code>handle</code>.
83 * The supported color depths are 1, 2, 4, 8, 16, 24 and 32 bit. The   87 * The supported color depths are 1, 2, 4, 8, 16, 24 and 32 bit. The
84 * returned depth must be one of the values supported by UGL. In the case   88 * returned depth must be one of the values supported by UGL. In the case
85 * of 3, 5, 6 or 7 bit GIFs the returned depth should reflect the actual   89 * of 3, 5, 6 or 7 bit GIFs the returned depth should reflect the actual
86 * "color resolution" as defined in the GIF89a spec.   90 * "color resolution" as defined in the GIF89a spec.
87 */   91 */
88 JNIEXPORT jint JNICALL Java_com_ibm_ugl_p3ml_OS_Image_1GetDepth(JNIEnv* env, jclass UNUSED(clazz), jint handle)   92 JNIEXPORT jint JNICALL Java_com_ibm_ugl_p3ml_OS_Image_1GetDepth(JNIEnv* env, jclass UNUSED(clazz), jint handle)
89 {   93 {
90     UGL_ErrorStruct error;   94     UGL_ErrorStruct error;
91     UGL_Int returnValue;   95     UGL_Int returnValue;
92       96    
93     error.error_code = 0;   97     error.error_code = 0;
94       98    
95     #ifdef debug_print   99     #ifdef debug_print
96     APITRACE(env, "Entering - Image_GetDepth\n");   100     APITRACE(env, "Entering - Image_GetDepth\n");
97     APIARGTRACE(env, "\thandle=%d\n" , handle);   101     APIARGTRACE(env, "\thandle=%d\n" , handle);
98     #endif   102     #endif
99     103  
100     returnValue = Image_GetDepth(handle, &error);   104     returnValue = Image_GetDepth(handle, &error);
101     if (error.error_code == 0) {   105     if (error.error_code == 0) {
102         return returnValue;   106         return returnValue;
103     } else {   107     } else {
104         UGL_ErrorHandler(env, "Image_GetDepth", &error);   108         UGL_ErrorHandler(env, "Image_GetDepth", &error);
105         return 0;   109         return 0;
106     }   110     }
107 }   111 }
108     112  
109 /**   113 /**
110 * Creates a new image from the supplied pixel data. Each pixel is an   114 * Creates a new image from the supplied pixel data. Each pixel is an
111 * index into a color palette. The color palette is supplied in the   115 * index into a color palette. The color palette is supplied in the
112 * indexed color arrays. The palette may not use all possible color   116 * indexed color arrays. The palette may not use all possible color
113 * values . In other words the number of elements may be less than   117 * values . In other words the number of elements may be less than
114 * (2^depth). Supported color depths are 1, 2, 4 and 8 bits per pixel.   118 * (2^depth). Supported color depths are 1, 2, 4 and 8 bits per pixel.
115 * <p>   119 * <p>
116 * May result in the following errors:   120 * May result in the following errors:
117 * <ul>   121 * <ul>
118 * <li>ERROR_UNSUPPORTED_DEPTH - the color depth is not supported</li>   122 * <li>ERROR_UNSUPPORTED_DEPTH - the color depth is not supported</li>
119 * <li>ERROR_INVALID_IMAGE - an error has occurred while creating the image</li>   123 * <li>ERROR_INVALID_IMAGE - an error has occurred while creating the image</li>
120 * </ul>   124 * </ul>
121 * </p>   125 * </p>
122 */   126 */
123 JNIEXPORT jint JNICALL Java_com_ibm_ugl_p3ml_OS_Image_1NewFromByteData(JNIEnv* env, jclass UNUSED(clazz), jint deviceHandle, jint width, jint height, jbyteArray imageData, jint bytesPerLine, jint depth, jbyteArray indexedReds, jbyteArray indexedGreens, jbyteArray indexedBlues, jint paletteSize, jint transparentPixel)   127 JNIEXPORT jint JNICALL Java_com_ibm_ugl_p3ml_OS_Image_1NewFromByteData(JNIEnv* env, jclass UNUSED(clazz), jint deviceHandle, jint width, jint height, jbyteArray imageData, jint bytesPerLine, jint depth, jbyteArray indexedReds, jbyteArray indexedGreens, jbyteArray indexedBlues, jint paletteSize, jint transparentPixel)
124 {   128 {
125     UGL_ErrorStruct error;   129     UGL_ErrorStruct error;
126     UGL_Int returnValue;   130     UGL_Int returnValue;
127     UGL_ByteArray uglimageData;   131     UGL_ByteArray uglimageData;
128     UGL_ByteArray uglindexedBlues;   132     UGL_ByteArray uglindexedBlues;
129     UGL_ByteArray uglindexedGreens;   133     UGL_ByteArray uglindexedGreens;
130     UGL_ByteArray uglindexedReds;   134     UGL_ByteArray uglindexedReds;
131       135    
132     uglimageData = GetByteArrayElements(env, imageData);   136     uglimageData = GetByteArrayElements(env, imageData);
133     if (ExceptionCheck(env)) return 0;   137     if (ExceptionCheck(env)) return 0;
134     uglindexedReds = GetByteArrayElements(env, indexedReds);   138     uglindexedReds = GetByteArrayElements(env, indexedReds);
135     if (ExceptionCheck(env)) return 0;   139     if (ExceptionCheck(env)) return 0;
136     uglindexedGreens = GetByteArrayElements(env, indexedGreens);   140     uglindexedGreens = GetByteArrayElements(env, indexedGreens);
137     if (ExceptionCheck(env)) return 0;   141     if (ExceptionCheck(env)) return 0;
138     uglindexedBlues = GetByteArrayElements(env, indexedBlues);   142     uglindexedBlues = GetByteArrayElements(env, indexedBlues);
139     if (ExceptionCheck(env)) return 0;   143     if (ExceptionCheck(env)) return 0;
140     error.error_code = 0;   144     error.error_code = 0;
141       145    
142     #ifdef debug_print   146     #ifdef debug_print
143     APITRACE(env, "Entering - Image_NewFromByteData\n");   147     APITRACE(env, "Entering - Image_NewFromByteData\n");
144     APIARGTRACE(env, "\tdeviceHandle=%d\n" , deviceHandle);   148     APIARGTRACE(env, "\tdeviceHandle=%d\n" , deviceHandle);
145     APIARGTRACE(env, "\twidth=%d\n" , width);   149     APIARGTRACE(env, "\twidth=%d\n" , width);
146     APIARGTRACE(env, "\theight=%d\n" , height);   150     APIARGTRACE(env, "\theight=%d\n" , height);
147     APIARGTRACE(env, "\tuglimageData (ByteArray)=%p\n" , uglimageData);   151     APIARGTRACE(env, "\tuglimageData (ByteArray)=%p\n" , uglimageData);
148     APIARGTRACE(env, "\tbytesPerLine=%d\n" , bytesPerLine);   152     APIARGTRACE(env, "\tbytesPerLine=%d\n" , bytesPerLine);
149     APIARGTRACE(env, "\tdepth=%d\n" , depth);   153     APIARGTRACE(env, "\tdepth=%d\n" , depth);
150     APIARGTRACE(env, "\tuglindexedReds (ByteArray)=%p\n" , uglindexedReds);   154     APIARGTRACE(env, "\tuglindexedReds (ByteArray)=%p\n" , uglindexedReds);
151     APIARGTRACE(env, "\tuglindexedGreens (ByteArray)=%p\n" , uglindexedGreens);   155     APIARGTRACE(env, "\tuglindexedGreens (ByteArray)=%p\n" , uglindexedGreens);
152     APIARGTRACE(env, "\tuglindexedBlues (ByteArray)=%p\n" , uglindexedBlues);   156     APIARGTRACE(env, "\tuglindexedBlues (ByteArray)=%p\n" , uglindexedBlues);
153     APIARGTRACE(env, "\tpaletteSize=%d\n" , paletteSize);   157     APIARGTRACE(env, "\tpaletteSize=%d\n" , paletteSize);
154     APIARGTRACE(env, "\ttransparentPixel=%d\n" , transparentPixel);   158     APIARGTRACE(env, "\ttransparentPixel=%d\n" , transparentPixel);
155     #endif   159     #endif
156     160  
157     returnValue = Image_NewFromByteData(deviceHandle, width, height, uglimageData, bytesPerLine, depth, uglindexedReds, uglindexedGreens, uglindexedBlues, paletteSize, transparentPixel, &error);   161     returnValue = Image_NewFromByteData(deviceHandle, width, height, uglimageData, bytesPerLine, depth, uglindexedReds, uglindexedGreens, uglindexedBlues, paletteSize, transparentPixel, &error);
158     ReleaseByteArrayElements(env, imageData, uglimageData);   162     ReleaseByteArrayElements(env, imageData, uglimageData);
159     ReleaseByteArrayElements(env, indexedReds, uglindexedReds);   163     ReleaseByteArrayElements(env, indexedReds, uglindexedReds);
160     ReleaseByteArrayElements(env, indexedGreens, uglindexedGreens);   164     ReleaseByteArrayElements(env, indexedGreens, uglindexedGreens);
161     ReleaseByteArrayElements(env, indexedBlues, uglindexedBlues);   165     ReleaseByteArrayElements(env, indexedBlues, uglindexedBlues);
162     if (error.error_code == 0) {   166     if (error.error_code == 0) {
163         return returnValue;   167         return returnValue;
164     } else {   168     } else {
165         UGL_ErrorHandler(env, "Image_NewFromByteData", &error);   169         UGL_ErrorHandler(env, "Image_NewFromByteData", &error);
166         return 0;   170         return 0;
167     }   171     }
168 }   172 }
169     173  
170 /**   174 /**
171 * Creates a new image using the supplied raw data.   175 * Creates a new image using the supplied raw data.
172 * <p>   176 * <p>
173 * May result in the following errors:   177 * May result in the following errors:
174 * <ul>   178 * <ul>
175 * <li>ERROR_UNSUPPORTED_DEPTH - the color depth is not supported</li>   179 * <li>ERROR_UNSUPPORTED_DEPTH - the color depth is not supported</li>
176 * <li>ERROR_INVALID_IMAGE - an error has occurred while creating the image</li>   180 * <li>ERROR_INVALID_IMAGE - an error has occurred while creating the image</li>
177 * </ul>   181 * </ul>
178 * </p>   182 * </p>
179 */   183 */
180 JNIEXPORT jint JNICALL Java_com_ibm_ugl_p3ml_OS_Image_1NewFromFileData(JNIEnv* env, jclass UNUSED(clazz), jint deviceHandle, jbyteArray data, jint length)   184 JNIEXPORT jint JNICALL Java_com_ibm_ugl_p3ml_OS_Image_1NewFromFileData(JNIEnv* env, jclass UNUSED(clazz), jint deviceHandle, jbyteArray data, jint length)
181 {   185 {
182     UGL_ErrorStruct error;   186     UGL_ErrorStruct error;
183     UGL_Int returnValue;   187     UGL_Int returnValue;
184     UGL_ByteArray ugldata;   188     UGL_ByteArray ugldata;
185       189    
186     ugldata = GetByteArrayElements(env, data);   190     ugldata = GetByteArrayElements(env, data);
187     if (ExceptionCheck(env)) return 0;   191     if (ExceptionCheck(env)) return 0;
188     error.error_code = 0;   192     error.error_code = 0;
189       193    
190     #ifdef debug_print   194     #ifdef debug_print
191     APITRACE(env, "Entering - Image_NewFromFileData\n");   195     APITRACE(env, "Entering - Image_NewFromFileData\n");
192     APIARGTRACE(env, "\tdeviceHandle=%d\n" , deviceHandle);   196     APIARGTRACE(env, "\tdeviceHandle=%d\n" , deviceHandle);
193     APIARGTRACE(env, "\tugldata (ByteArray)=%p\n" , ugldata);   197     APIARGTRACE(env, "\tugldata (ByteArray)=%p\n" , ugldata);
194     APIARGTRACE(env, "\tlength=%d\n" , length);   198     APIARGTRACE(env, "\tlength=%d\n" , length);
195     #endif   199     #endif
196     200  
197     returnValue = Image_NewFromFileData(deviceHandle, ugldata, length, &error);   201     returnValue = Image_NewFromFileData(deviceHandle, ugldata, length, &error);
198     ReleaseByteArrayElements(env, data, ugldata);   202     ReleaseByteArrayElements(env, data, ugldata);
199     if (error.error_code == 0) {   203     if (error.error_code == 0) {
200         return returnValue;   204         return returnValue;
201     } else {   205     } else {
202         UGL_ErrorHandler(env, "Image_NewFromFileData", &error);   206         UGL_ErrorHandler(env, "Image_NewFromFileData", &error);
203         return 0;   207         return 0;
204     }   208     }
205 }   209 }
206     210  
207 /**   211 /**
208 * Creates a new image from the supplied pixel data. Each pixel is a direct   212 * Creates a new image from the supplied pixel data. Each pixel is a direct
209 * color RGB value. Supported color depths are 16, 24 and 32 bits per pixel.   213 * color RGB value. Supported color depths are 16, 24 and 32 bits per pixel.
210 * For 16 bit depth the RGB bits are layed out as 5-6-5 bits for red, green   214 * For 16 bit depth the RGB bits are layed out as 5-6-5 bits for red, green
211 * and blue respectively, 24 bit depth uses 8-8-8 bits and no alpha channel.   215 * and blue respectively, 24 bit depth uses 8-8-8 bits and no alpha channel.
212 * 32 bit color depth uses 8-8-8 bits and the most significant byte for the   216 * 32 bit color depth uses 8-8-8 bits and the most significant byte for the
213 * alpha channel for an ARGB pixel layout. For 32 bit pixel data the alpha   217 * alpha channel for an ARGB pixel layout. For 32 bit pixel data the alpha
214 * channel byte is ignored if either one of the   218 * channel byte is ignored if either one of the
215 * <code>transparentColor</code>, <code>globalAlpha</code> or   219 * <code>transparentColor</code>, <code>globalAlpha</code> or
216 * <code>alphaData</code> is specified. Only one of the three transparency/   220 * <code>alphaData</code> is specified. Only one of the three transparency/
217 * alpha arguments may be specified at a time.   221 * alpha arguments may be specified at a time.
218 * <p>   222 * <p>
219 * May result in the following errors:   223 * May result in the following errors:
220 * <ul>   224 * <ul>
221 * <li>ERROR_UNSUPPORTED_DEPTH - the color depth is not supported</li>   225 * <li>ERROR_UNSUPPORTED_DEPTH - the color depth is not supported</li>
222 * <li>ERROR_INVALID_IMAGE - an error has occurred while creating the image</li>   226 * <li>ERROR_INVALID_IMAGE - an error has occurred while creating the image</li>
223 * </ul>   227 * </ul>
224 * </p>   228 * </p>
225 */   229 */
226 JNIEXPORT jint JNICALL Java_com_ibm_ugl_p3ml_OS_Image_1NewFromIntData(JNIEnv* env, jclass UNUSED(clazz), jint deviceHandle, jint width, jint height, jintArray imageData, jint depth, jint transparentColor, jint globalAlpha, jbyteArray alphaData)   230 JNIEXPORT jint JNICALL Java_com_ibm_ugl_p3ml_OS_Image_1NewFromIntData(JNIEnv* env, jclass UNUSED(clazz), jint deviceHandle, jint width, jint height, jintArray imageData, jint depth, jint transparentColor, jint globalAlpha, jbyteArray alphaData)
227 {   231 {
228     UGL_ErrorStruct error;   232     UGL_ErrorStruct error;
229     UGL_Int returnValue;   233     UGL_Int returnValue;
230     UGL_ByteArray uglalphaData;   234     UGL_ByteArray uglalphaData;
231     UGL_IntArray uglimageData;   235     UGL_IntArray uglimageData;
232       236    
233     uglimageData = GetIntArrayElements(env, imageData);   237     uglimageData = GetIntArrayElements(env, imageData);
234     if (ExceptionCheck(env)) return 0;   238     if (ExceptionCheck(env)) return 0;
235     uglalphaData = GetByteArrayElements(env, alphaData);   239     uglalphaData = GetByteArrayElements(env, alphaData);
236     if (ExceptionCheck(env)) return 0;   240     if (ExceptionCheck(env)) return 0;
237     error.error_code = 0;   241     error.error_code = 0;
238       242    
239     #ifdef debug_print   243     #ifdef debug_print
240     APITRACE(env, "Entering - Image_NewFromIntData\n");   244     APITRACE(env, "Entering - Image_NewFromIntData\n");
241     APIARGTRACE(env, "\tdeviceHandle=%d\n" , deviceHandle);   245     APIARGTRACE(env, "\tdeviceHandle=%d\n" , deviceHandle);
242     APIARGTRACE(env, "\twidth=%d\n" , width);   246     APIARGTRACE(env, "\twidth=%d\n" , width);
243     APIARGTRACE(env, "\theight=%d\n" , height);   247     APIARGTRACE(env, "\theight=%d\n" , height);
244     APIARGTRACE(env, "\tuglimageData (IntArray)=%p\n" , uglimageData);   248     APIARGTRACE(env, "\tuglimageData (IntArray)=%p\n" , uglimageData);
245     APIARGTRACE(env, "\tdepth=%d\n" , depth);   249     APIARGTRACE(env, "\tdepth=%d\n" , depth);
246     APIARGTRACE(env, "\ttransparentColor=%d\n" , transparentColor);   250     APIARGTRACE(env, "\ttransparentColor=%d\n" , transparentColor);
247     APIARGTRACE(env, "\tglobalAlpha=%d\n" , globalAlpha);   251     APIARGTRACE(env, "\tglobalAlpha=%d\n" , globalAlpha);
248     APIARGTRACE(env, "\tuglalphaData (ByteArray)=%p\n" , uglalphaData);   252     APIARGTRACE(env, "\tuglalphaData (ByteArray)=%p\n" , uglalphaData);
249     #endif   253     #endif
250     254  
251     returnValue = Image_NewFromIntData(deviceHandle, width, height, uglimageData, depth, transparentColor, globalAlpha, uglalphaData, &error);   255     returnValue = Image_NewFromIntData(deviceHandle, width, height, uglimageData, depth, transparentColor, globalAlpha, uglalphaData, &error);
252     ReleaseIntArrayElements(env, imageData, uglimageData);   256     ReleaseIntArrayElements(env, imageData, uglimageData);
253     ReleaseByteArrayElements(env, alphaData, uglalphaData);   257     ReleaseByteArrayElements(env, alphaData, uglalphaData);
254     if (error.error_code == 0) {   258     if (error.error_code == 0) {
255         return returnValue;   259         return returnValue;
256     } else {   260     } else {
257         UGL_ErrorHandler(env, "Image_NewFromIntData", &error);   261         UGL_ErrorHandler(env, "Image_NewFromIntData", &error);
258         return 0;   262         return 0;
259     }   263     }
260 }   264 }
261     265  
262 /**   266 /**
263 * Creates a new, empty image with the given dimensions.   267 * Creates a new, empty image with the given dimensions.
264 * <p>   268 * <p>
265 * Image will be filled with the provided fill color which   269 * Image will be filled with the provided fill color which
266 * is in 0xAARRGGBB format.   270 * is in 0xAARRGGBB format.
267 * </p>   271 * </p>
268 */   272 */
269 JNIEXPORT jint JNICALL Java_com_ibm_ugl_p3ml_OS_Image_1NewFromSize(JNIEnv* env, jclass UNUSED(clazz), jint deviceHandle, jint width, jint height, jint fillColor)   273 JNIEXPORT jint JNICALL Java_com_ibm_ugl_p3ml_OS_Image_1NewFromSize(JNIEnv* env, jclass UNUSED(clazz), jint deviceHandle, jint width, jint height, jint fillColor)
270 {   274 {
271     UGL_ErrorStruct error;   275     UGL_ErrorStruct error;
272     UGL_Int returnValue;   276     UGL_Int returnValue;
273       277    
274     error.error_code = 0;   278     error.error_code = 0;
275       279    
276     #ifdef debug_print   280     #ifdef debug_print
277     APITRACE(env, "Entering - Image_NewFromSize\n");   281     APITRACE(env, "Entering - Image_NewFromSize\n");
278     APIARGTRACE(env, "\tdeviceHandle=%d\n" , deviceHandle);   282     APIARGTRACE(env, "\tdeviceHandle=%d\n" , deviceHandle);
279     APIARGTRACE(env, "\twidth=%d\n" , width);   283     APIARGTRACE(env, "\twidth=%d\n" , width);
280     APIARGTRACE(env, "\theight=%d\n" , height);   284     APIARGTRACE(env, "\theight=%d\n" , height);
281     APIARGTRACE(env, "\tfillColor=%d\n" , fillColor);   285     APIARGTRACE(env, "\tfillColor=%d\n" , fillColor);
282     #endif   286     #endif
283     287  
284     returnValue = Image_NewFromSize(deviceHandle, width, height, fillColor, &error);   288     returnValue = Image_NewFromSize(deviceHandle, width, height, fillColor, &error);
285     if (error.error_code == 0) {   289     if (error.error_code == 0) {
286         return returnValue;   290         return returnValue;
287     } else {   291     } else {
288         UGL_ErrorHandler(env, "Image_NewFromSize", &error);   292         UGL_ErrorHandler(env, "Image_NewFromSize", &error);
289         return 0;   293         return 0;
290     }   294     }
291 }   295 }
292     296  
    <> 297 JNIEXPORT jint JNICALL Java_com_ibm_ugl_p3ml_OS_Image_1NewFromSystemResource(JNIEnv* env, jclass UNUSED(clazz), jint deviceHandle, jint identifier)
      298 {
      299     UGL_ErrorStruct error;
      300     UGL_Int returnValue;
      301    
      302     error.error_code = 0;
      303    
      304     #ifdef debug_print
      305     APITRACE(env, "Entering - Image_NewFromSystemResource\n");
      306     APIARGTRACE(env, "\tdeviceHandle=%d\n" , deviceHandle);
      307     APIARGTRACE(env, "\tidentifier=%d\n" , height);
      308     APIARGTRACE(env, "\tfillColor=%d\n" , fillColor);
      309     #endif
      310  
      311     returnValue = Image_NewFromSystemResource(deviceHandle, identifier, &error);
      312     if (error.error_code == 0) {
      313         return returnValue;
      314     } else {
      315         UGL_ErrorHandler(env, "Image_NewFromSystemResource", &error);
      316         return 0;
      317     }
      318 }
      319  
293 /** = 320 /**
294 * Creates a new graphics context on the image identified by   321 * Creates a new graphics context on the image identified by
295 * <code>handle</code>   322 * <code>handle</code>
296 */   323 */
297 JNIEXPORT jint JNICALL Java_com_ibm_ugl_p3ml_OS_Image_1NewGraphics(JNIEnv* env, jclass UNUSED(clazz), jint handle)   324 JNIEXPORT jint JNICALL Java_com_ibm_ugl_p3ml_OS_Image_1NewGraphics(JNIEnv* env, jclass UNUSED(clazz), jint handle)
298 {   325 {
299     UGL_ErrorStruct error;   326     UGL_ErrorStruct error;
300     UGL_Int returnValue;   327     UGL_Int returnValue;
301       328    
302     error.error_code = 0;   329     error.error_code = 0;
303       330    
304     #ifdef debug_print   331     #ifdef debug_print
305     APITRACE(env, "Entering - Image_NewGraphics\n");   332     APITRACE(env, "Entering - Image_NewGraphics\n");
306     APIARGTRACE(env, "\thandle=%d\n" , handle);   333     APIARGTRACE(env, "\thandle=%d\n" , handle);
307     #endif   334     #endif
308     335  
309     returnValue = Image_NewGraphics(handle, &error);   336     returnValue = Image_NewGraphics(handle, &error);
310     if (error.error_code == 0) {   337     if (error.error_code == 0) {
311         return returnValue;   338         return returnValue;
312     } else {   339     } else {
313         UGL_ErrorHandler(env, "Image_NewGraphics", &error);   340         UGL_ErrorHandler(env, "Image_NewGraphics", &error);
314         return 0;   341         return 0;
315     }   342     }
316 }   343 }
317   <>    
318   = 344  
319     345  
320 /**   346 /**
321 * Returns the direct color model masks of the image identified by   347 * Returns the direct color model masks of the image identified by
322 * <code>handle</code>.   348 * <code>handle</code>.
323 * <p>   349 * <p>
324 * Color masks are used to access individual color components of a   350 * Color masks are used to access individual color components of a
325 * direct color pixel. There is one mask for each of the red, green,   351 * direct color pixel. There is one mask for each of the red, green,
326 * blue and alpha component of a pixel. The masks for a 32 bit   352 * blue and alpha component of a pixel. The masks for a 32 bit
327 * per pixel image for example might be red=0xFF, green=0x00FF,   353 * per pixel image for example might be red=0xFF, green=0x00FF,
328 * blue=0x0000FF, alpha=0x000000FF.   354 * blue=0x0000FF, alpha=0x000000FF.
329 * </p>   355 * </p>
330 * <p>   356 * <p>
331 * Example: Given a pixel value, <code>int pixel</code>, returned by   357 * Example: Given a pixel value, <code>int pixel</code>, returned by
332 * <code>Image_GetPixelsHighColor()</code> the red color component can be extracted   358 * <code>Image_GetPixelsHighColor()</code> the red color component can be extracted
333 * as follows.   359 * as follows.
334 * <pre>   360 * <pre>
335 * int[] masks = Image_GetDirectPaletteMasks(imageHandle);   361 * int[] masks = Image_GetDirectPaletteMasks(imageHandle);
336 * int redMask = masks[OS.PALETTE_MASK_RED];   362 * int redMask = masks[OS.PALETTE_MASK_RED];
337 * int redShift = getMaskShift(redMask);   363 * int redShift = getMaskShift(redMask);
338 * int red = (pixel & redMask) >>> redShift;   364 * int red = (pixel & redMask) >>> redShift;
339 * </pre>   365 * </pre>
340 * Where getMaskShift is defined separately to return the bit shift   366 * Where getMaskShift is defined separately to return the bit shift
341 * necessary to shift the masked bits to the low order bits.   367 * necessary to shift the masked bits to the low order bits.
342 * <pre>   368 * <pre>
343 * int getMaskShift(int colorMask) {   369 * int getMaskShift(int colorMask) {
344 * int shiftCount = 0;   370 * int shiftCount = 0;
345 * if (mask == 0) return 0;   371 * if (mask == 0) return 0;
346 * while (((mask >> shiftCount) & 0x1) == 0) {   372 * while (((mask >> shiftCount) & 0x1) == 0) {
347 * shiftCount++;   373 * shiftCount++;
348 * }   374 * }
349 * return shiftCount;   375 * return shiftCount;
350 * }   376 * }
351 * </pre>   377 * </pre>
352 * </p>   378 * </p>
353 * <p>   379 * <p>
354 * May result in the following error:   380 * May result in the following error:
355 * <ul>   381 * <ul>
356 * <li>ERROR_UNSUPPORTED_DEPTH - direct palette not supported for this color depth</li>   382 * <li>ERROR_UNSUPPORTED_DEPTH - direct palette not supported for this color depth</li>
357 * </ul>   383 * </ul>
358 * </p>   384 * </p>
359 */   385 */
360 JNIEXPORT jintArray JNICALL Java_com_ibm_ugl_eswt_OS_Image_1GetDirectPaletteMasks(JNIEnv* env, jclass UNUSED(clazz), jint handle)   386 JNIEXPORT jintArray JNICALL Java_com_ibm_ugl_eswt_OS_Image_1GetDirectPaletteMasks(JNIEnv* env, jclass UNUSED(clazz), jint handle)
361 {   387 {
362     UGL_ErrorStruct error;   388     UGL_ErrorStruct error;
363     UGL_Int returnAlphaMask;   389     UGL_Int returnAlphaMask;
364     UGL_Int returnBlueMask;   390     UGL_Int returnBlueMask;
365     UGL_Int returnGreenMask;   391     UGL_Int returnGreenMask;
366     UGL_Int returnRedMask;   392     UGL_Int returnRedMask;
367       393    
368     error.error_code = 0;   394     error.error_code = 0;
369       395    
370     #ifdef debug_print   396     #ifdef debug_print
371     APITRACE(env, "Entering - Image_GetDirectPaletteMasks\n");   397     APITRACE(env, "Entering - Image_GetDirectPaletteMasks\n");
372     APIARGTRACE(env, "\thandle=%d\n" , handle);   398     APIARGTRACE(env, "\thandle=%d\n" , handle);
373     #endif   399     #endif
374     400  
375     Image_GetDirectPaletteMasks(handle, &returnRedMask, &returnGreenMask, &returnBlueMask, &returnAlphaMask, &error);   401     Image_GetDirectPaletteMasks(handle, &returnRedMask, &returnGreenMask, &returnBlueMask, &returnAlphaMask, &error);
376     if (error.error_code == 0) {   402     if (error.error_code == 0) {
377         return createJavaPaletteMasks(env, returnRedMask, returnGreenMask, returnBlueMask, returnAlphaMask);   403         return createJavaPaletteMasks(env, returnRedMask, returnGreenMask, returnBlueMask, returnAlphaMask);
378     } else {   404     } else {
379         UGL_ErrorHandler(env, "Image_GetDirectPaletteMasks", &error);   405         UGL_ErrorHandler(env, "Image_GetDirectPaletteMasks", &error);
380         return 0;   406         return 0;
381     }   407     }
382 }   408 }
383     409  
384 /**   410 /**
385 * Returns the indexed palette of the image identified by <code>handle</code>.   411 * Returns the indexed palette of the image identified by <code>handle</code>.
386 * The red, green and blue arrays must be big enough to hold all color   412 * The red, green and blue arrays must be big enough to hold all color
387 * indices for the image's color depth.   413 * indices for the image's color depth.
388 * <p>   414 * <p>
389 * May result in the following error:   415 * May result in the following error:
390 * <ul>   416 * <ul>
391 * <li>ERROR_UNSUPPORTED_DEPTH - indexed palette not supported for this color depth</li>   417 * <li>ERROR_UNSUPPORTED_DEPTH - indexed palette not supported for this color depth</li>
392 * </ul>   418 * </ul>
393 * </p>   419 * </p>
394 */   420 */
395 JNIEXPORT void JNICALL Java_com_ibm_ugl_eswt_OS_Image_1GetIndexedPalette(JNIEnv* env, jclass UNUSED(clazz), jint handle, jbyteArray red, jbyteArray green, jbyteArray blue)   421 JNIEXPORT void JNICALL Java_com_ibm_ugl_eswt_OS_Image_1GetIndexedPalette(JNIEnv* env, jclass UNUSED(clazz), jint handle, jbyteArray red, jbyteArray green, jbyteArray blue)
396 {   422 {
397     UGL_ErrorStruct error;   423     UGL_ErrorStruct error;
398     UGL_ByteArray uglblue;   424     UGL_ByteArray uglblue;
399     UGL_ByteArray uglgreen;   425     UGL_ByteArray uglgreen;
400     UGL_ByteArray uglred;   426     UGL_ByteArray uglred;
401       427    
402     uglred = GetByteArrayElements(env, red);   428     uglred = GetByteArrayElements(env, red);
403     if (ExceptionCheck(env)) return ;   429     if (ExceptionCheck(env)) return ;
404     uglgreen = GetByteArrayElements(env, green);   430     uglgreen = GetByteArrayElements(env, green);
405     if (ExceptionCheck(env)) return ;   431     if (ExceptionCheck(env)) return ;
406     uglblue = GetByteArrayElements(env, blue);   432     uglblue = GetByteArrayElements(env, blue);
407     if (ExceptionCheck(env)) return ;   433     if (ExceptionCheck(env)) return ;
408     error.error_code = 0;   434     error.error_code = 0;
409       435    
410     #ifdef debug_print   436     #ifdef debug_print
411     APITRACE(env, "Entering - Image_GetIndexedPalette\n");   437     APITRACE(env, "Entering - Image_GetIndexedPalette\n");
412     APIARGTRACE(env, "\thandle=%d\n" , handle);   438     APIARGTRACE(env, "\thandle=%d\n" , handle);
413     APIARGTRACE(env, "\tuglred (ByteArray)=%p\n" , uglred);   439     APIARGTRACE(env, "\tuglred (ByteArray)=%p\n" , uglred);
414     APIARGTRACE(env, "\tuglgreen (ByteArray)=%p\n" , uglgreen);   440     APIARGTRACE(env, "\tuglgreen (ByteArray)=%p\n" , uglgreen);
415     APIARGTRACE(env, "\tuglblue (ByteArray)=%p\n" , uglblue);   441     APIARGTRACE(env, "\tuglblue (ByteArray)=%p\n" , uglblue);
416     #endif   442     #endif
417     443  
418     Image_GetIndexedPalette(handle, uglred, uglgreen, uglblue, &error);   444     Image_GetIndexedPalette(handle, uglred, uglgreen, uglblue, &error);
419     ReleaseByteArrayElements(env, red, uglred);   445     ReleaseByteArrayElements(env, red, uglred);
420     ReleaseByteArrayElements(env, green, uglgreen);   446     ReleaseByteArrayElements(env, green, uglgreen);
421     ReleaseByteArrayElements(env, blue, uglblue);   447     ReleaseByteArrayElements(env, blue, uglblue);
422     if (error.error_code == 0) {   448     if (error.error_code == 0) {
423         return;   449         return;
424     } else {   450     } else {
425         UGL_ErrorHandler(env, "Image_GetIndexedPalette", &error);   451         UGL_ErrorHandler(env, "Image_GetIndexedPalette", &error);
426     }   452     }
427 }   453 }
428     454  
429 /*   455 /*
430 * Class:     com_ibm_ugl_eswt_OS   456 * Class:     com_ibm_ugl_eswt_OS
431 * Method:    Image_GetPixelsHighColor   457 * Method:    Image_GetPixelsHighColor
432 * Signature: (I)[I   458 * Signature: (I)[I
433 */   459 */
434 JNIEXPORT jintArray JNICALL Java_com_ibm_ugl_eswt_OS_Image_1GetPixelsHighColor   460 JNIEXPORT jintArray JNICALL Java_com_ibm_ugl_eswt_OS_Image_1GetPixelsHighColor
435 #ifdef __cplusplus   461 #ifdef __cplusplus
436   (JNIEnv *env, jclass, jint imageHandle)   462   (JNIEnv *env, jclass, jint imageHandle)
437 #else    463 #else 
438   (JNIEnv *env, jclass clazz, jint imageHandle)   464   (JNIEnv *env, jclass clazz, jint imageHandle)
439 #endif   465 #endif
440 {   466 {
441     UGL_ErrorStruct error;   467     UGL_ErrorStruct error;
442     jint dataSize;   468     jint dataSize;
443     jintArray javaArray;   469     jintArray javaArray;
444     UGL_Int x, y, width, height;   470     UGL_Int x, y, width, height;
445       471    
446     error.error_code = 0;   472     error.error_code = 0;
447     Image_GetBounds(imageHandle, &x, &y, &width, &height, &error);   473     Image_GetBounds(imageHandle, &x, &y, &width, &height, &error);
448     dataSize = width * height;   474     dataSize = width * height;
449       475    
450     if (error.error_code == 0) {   476     if (error.error_code == 0) {
451         javaArray = NewIntArray(env, dataSize);   477         javaArray = NewIntArray(env, dataSize);
452         if (ExceptionCheck(env)) return NULL;   478         if (ExceptionCheck(env)) return NULL;
453           479        
454         if (dataSize > 0) {   480         if (dataSize > 0) {
455             jint *pixels = GetIntArrayElements(env, javaArray);   481             jint *pixels = GetIntArrayElements(env, javaArray);
456             if (ExceptionCheck(env)) return javaArray;            482             if (ExceptionCheck(env)) return javaArray;         
457             Image_GetPixelsHighColor(imageHandle, pixels, dataSize, &error);   483             Image_GetPixelsHighColor(imageHandle, pixels, dataSize, &error);
458             ReleaseIntArrayElements(env, javaArray, pixels);   484             ReleaseIntArrayElements(env, javaArray, pixels);
459             if (error.error_code != 0) {   485             if (error.error_code != 0) {
460                 UGL_ErrorHandler(env, "Image_GetPixelsHighColor", &error);   486                 UGL_ErrorHandler(env, "Image_GetPixelsHighColor", &error);
461                 return 0;   487                 return 0;
462             }   488             }
463         }   489         }
464         return javaArray;   490         return javaArray;
465     } else {   491     } else {
466         UGL_ErrorHandler(env, "Image_GetPixelsHighColor", &error);   492         UGL_ErrorHandler(env, "Image_GetPixelsHighColor", &error);
467         return 0;     493         return 0;  
468     }   494     }
469 }   495 }
470 /*   496 /*
471 * Class:     com_ibm_ugl_eswt_OS   497 * Class:     com_ibm_ugl_eswt_OS
472 * Method:    Image_GetPixelsLowColor   498 * Method:    Image_GetPixelsLowColor
473 * Signature: (I)[B   499 * Signature: (I)[B
474 */   500 */
475 JNIEXPORT jbyteArray JNICALL Java_com_ibm_ugl_eswt_OS_Image_1GetPixelsLowColor   501 JNIEXPORT jbyteArray JNICALL Java_com_ibm_ugl_eswt_OS_Image_1GetPixelsLowColor
476 #ifdef __cplusplus   502 #ifdef __cplusplus
477   (JNIEnv *env, jclass, jint imageHandle)   503   (JNIEnv *env, jclass, jint imageHandle)
478 #else    504 #else 
479   (JNIEnv *env, jclass clazz, jint imageHandle)   505   (JNIEnv *env, jclass clazz, jint imageHandle)
480 #endif   506 #endif
481 {   507 {
482     UGL_ErrorStruct error;   508     UGL_ErrorStruct error;
483     jint dataSize;   509     jint dataSize;
484     jbyteArray javaArray;   510     jbyteArray javaArray;
485       511    
486     error.error_code = 0;   512     error.error_code = 0;
487     dataSize = Image_GetSize(imageHandle, &error);   513     dataSize = Image_GetSize(imageHandle, &error);
488     if (error.error_code == 0) {   514     if (error.error_code == 0) {
489         javaArray = NewByteArray(env, dataSize);   515         javaArray = NewByteArray(env, dataSize);
490         if (ExceptionCheck(env)) return NULL;   516         if (ExceptionCheck(env)) return NULL;
491           517        
492         if (dataSize > 0) {   518         if (dataSize > 0) {
493             jbyte *pixels = GetByteArrayElements(env, javaArray);   519             jbyte *pixels = GetByteArrayElements(env, javaArray);
494             if (ExceptionCheck(env)) return javaArray;   520             if (ExceptionCheck(env)) return javaArray;
495             Image_GetPixelsLowColor(imageHandle, pixels, dataSize, &error);   521             Image_GetPixelsLowColor(imageHandle, pixels, dataSize, &error);
496             ReleaseByteArrayElements(env, javaArray, pixels);   522             ReleaseByteArrayElements(env, javaArray, pixels);
497             if (error.error_code != 0) {   523             if (error.error_code != 0) {
498                 UGL_ErrorHandler(env, "Image_GetPixelsLowColor", &error);   524                 UGL_ErrorHandler(env, "Image_GetPixelsLowColor", &error);
499                 return 0;   525                 return 0;
500             }   526             }
501         }   527         }
502         return javaArray;   528         return javaArray;
503     } else {   529     } else {
504         UGL_ErrorHandler(env, "Image_GetPixelsLowColor", &error);   530         UGL_ErrorHandler(env, "Image_GetPixelsLowColor", &error);
505         return 0;   531         return 0;
506     }   532     }
507 }   533 }
508 /**   534 /**
509 * Returns the transparent color of the image identified by   535 * Returns the transparent color of the image identified by
510 * <code>handle</code> or -1 if the image has no transparency.   536 * <code>handle</code> or -1 if the image has no transparency.
511 */   537 */
512 JNIEXPORT jint JNICALL Java_com_ibm_ugl_eswt_OS_Image_1GetTransparentColor(JNIEnv* env, jclass UNUSED(clazz), jint handle)   538 JNIEXPORT jint JNICALL Java_com_ibm_ugl_eswt_OS_Image_1GetTransparentColor(JNIEnv* env, jclass UNUSED(clazz), jint handle)
513 {   539 {
514     UGL_ErrorStruct error;   540     UGL_ErrorStruct error;
515     UGL_Int returnValue;   541     UGL_Int returnValue;
516       542    
517     error.error_code = 0;   543     error.error_code = 0;
518       544    
519     #ifdef debug_print   545     #ifdef debug_print
520     APITRACE(env, "Entering - Image_GetTransparentColor\n");   546     APITRACE(env, "Entering - Image_GetTransparentColor\n");
521     APIARGTRACE(env, "\thandle=%d\n" , handle);   547     APIARGTRACE(env, "\thandle=%d\n" , handle);
522     #endif   548     #endif
523     549  
524     returnValue = Image_GetTransparentColor(handle, &error);   550     returnValue = Image_GetTransparentColor(handle, &error);
525     if (error.error_code == 0) {   551     if (error.error_code == 0) {
526         return returnValue;   552         return returnValue;
527     } else {   553     } else {
528         UGL_ErrorHandler(env, "Image_GetTransparentColor", &error);   554         UGL_ErrorHandler(env, "Image_GetTransparentColor", &error);
529         return 0;   555         return 0;
530     }   556     }
531 }   557 }
532     558  
533 /**   559 /**
534 * Returns whether the image identified by <code>handle</code> uses   560 * Returns whether the image identified by <code>handle</code> uses
535 * a direct color model or a paletted color model.   561 * a direct color model or a paletted color model.
536 */   562 */
537 JNIEXPORT jboolean JNICALL Java_com_ibm_ugl_eswt_OS_Image_1IsDirect(JNIEnv* env, jclass UNUSED(clazz), jint handle)   563 JNIEXPORT jboolean JNICALL Java_com_ibm_ugl_eswt_OS_Image_1IsDirect(JNIEnv* env, jclass UNUSED(clazz), jint handle)
538 {   564 {
539     UGL_ErrorStruct error;   565     UGL_ErrorStruct error;
540     UGL_Boolean returnValue;   566     UGL_Boolean returnValue;
541       567    
542     error.error_code = 0;   568     error.error_code = 0;
543       569    
544     #ifdef debug_print   570     #ifdef debug_print
545     APITRACE(env, "Entering - Image_IsDirect\n");   571     APITRACE(env, "Entering - Image_IsDirect\n");
546     APIARGTRACE(env, "\thandle=%d\n" , handle);   572     APIARGTRACE(env, "\thandle=%d\n" , handle);
547     #endif   573     #endif
548     574  
549     returnValue = Image_IsDirect(handle, &error);   575     returnValue = Image_IsDirect(handle, &error);
550     if (error.error_code == 0) {   576     if (error.error_code == 0) {
551         return convertToJavaBoolean(env, returnValue);   577         return convertToJavaBoolean(env, returnValue);
552     } else {   578     } else {
553         UGL_ErrorHandler(env, "Image_IsDirect", &error);   579         UGL_ErrorHandler(env, "Image_IsDirect", &error);
554         return JNI_FALSE;   580         return JNI_FALSE;
555     }   581     }
556 }   582 }
557     583  
558 /**   584 /**
559 * Creates a new image loaded from the specified file.   585 * Creates a new image loaded from the specified file.
560 * <p>   586 * <p>
561 * May result in the following errors:   587 * May result in the following errors:
562 * <ul>   588 * <ul>
563 * <li>ERROR_IO - I/O error occurred opening or reading the image file</li>   589 * <li>ERROR_IO - I/O error occurred opening or reading the image file</li>
564 * <li>ERROR_UNSUPPORTED_DEPTH - the color depth is not supported</li>   590 * <li>ERROR_UNSUPPORTED_DEPTH - the color depth is not supported</li>
565 * <li>ERROR_INVALID_IMAGE - an error has occurred while creating the image</li>   591 * <li>ERROR_INVALID_IMAGE - an error has occurred while creating the image</li>
566 * </ul>   592 * </ul>
567 * </p>   593 * </p>
568 */   594 */
569 JNIEXPORT jint JNICALL Java_com_ibm_ugl_eswt_OS_Image_1NewFromFile(JNIEnv* env, jclass UNUSED(clazz), jint deviceHandle, jstring fileName)   595 JNIEXPORT jint JNICALL Java_com_ibm_ugl_eswt_OS_Image_1NewFromFile(JNIEnv* env, jclass UNUSED(clazz), jint deviceHandle, jstring fileName)
570 {   596 {
571     UGL_ErrorStruct error;   597     UGL_ErrorStruct error;
572     const jchar* fileNameCharData;   598     const jchar* fileNameCharData;
573     jint fileNameLength;   599     jint fileNameLength;
574     UGL_Boolean fileNameShouldFree;   600     UGL_Boolean fileNameShouldFree;
575     UGL_Int returnValue;   601     UGL_Int returnValue;
576     UGL_String uglfileName;   602     UGL_String uglfileName;
577       603    
578     fileNameCharData = GetStringChars(env, fileName);   604     fileNameCharData = GetStringChars(env, fileName);
579     if (ExceptionCheck(env)) return 0;   605     if (ExceptionCheck(env)) return 0;
580     fileNameLength = GetStringLength(env, fileName);   606     fileNameLength = GetStringLength(env, fileName);
581     uglfileName = convertToNativeString(fileNameCharData, fileNameLength, &fileNameShouldFree);   607     uglfileName = convertToNativeString(fileNameCharData, fileNameLength, &fileNameShouldFree);
582     error.error_code = 0;   608     error.error_code = 0;
583       609    
584     #ifdef debug_print   610     #ifdef debug_print
585     APITRACE(env, "Entering - Image_NewFromFile\n");   611     APITRACE(env, "Entering - Image_NewFromFile\n");
586     APIARGTRACE(env, "\tdeviceHandle=%d\n" , deviceHandle);   612     APIARGTRACE(env, "\tdeviceHandle=%d\n" , deviceHandle);
587     APITRACE(env, "\tfileNameCharData=");   613     APITRACE(env, "\tfileNameCharData=");
588     {   614     {
589         int i;   615         int i;
590         for (i=0; i<fileNameLength; i++) APIARGTRACE(env, "%c" , fileNameCharData[i]);   616         for (i=0; i<fileNameLength; i++) APIARGTRACE(env, "%c" , fileNameCharData[i]);
591     }   617     }
592     APITRACE(env, "\n");   618     APITRACE(env, "\n");
593     #endif   619     #endif
594     620  
595     returnValue = Image_NewFromFile(deviceHandle, uglfileName, &error);   621     returnValue = Image_NewFromFile(deviceHandle, uglfileName, &error);
596     if (fileNameShouldFree) freeNativeString(uglfileName);   622     if (fileNameShouldFree) freeNativeString(uglfileName);
597     ReleaseStringChars(env, fileName, fileNameCharData);   623     ReleaseStringChars(env, fileName, fileNameCharData);
598     if (error.error_code == 0) {   624     if (error.error_code == 0) {
599         return returnValue;   625         return returnValue;
600     } else {   626     } else {
601         UGL_ErrorHandler(env, "Image_NewFromFile", &error);   627         UGL_ErrorHandler(env, "Image_NewFromFile", &error);
602         return 0;   628         return 0;
603     }   629     }
604 }   630 }
605     631  
606   <>    
607        
608        
609        
610 /** = 632 /**
611 * Copies the specified area from the image identified by <code>handle</code>   633 * Copies the specified area from the image identified by <code>handle</code>
612 * into the destination image. The area is copied from location <code>x</code>,   634 * into the destination image. The area is copied from location <code>x</code>,
613 * <code>y</code> in the source image to location 0, 0 in the destination   635 * <code>y</code> in the source image to location 0, 0 in the destination
614 * image.   636 * image.
615 */   637 */
616 JNIEXPORT void JNICALL Java_com_ibm_ugl_p3ml_OS_Image_1CopyArea(JNIEnv* env, jclass UNUSED(clazz), jint handle, jint destImageHandle, jint x, jint y, jint width, jint height)   638 JNIEXPORT void JNICALL Java_com_ibm_ugl_p3ml_OS_Image_1CopyArea(JNIEnv* env, jclass UNUSED(clazz), jint handle, jint destImageHandle, jint x, jint y, jint width, jint height)
617 {   639 {
618     UGL_ErrorStruct error;   640     UGL_ErrorStruct error;
619       641    
620     error.error_code = 0;   642     error.error_code = 0;
621       643    
622     #ifdef debug_print   644     #ifdef debug_print
623     APITRACE(env, "Entering - Image_CopyArea\n");   645     APITRACE(env, "Entering - Image_CopyArea\n");
624     APIARGTRACE(env, "\thandle=%d\n" , handle);   646     APIARGTRACE(env, "\thandle=%d\n" , handle);
625     APIARGTRACE(env, "\tdestImageHandle=%d\n" , destImageHandle);   647     APIARGTRACE(env, "\tdestImageHandle=%d\n" , destImageHandle);
626     APIARGTRACE(env, "\tx=%d\n" , x);   648     APIARGTRACE(env, "\tx=%d\n" , x);
627     APIARGTRACE(env, "\ty=%d\n" , y);   649     APIARGTRACE(env, "\ty=%d\n" , y);
628     APIARGTRACE(env, "\twidth=%d\n" , width);   650     APIARGTRACE(env, "\twidth=%d\n" , width);
629     APIARGTRACE(env, "\theight=%d\n" , height);   651     APIARGTRACE(env, "\theight=%d\n" , height);
630     #endif   652     #endif
631     653  
632     Image_CopyArea(handle, destImageHandle, x, y, width, height, &error);   654     Image_CopyArea(handle, destImageHandle, x, y, width, height, &error);
633     if (error.error_code == 0) {   655     if (error.error_code == 0) {
634         return;   656         return;
635     } else {   657     } else {
636         UGL_ErrorHandler(env, "Image_CopyArea", &error);   658         UGL_ErrorHandler(env, "Image_CopyArea", &error);
637     }   659     }
638 }   660 }
639     661  
640     662  
641 #ifdef __cplusplus   663 #ifdef __cplusplus
642 }   664 }
643 #endif   665 #endif
644     666