⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gxapi_graphics_kni.c

📁 This is a resource based on j2me embedded,if you dont understand,you can connection with me .
💻 C
📖 第 1 页 / 共 3 页
字号:
             * Optimization: This whole block can skip if              * native platform support negative arc input.             */            if (arcAngle < 0) {                startAngle += arcAngle;                arcAngle = -arcAngle;            }            startAngle = (startAngle + 360) % 360;#endif            GET_CLIP(thisObject, clip);            gx_draw_arc(GET_PIXEL(thisObject),                        clip,                        GET_IMAGEDATA_PTR_FROM_GRAPHICS(thisObject),                        GET_LINESTYLE(thisObject),                        x, y, w, h, startAngle, arcAngle);        }        KNI_EndHandles();    }    KNI_ReturnVoid();}/** * Fills the specified circular or elliptical arc segment using the * current color and stroke style. According to the MIDP specification, * if either the <tt>width</tt> or <tt>height</tt> are negative, no * arc is drawn. * <p> * Java declaration: * <pre> *     fillArc(IIIIII)V * </pre> * * @param x The x coordinate of the upper-left corner of the arc *          to be drawn * @param y The y coordinate of the upper-left corner of the arc *          to be drawn * @param width The width of the arc to be drawn * @param height The height of the arc to be drawn * @param startAngle The beginning angle * @param arcAngle The angular extent of the arc, relative to *                 <tt>startAngle</tt> */KNIEXPORT KNI_RETURNTYPE_VOIDKNIDECL(javax_microedition_lcdui_Graphics_fillArc) {    int   arcAngle = KNI_GetParameterAsInt(6);    int startAngle = KNI_GetParameterAsInt(5);    int          h = KNI_GetParameterAsInt(4);    int          w = KNI_GetParameterAsInt(3);    int          y = KNI_GetParameterAsInt(2);    int          x = KNI_GetParameterAsInt(1);    /*     * @note { Spec verify step: "If either width or height     * is less than zero, nothing is drawn." }     */    if ((w >= 0) && (h >= 0)) {        KNI_StartHandles(1);        KNI_DeclareHandle(thisObject);                KNI_GetThisPointer(thisObject);        if (GRAPHICS_OP_IS_ALLOWED(thisObject)) {            jshort clip[4]; /* Defined in Graphics.java as 4 shorts */            TRANSLATE(thisObject, x, y);        #ifdef PLATFORM_SUPPORT_CCW_ARC_ONLY            /* Please see above for explanation */            if (arcAngle < 0) {                startAngle += arcAngle;                arcAngle = -arcAngle;            }            startAngle = (startAngle + 360) % 360;#endif            GET_CLIP(thisObject, clip);            gx_fill_arc(GET_PIXEL(thisObject),                        clip,                        GET_IMAGEDATA_PTR_FROM_GRAPHICS(thisObject),                        GET_LINESTYLE(thisObject),                        x, y, w, h, startAngle, arcAngle);        }        KNI_EndHandles();    }    KNI_ReturnVoid();}/** * Fills the specified triangle using the current color and stroke * style. * <p> * Java declaration: * <pre> *     fillTriangle(IIIIII)V * </pre> * * @param x1 The x coordinate of the first vertices * @param y1 The y coordinate of the first vertices * @param x2 The x coordinate of the second vertices * @param y2 The y coordinate of the second vertices * @param x3 The x coordinate of the third vertices * @param y3 The y coordinate of the third vertices */KNIEXPORT KNI_RETURNTYPE_VOIDKNIDECL(javax_microedition_lcdui_Graphics_fillTriangle) {    int         y3 = KNI_GetParameterAsInt(6);    int         x3 = KNI_GetParameterAsInt(5);    int         y2 = KNI_GetParameterAsInt(4);    int         x2 = KNI_GetParameterAsInt(3);    int         y1 = KNI_GetParameterAsInt(2);    int         x1 = KNI_GetParameterAsInt(1);    KNI_StartHandles(1);    KNI_DeclareHandle(thisObject);    KNI_GetThisPointer(thisObject);    if (GRAPHICS_OP_IS_ALLOWED(thisObject)) {        jshort clip[4]; /* Defined in Graphics.java as 4 shorts */        TRANSLATE(thisObject, x1, y1);        TRANSLATE(thisObject, x2, y2);        TRANSLATE(thisObject, x3, y3);              GET_CLIP(thisObject, clip);        gx_fill_triangle(GET_PIXEL(thisObject),                         clip,                         GET_IMAGEDATA_PTR_FROM_GRAPHICS(thisObject),                         GET_LINESTYLE(thisObject),                         x1, y1, x2, y2, x3, y3);    }    KNI_EndHandles();    KNI_ReturnVoid();}/** * Draws the specified <tt>String</tt> using the current font and color. * <p> * Java declaration: * <pre> *     drawString(Ljava/lang/String;III)V * </pre> * * @param str The <tt>String</tt> to be drawn * @param x The x coordinate of the anchor point * @param y The y coordinate of the anchor point * @param anchor The anchor point for positioning the text */KNIEXPORT KNI_RETURNTYPE_VOIDKNIDECL(javax_microedition_lcdui_Graphics_drawString) {    int anchor = KNI_GetParameterAsInt(4);    int      y = KNI_GetParameterAsInt(3);    int      x = KNI_GetParameterAsInt(2);    int strLen;    KNI_StartHandles(3);    KNI_DeclareHandle(str);    KNI_DeclareHandle(thisObject);    KNI_DeclareHandle(font);    KNI_GetParameterAsObject(1, str);    KNI_GetThisPointer(thisObject);    if (GRAPHICS_OP_IS_ALLOWED(thisObject)) {        strLen = KNI_GetStringLength(str);        if (strLen < 0) {            KNI_ThrowNew(midpNullPointerException, NULL);        } else if (!check_anchor(anchor, VCENTER)) {            KNI_ThrowNew(midpIllegalArgumentException, NULL);        } else {            int      face, style, size;            _JavaString *jstr;            jshort clip[4]; /* Defined in Graphics.java as 4 shorts */            GET_FONT(thisObject, font);                    DECLARE_FONT_PARAMS(font);                    TRANSLATE(thisObject, x, y);                    jstr = GET_STRING_PTR(str);                    GET_CLIP(thisObject, clip);            gx_draw_chars(GET_PIXEL(thisObject),                          clip,                          GET_IMAGEDATA_PTR_FROM_GRAPHICS(thisObject),                          GET_LINESTYLE(thisObject),                          face, style, size, x, y, anchor,                           jstr->value->elements + jstr->offset,                          strLen);        }    }    KNI_EndHandles();    KNI_ReturnVoid();}/** * Draws a portion of the specified <tt>String</tt> using the * current font and color. * <p> * Java declaration: * <pre> *     drawSubstring(Ljava/lang/String;III)V * </pre> * * @param str The <tt>String</tt> to be drawn * @param offset Zero-based index of first character in the substring * @param length Length of the substring * @param x The x coordinate of the anchor point * @param y The y coordinate of the anchor point * @param anchor The anchor point for positioning the text */KNIEXPORT KNI_RETURNTYPE_VOIDKNIDECL(javax_microedition_lcdui_Graphics_drawSubstring) {    int anchor = KNI_GetParameterAsInt(6);    int      y = KNI_GetParameterAsInt(5);    int      x = KNI_GetParameterAsInt(4);    int length = KNI_GetParameterAsInt(3);    int offset = KNI_GetParameterAsInt(2);    int strLen;    KNI_StartHandles(3);    KNI_DeclareHandle(str);    KNI_DeclareHandle(thisObject);    KNI_DeclareHandle(font);    KNI_GetParameterAsObject(1, str);    KNI_GetThisPointer(thisObject);    if (GRAPHICS_OP_IS_ALLOWED(thisObject)) {        strLen = KNI_GetStringLength(str);        if (strLen < 0) {            KNI_ThrowNew(midpNullPointerException, NULL);        } else if (   (offset < 0)                       || (offset > strLen)                       || (length < 0)                      || (length > strLen)                      || ((offset + length) < 0)                      || ((offset + length) > strLen)) {            KNI_ThrowNew(midpStringIndexOutOfBoundsException, NULL);        } else if (!check_anchor(anchor, VCENTER)) {            KNI_ThrowNew(midpIllegalArgumentException, NULL);        } else if (length != 0) {            int      face, style, size;            _JavaString *jstr;            jshort clip[4]; /* Defined in Graphics.java as 4 shorts */                    GET_FONT(thisObject, font);                    DECLARE_FONT_PARAMS(font);                    TRANSLATE(thisObject, x, y);                    jstr = GET_STRING_PTR(str);                    GET_CLIP(thisObject, clip);            gx_draw_chars(GET_PIXEL(thisObject),                          clip,                          GET_IMAGEDATA_PTR_FROM_GRAPHICS(thisObject),                          GET_LINESTYLE(thisObject),                          face, style, size, x, y, anchor,                          jstr->value->elements + (jstr->offset + offset),                          length);        }    }    KNI_EndHandles();    KNI_ReturnVoid();}/** * Draws the specified character using the current font and color. * <p> * Java declaration: * <pre> *     drawChar(CIII)V * </pre> * * @param ch The character to be drawn * @param x The x coordinate of the anchor point * @param y The y coordinate of the anchor point * @param anchor The anchor point for positioning the text */KNIEXPORT KNI_RETURNTYPE_VOIDKNIDECL(javax_microedition_lcdui_Graphics_drawChar) {    int anchor = KNI_GetParameterAsInt(4);    int      y = KNI_GetParameterAsInt(3);    int      x = KNI_GetParameterAsInt(2);    jchar  c = KNI_GetParameterAsShort(1);    KNI_StartHandles(2);    KNI_DeclareHandle(thisObject);    KNI_DeclareHandle(font);    KNI_GetThisPointer(thisObject);    if (GRAPHICS_OP_IS_ALLOWED(thisObject)) {        if (!check_anchor(anchor, VCENTER)) {            KNI_ThrowNew(midpIllegalArgumentException, NULL);        } else {            int      face, style, size;            jshort clip[4]; /* Defined in Graphics.java as 4 shorts */            GET_FONT(thisObject, font);            DECLARE_FONT_PARAMS(font);            TRANSLATE(thisObject, x, y);            GET_CLIP(thisObject, clip);            gx_draw_chars(GET_PIXEL(thisObject),                          clip,                          GET_IMAGEDATA_PTR_FROM_GRAPHICS(thisObject),                          GET_LINESTYLE(thisObject),                          face, style, size, x, y, anchor, &c, 1);        }    }    KNI_EndHandles();    KNI_ReturnVoid();}/** * Draws the specified characters using the current font and color. * <p> * Java declaration: * <pre> *     drawChars([CIIIII)V * </pre> * * @param data The array of characters to be drawn * @param offset Zero-based index of first character to be drawn * @param length Number of characters to be drawn * @param x The x coordinate of the anchor point * @param y The y coordinate of the anchor point * @param anchor The anchor point for positioning the text */KNIEXPORT KNI_RETURNTYPE_VOIDKNIDECL(javax_microedition_lcdui_Graphics_drawChars) {    int anchor = KNI_GetParameterAsInt(6);    int      y = KNI_GetParameterAsInt(5);    int      x = KNI_GetParameterAsInt(4);    int length = KNI_GetParameterAsInt(3);    int offset = KNI_GetParameterAsInt(2);    int chLen;    KNI_StartHandles(3);    KNI_DeclareHandle(ch);    KNI_DeclareHandle(thisObject);    KNI_DeclareHandle(font);    KNI_GetParameterAsObject(1, ch);    KNI_GetThisPointer(thisObject);    if (GRAPHICS_OP_IS_ALLOWED(thisObject)) {        chLen = KNI_GetArrayLength(ch);        if (chLen < 0) {            KNI_ThrowNew(midpNullPointerException, NULL);        } else if (   (offset < 0)                       || (offset > chLen)                       || (length < 0)                      || (length > chLen)                      || ((offset + length) < 0)                      || ((offset + length) > chLen)) {            KNI_ThrowNew(midpArrayIndexOutOfBoundsException, NULL);        } else if (!check_anchor(anchor, VCENTER)) {            KNI_ThrowNew(midpIllegalArgumentException, NULL);        } else if (length != 0) {            int      face, style, size;            jshort clip[4]; /* Defined in Graphics.java as 4 shorts */            GET_FONT(thisObject, font);                    DECLARE_FONT_PARAMS(font);                    TRANSLATE(thisObject, x, y);                    GET_CLIP(thisObject, clip);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -