color.c

Go to the documentation of this file.
00001 
00014 #include "color.h"
00015 
00016 #ifdef __cplusplus
00017 extern "C" {
00018 #endif
00019 
00029 Color convertJavaColor(jobject color) {
00030    static jclass jcolor = NULL;
00031    static jmethodID mred = NULL;
00032    static jmethodID mgreen = NULL;
00033    static jmethodID mblue = NULL;
00034    static jmethodID malpha = NULL;
00035 
00036    Color ret = {0, 0, 0, 0};
00037 
00038    if (jcolor == NULL) {
00039       jcolor = findClass(CLS_COLOR);
00040       mred = findMethod(jcolor, "getRed", "()I");
00041       mgreen = findMethod(jcolor, "getGreen", "()I");
00042       mblue = findMethod(jcolor, "getBlue", "()I");
00043       malpha = findMethod(jcolor, "getAlpha", "()I");
00044    }
00045 
00046    if (!isSameObject(color, NULL)) {
00047       ret.red = (unsigned char) callIntMethod(color, mred);
00048       ret.green = (unsigned char) callIntMethod(color, mgreen);
00049       ret.blue = (unsigned char) callIntMethod(color, mblue);
00050       ret.alpha = (unsigned char) callIntMethod(color, malpha);
00051    }
00052 
00053    return ret;
00054 }
00055 
00065 jobject convertColor(const Color* color) {
00066    static jclass jcolor = NULL;
00067    static jmethodID minit = NULL;
00068    jobject ret = NULL;
00069 
00070    if (jcolor == NULL) {
00071       jcolor = findClass(CLS_COLOR);
00072       minit = findMethod(jcolor, "<init>", "(IIII)V");
00073    }
00074    
00075    if (color != NULL) {
00076       ret = newObject(jcolor, minit, color->red, color->green, color->blue, color->alpha);
00077    }
00078 
00079    return ret;
00080 }
00081 
00082 #ifdef __cplusplus
00083 } /* extern "C" */
00084 #endif
00085 
00086 /* end of file color.c */

Generated on Sat Nov 19 14:11:11 2005 for GrubC by  doxygen 1.4.4