/* * Return the height of the window accessed by the given Graphics * object. */ jint JSR239_getGraphicsHeight(jobject graphicsHandle) { #ifdef DEBUG printf("JSR239_getGraphicsHeight\n"); #endif return GXAPI_GET_GRAPHICS_PTR(graphicsHandle)->maxHeight; }
/* * Return the width of the window accessed by the given Graphics * object. */ jint JSR239_getGraphicsWidth(jobject graphicsHandle) { #ifdef DEBUG printf("JSR239_getGraphicsWidth\n"); #endif return GXAPI_GET_GRAPHICS_PTR(graphicsHandle)->maxWidth; }
/** * Draws the specified image by using the anchor point. * The image can be drawn in different positions relative to * the anchor point by passing the appropriate position constants. * See <a href="#anchor">anchor points</a>. * * <p>If the source image contains transparent pixels, the corresponding * pixels in the destination image must be left untouched. If the source * image contains partially transparent pixels, a compositing operation * must be performed with the destination pixels, leaving all pixels of * the destination image fully opaque.</p> * * <p>If <code>img</code> is the same as the destination of this Graphics * object, the result is undefined. For copying areas within an * <code>Image</code>, {@link #copyArea copyArea} should be used instead. * </p> * * @param g the specified Graphics 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 image * @throws IllegalArgumentException if <code>anchor</code> * is not a legal value * @throws NullPointerException if <code>g</code> is <code>null</code> * @see Image */ KNIEXPORT KNI_RETURNTYPE_BOOLEAN KNIDECL(javax_microedition_lcdui_Image_render) { jboolean success = KNI_TRUE; int anchor = KNI_GetParameterAsInt(4); int y = KNI_GetParameterAsInt(3); int x = KNI_GetParameterAsInt(2); KNI_StartHandles(3); KNI_DeclareHandle(img); KNI_DeclareHandle(g); KNI_DeclareHandle(gImg); KNI_GetParameterAsObject(1, g); KNI_GetThisPointer(img); if (GRAPHICS_OP_IS_ALLOWED(g)) { /* null checking is handled by the Java layer, but test just in case */ if (KNI_IsNullHandle(img)) { success = KNI_FALSE; //KNI_ThrowNew(midpNullPointerException, NULL); } else { const java_imagedata * srcImageDataPtr = GET_IMAGE_PTR(img)->imageData; GET_IMAGE_PTR(gImg) = (struct Java_javax_microedition_lcdui_Image *) (GXAPI_GET_GRAPHICS_PTR(g)->img); if (KNI_IsSameObject(gImg, img) || !gxutl_check_anchor(anchor,0)) { success = KNI_FALSE; //KNI_ThrowNew(midpIllegalArgumentException, NULL); } else if (!gxutl_normalize_anchor(&x, &y, srcImageDataPtr->width, srcImageDataPtr->height, anchor)) { success = KNI_FALSE;//KNI_ThrowNew(midpIllegalArgumentException, NULL); } else { jshort clip[4]; /* Defined in Graphics.java as 4 shorts */ const java_imagedata * dstMutableImageDataPtr = GXAPI_GET_IMAGEDATA_PTR_FROM_GRAPHICS(g); GXAPI_TRANSLATE(g, x, y); GXAPI_GET_CLIP(g, clip); gx_render_image(srcImageDataPtr, dstMutableImageDataPtr, clip, x, y); } } } KNI_EndHandles(); KNI_ReturnBoolean(success); }
/** * Helper function. * Retrieve buffer for the specified graphics. * * @param graphicshandle A KNI handle to a graphics object. * @return QPixmap that represents the graphics buffer. */ static QPixmap* getGraphicsBuffer(jobject graphicsHandle) { QPixmap* pixmap; java_image* image; image = GXAPI_GET_GRAPHICS_PTR(graphicsHandle)->img; if (image != NULL) { /* * If the graphics context has a parent image bound to it, * pick up the pixmap. */ pixmap = gxpportqt_get_mutableimage_pixmap( (gxpport_mutableimage_native_handle) (image->imageData->nativeImageData)); } else { /* If no image is bound, render to back buffer */ pixmap = qteapp_get_mscreen()->getBackBuffer(); } return pixmap; }
/** * Create native representation for a image. * * @param jimg Java Image ROM structure to convert from * @param sbuf pointer to Screen buffer structure to populate * @param g optional Graphics object for debugging clip code. * give NULL if don't care. * * @return the given 'sbuf' pointer for convenient usage, * or NULL if the image is null. */ gxj_screen_buffer* gxj_get_image_screen_buffer_impl(const java_imagedata *img, gxj_screen_buffer *sbuf, kjobject graphics) { /* NOTE: * Since this routine is called by every graphics operations * We use ROMStruct directly instead of macros * like JavaByteArray, etc, for max performance. */ if (img == NULL) { return NULL; } sbuf->width = img->width; sbuf->height = img->height; /* Only use nativePixelData and nativeAlphaData if * pixelData is null */ if (img->pixelData != NULL) { sbuf->pixelData = (gxj_pixel_type *)&(img->pixelData->elements[0]); sbuf->alphaData = (img->alphaData != NULL) ? (gxj_alpha_type *)&(img->alphaData->elements[0]) : NULL; } else { sbuf->pixelData = (gxj_pixel_type *)img->nativePixelData; sbuf->alphaData = (gxj_alpha_type *)img->nativeAlphaData; } #if ENABLE_BOUNDS_CHECKS sbuf->g = (graphics != NULL) ? GXAPI_GET_GRAPHICS_PTR(graphics) : NULL; #else (void)graphics; /* Surpress unused parameter warning */ #endif return sbuf; }
/** * Renders the given region of this <tt>ImmutableImage</tt> onto the * given <tt>Graphics</tt> object. * <p> * Java declaration: * <pre> * renderRegion(Ljavax/microedition/lcdui/ImageImpl;IIIIIIII)V * </pre> * * @param g The <tt>Graphics</tt> object to be drawn * @param x_src The x coordinate of the upper-left corner of the * source region * @param y_src The y coordinate of the upper-left corner of the * source region * @param width The width of the source region * @param height The height of the source region * @param transform The transform to apply to the selected region. * @param x_dest The x coordinate of the destination anchor point * @param y_dest The y coordinate of the destination anchor point * @param anchor The anchor point for positioning the destination * <tt>Image</tt> */ KNIEXPORT KNI_RETURNTYPE_BOOLEAN KNIDECL(javax_microedition_lcdui_Image_renderRegion) { int anchor = KNI_GetParameterAsInt(9); int y_dest = KNI_GetParameterAsInt(8); int x_dest = KNI_GetParameterAsInt(7); int transform = KNI_GetParameterAsInt(6); int height = KNI_GetParameterAsInt(5); int width = KNI_GetParameterAsInt(4); int y_src = KNI_GetParameterAsInt(3); int x_src = KNI_GetParameterAsInt(2); jboolean success = KNI_TRUE; KNI_StartHandles(3); KNI_DeclareHandle(img); KNI_DeclareHandle(g); KNI_DeclareHandle(gImg); KNI_GetParameterAsObject(1, g); KNI_GetThisPointer(img); if (GRAPHICS_OP_IS_ALLOWED(g)) { if (KNI_IsNullHandle(img)) { /* null checking is performed in the Java code, but check just in case */ success = KNI_FALSE; //KNI_ThrowNew(midpNullPointerException, NULL); } else if ((transform < 0) || (transform > 7)) { success = KNI_FALSE; //KNI_ThrowNew(midpIllegalArgumentException, NULL); } else if (!gxutl_normalize_anchor(&x_dest, &y_dest, width, height, anchor)) { success = KNI_FALSE; //KNI_ThrowNew(midpIllegalArgumentException, NULL); } else { const java_imagedata * srcImageDataPtr = GET_IMAGE_PTR(img)->imageData; jint img_width = srcImageDataPtr->width; jint img_height = srcImageDataPtr->height; GET_IMAGE_PTR(gImg) = (struct Java_javax_microedition_lcdui_Image *) (GXAPI_GET_GRAPHICS_PTR(g)->img); if (KNI_IsSameObject(gImg, img) || (height < 0) || (width < 0) || (x_src < 0) || (y_src < 0) || ((x_src + width) > img_width) || ((y_src + height) > img_height)) { success = KNI_FALSE; //KNI_ThrowNew(midpIllegalArgumentException, NULL); } else { jshort clip[4]; /* Defined in Graphics.java as 4 shorts */ const java_imagedata * dstMutableImageDataPtr = GXAPI_GET_IMAGEDATA_PTR_FROM_GRAPHICS(g); GXAPI_TRANSLATE(g, x_dest, y_dest); GXAPI_GET_CLIP(g, clip); gx_render_imageregion(srcImageDataPtr, dstMutableImageDataPtr, clip, x_src, y_src, width, height, x_dest, y_dest, transform); } } } KNI_EndHandles(); KNI_ReturnBoolean(success); }