/**
 * Gets an ARGB integer array from this <tt>ImmutableImage</tt>. The
 * array consists of values in the form of 0xAARRGGBB.
 * <p>
 * Java declaration:
 * <pre>
 *     getRGB([IIIIIII)V
 * </pre>
 *
 * @param rgbData The target integer array for the ARGB data
 * @param offset Zero-based index of first ARGB pixel to be saved
 * @param scanlen Number of intervening pixels between pixels in
 *                the same column but in adjacent rows
 * @param x The x coordinate of the upper left corner of the
 *          selected region
 * @param y The y coordinate of the upper left corner of the
 *          selected region
 * @param width The width of the selected region
 * @param height The height of the selected region
 */
KNIEXPORT KNI_RETURNTYPE_VOID
KNIDECL(javax_microedition_lcdui_ImageData_getRGB) {
    int height = KNI_GetParameterAsInt(7);
    int width = KNI_GetParameterAsInt(6);
    int y = KNI_GetParameterAsInt(5);
    int x = KNI_GetParameterAsInt(4);
    int scanlength = KNI_GetParameterAsInt(3);
    int offset = KNI_GetParameterAsInt(2);
    int *rgbBuffer;
    java_imagedata *srcImageDataPtr;
    gxpport_mutableimage_native_handle srcImageNativeData;
    img_native_error_codes error = IMG_NATIVE_IMAGE_NO_ERROR;

    KNI_StartHandles(2);
    KNI_DeclareHandle(rgbData);
    KNI_DeclareHandle(thisObject);

    KNI_GetParameterAsObject(1, rgbData);
    KNI_GetThisPointer(thisObject);


    SNI_BEGIN_RAW_POINTERS;
    
    rgbBuffer = JavaIntArray(rgbData);

    srcImageDataPtr = IMGAPI_GET_IMAGEDATA_PTR(thisObject);
    srcImageNativeData =
      (gxpport_mutableimage_native_handle)srcImageDataPtr->nativeImageData;    

    if (srcImageDataPtr->isMutable) {
        gxpport_get_mutable_argb(srcImageNativeData,
                                 rgbBuffer, offset, scanlength,
                                 x, y, width, height, 
                                 &error);
    } else {
        gxpport_get_immutable_argb(srcImageNativeData,
                                   rgbBuffer, offset, scanlength,
                                   x, y, width, height, 
                                   &error);
    }

    SNI_END_RAW_POINTERS;
    
    if (error != IMG_NATIVE_IMAGE_NO_ERROR) {
      KNI_ThrowNew(midpOutOfMemoryError, NULL);
    }

    KNI_EndHandles();
    KNI_ReturnVoid();
}
Beispiel #2
0
/**
 * Retrieves handles of all service records in the SDDB.
 *
 * @param handles array to receive handles, or null for count query
 * @return number of entries read/available
 */
KNIEXPORT KNI_RETURNTYPE_INT
Java_com_sun_kvem_jsr082_bluetooth_SDDB_getRecords(void)
{
    jint retval;
    KNI_StartHandles(1);
    KNI_DeclareHandle(arrayHandle);
    KNI_GetParameterAsObject(1, arrayHandle);
    if (KNI_IsNullHandle(arrayHandle)) {
        retval = javacall_bt_sddb_get_records(NULL, 0);
    } else {
        retval = javacall_bt_sddb_get_records((bt_sddbid_t *)JavaIntArray(arrayHandle),
                KNI_GetArrayLength(arrayHandle));
    }
    KNI_EndHandles();
    KNI_ReturnInt(retval);
}
Beispiel #3
0
KNIEXPORT KNI_RETURNTYPE_VOID
Java_com_sun_pisces_AbstractSurface_drawRGBImpl() {
    KNI_StartHandles(2);
    KNI_DeclareHandle(objectHandle);
    KNI_DeclareHandle(arrayHandle);

    jint offset = KNI_GetParameterAsInt(2);
    jint scanLength = KNI_GetParameterAsInt(3);
    jint x = KNI_GetParameterAsInt(4);
    jint y = KNI_GetParameterAsInt(5);
    jint width = KNI_GetParameterAsInt(6);
    jint height = KNI_GetParameterAsInt(7);
    jfloat opacity = KNI_GetParameterAsFloat(8);

    jint srcX = 0;
    jint srcY = 0;

    Surface* surface;

    KNI_GetParameterAsObject(1, arrayHandle);

    KNI_GetThisPointer(objectHandle);
    surface = (Surface*)JLongToPointer(
                  KNI_GetLongField(objectHandle, fieldIds[SURFACE_NATIVE_PTR]));

    CORRECT_DIMS(surface, x, y, width, height, srcX, srcY);

    if ((width > 0) && (height > 0)) {
        jint* tempArray;
        offset += srcY * scanLength + srcX;

        SNI_BEGIN_RAW_POINTERS;

        tempArray = &JavaIntArray(arrayHandle)[offset];

        ACQUIRE_SURFACE(surface, objectHandle);
        surface_drawRGB(surface, x, y, width, height, tempArray, scanLength,
                        opacity);
        RELEASE_SURFACE(surface, objectHandle);

        SNI_END_RAW_POINTERS;
    }

    KNI_EndHandles();
    KNI_ReturnVoid();
}
/**
 * Loads the <tt>ImageData</tt> with the given ARGB integer
 * array. The array consists of values in the form of 0xAARRGGBB.
 * <p>
 * Java declaration:
 * <pre>
 *     loadRGB(Ljavax/microedition/lcdui/ImageData;[I)V
 * </pre>
 *
 * @param rgbData The array of argb image data
 */
KNIEXPORT KNI_RETURNTYPE_VOID
KNIDECL(javax_microedition_lcdui_ImageDataFactory_loadRGB) {
    /* jboolean processAlpha = KNI_GetParameterAsBoolean(2); */
    int height;
    int width;
    int *rgbBuffer;
    gxj_screen_buffer sbuf;

    KNI_StartHandles(2);
    KNI_DeclareHandle(rgbData);
    KNI_DeclareHandle(imageData);

    KNI_GetParameterAsObject(2, rgbData);
    KNI_GetParameterAsObject(1, imageData);

    width  = (int)GXAPI_GET_IMAGEDATA_PTR(imageData)->width;
    height = (int)GXAPI_GET_IMAGEDATA_PTR(imageData)->height;

    rgbBuffer = JavaIntArray(rgbData);
    if (getImageScreenBuffer(imageData, &sbuf) != NULL) {
        int i;
        int len = KNI_GetArrayLength(rgbData);
        int data_length = width * height;

        if (len > data_length) {
            len = data_length;
        }

        /* if (len != width*height) {
         *    JAVA_TRACE("len mismatch  %d !=  %d\n", len, width*height);
         * }
		 */

        if (sbuf.alphaData != NULL) {
            for (i = 0; i < len; i++) {
                sbuf.pixelData[i] = GXJ_RGB24TOPIXEL(rgbBuffer[i]);
                sbuf.alphaData[i] = (rgbBuffer[i] >> 24) & 0x00ff;
            }
        } else {
            for (i = 0; i < len; i++) {
Beispiel #5
0
static void
surface_acquire(AbstractSurface* surface, jobject surfaceHandle) {
    KNI_StartHandles(1);
    KNI_DeclareHandle(dataHandle);

    KNI_GetObjectField(surfaceHandle, ((JavaSurface *) surface)->javaArrayFieldID, dataHandle);
    switch(((JavaSurface*)surface)->javaArrayFieldSize) {
        case sizeof(jint):
            surface->super.data = JavaIntArray(dataHandle)->elements;
            break;
        case sizeof(jshort):
            surface->super.data = JavaShortArray(dataHandle)->elements;
            break;
        case sizeof(jbyte):
            surface->super.data = JavaByteArray(dataHandle)->elements;
            break;
        default:
            //shouldn't happen        
            break;
    }
    KNI_EndHandles();
}
Beispiel #6
0
/**
 * Gets an ARGB integer array from this <tt>ImmutableImage</tt>. The
 * array consists of values in the form of 0xAARRGGBB.
 * <p>
 * Java declaration:
 * <pre>
 *     getRGB([IIIIIII)V
 * </pre>
 *
 * @param rgbData The target integer array for the ARGB data
 * @param offset Zero-based index of first ARGB pixel to be saved
 * @param scanlen Number of intervening pixels between pixels in
 *                the same column but in adjacent rows
 * @param x The x coordinate of the upper left corner of the
 *          selected region
 * @param y The y coordinate of the upper left corner of the
 *          selected region
 * @param width The width of the selected region
 * @param height The height of the selected region
 */
KNIEXPORT KNI_RETURNTYPE_VOID
KNIDECL(javax_microedition_lcdui_Image_getRGB) {
    int height = KNI_GetParameterAsInt(7);
    int width = KNI_GetParameterAsInt(6);
    int y = KNI_GetParameterAsInt(5);
    int x = KNI_GetParameterAsInt(4);
    int scanlength = KNI_GetParameterAsInt(3);
    int offset = KNI_GetParameterAsInt(2);
    int buflen;
    int *rgbBuffer;
    int img_width;
    int img_height;
    jboolean iae = KNI_FALSE;
    java_imagedata * srcImageDataPtr = NULL;

    KNI_StartHandles(2);
    KNI_DeclareHandle(rgbData);
    KNI_DeclareHandle(thisObject);

    KNI_GetParameterAsObject(1, rgbData);
    KNI_GetThisPointer(thisObject);

    srcImageDataPtr = GET_IMAGE_PTR(thisObject)->imageData;

    img_width  = srcImageDataPtr->width;
    img_height = srcImageDataPtr->height;

    /* see if absolute value of scanlength is greater than or equal to width */
    if (scanlength >= 0 && scanlength < width) {
        iae = KNI_TRUE;
    } else if (scanlength < 0 && (0 - scanlength) < width) {
        iae = KNI_TRUE;
    }
    if (KNI_IsNullHandle(rgbData)) {
        KNI_ThrowNew(midpNullPointerException, NULL);
    } else if((y < 0) || (x < 0) || (x + width > img_width) ||
              (y + height > img_height) || iae == KNI_TRUE) {
        KNI_ThrowNew(midpIllegalArgumentException, NULL);
    } else if (height < 0 || width < 0 ) {
        /* spec says noop in this case */
    } else {
        buflen = KNI_GetArrayLength(rgbData);
        if (offset < 0
            || offset + ((height - 1) * scanlength) + width > buflen
            || offset + ((height - 1) * scanlength) < 0) {
            KNI_ThrowNew(midpArrayIndexOutOfBoundsException, NULL);
        } else {
  	    gxutl_native_image_error_codes error = GXUTL_NATIVE_IMAGE_NO_ERROR;

	    SNI_BEGIN_RAW_POINTERS;

            rgbBuffer = JavaIntArray(rgbData);
	    gx_get_argb(srcImageDataPtr, rgbBuffer,
		       offset, scanlength,
		       x, y, width, height, &error);

	    SNI_END_RAW_POINTERS;

	    if (error != GXUTL_NATIVE_IMAGE_NO_ERROR) {
		KNI_ThrowNew(midpOutOfMemoryError, NULL);
	    }
        }
    }

    KNI_EndHandles();
    KNI_ReturnVoid();
}
/**
 * Populates a passed in immutable <tt>ImageData</tt>
 * from the given ARGB integer
 * array. The array consists of values in the form of 0xAARRGGBB.
 * <p>
 * Java declaration:
 * <pre>
 *     createImmutableImageDecodeRGBImage([Ljavax/microedition/lcdui/ImageData;III)V
 * </pre>
 *
 * @param imageData The <tt>ImadgeData</tt> to be populated
 * @param rgbData The array of argb image data
 * @param width The width of the new image
 * @param height The height of the new image
 * @param processAlpha If <tt>true</tt>, alpha channel bytes will
 *                     be used, otherwise, alpha channel bytes will
 *                     be ignored
 */
KNIEXPORT KNI_RETURNTYPE_VOID
Java_javax_microedition_lcdui_ImageDataFactory_createImmutableImageDecodeRGBImage() {
    jboolean processAlpha = KNI_GetParameterAsBoolean(5);
    int height = KNI_GetParameterAsInt(4);
    int width = KNI_GetParameterAsInt(3);
    jint *imageBuffer = NULL;
    int buflen;
    img_native_error_codes creationError = IMG_NATIVE_IMAGE_NO_ERROR;

    /* pointer to native image structure */
    gxpport_image_native_handle newImagePtr;

    KNI_StartHandles(2);
    KNI_DeclareHandle(rgbData);
    KNI_DeclareHandle(imageData);

    KNI_GetParameterAsObject(2, rgbData);
    KNI_GetParameterAsObject(1, imageData);

    do {
        if (KNI_IsNullHandle(rgbData)) {
            KNI_ThrowNew(midpNullPointerException, NULL);
            break;
        }

        if ((width <= 0) || (height <= 0)) {
            KNI_ThrowNew(midpIllegalArgumentException, NULL);
            break;
        }

        buflen = KNI_GetArrayLength(rgbData);
        if ((width * height) > buflen) {
            KNI_ThrowNew(midpArrayIndexOutOfBoundsException, NULL);
            break;
        }

        imageBuffer = JavaIntArray(rgbData);

	SNI_BEGIN_RAW_POINTERS;

        gxpport_decodeimmutable_from_argb(imageBuffer, width, height,
					  processAlpha,
					  &newImagePtr, &creationError);

	SNI_END_RAW_POINTERS;

        if (IMG_NATIVE_IMAGE_NO_ERROR == creationError) {
	    java_imagedata * dstImageDataPtr = IMGAPI_GET_IMAGEDATA_PTR(imageData);

            dstImageDataPtr->height = (jint)height;
            dstImageDataPtr->width = (jint)width;
            dstImageDataPtr->nativeImageData = (jint)newImagePtr;
            break;
        }

        if (IMG_NATIVE_IMAGE_OUT_OF_MEMORY_ERROR == creationError) {
            KNI_ThrowNew(midpOutOfMemoryError, NULL);
            break;
        }

        if (IMG_NATIVE_IMAGE_RESOURCE_LIMIT == creationError) {
            KNI_ThrowNew(midpOutOfMemoryError,
                         "Resource limit exceeded for immutable image");
            break;
        }

        KNI_ThrowNew(midpIllegalArgumentException, NULL);
    } while (0);

    KNI_EndHandles();
    KNI_ReturnVoid();
}