[cairo-commit] cairo-java/src/jni org_freedesktop_cairo_ImageSurface.c, 1.1, 1.2 org_freedesktop_cairo_Cairo.c, 1.14, 1.15

Jeffrey Morgan commit at pdx.freedesktop.org
Mon Apr 4 17:37:01 PDT 2005


Committed by: kuzman

Update of /cvs/cairo/cairo-java/src/jni
In directory gabe:/tmp/cvs-serv30279/src/jni

Modified Files:
	org_freedesktop_cairo_ImageSurface.c 
	org_freedesktop_cairo_Cairo.c 
Log Message:
fixed bug in ImageSurface and changed image data from byte[] to char[]

Index: org_freedesktop_cairo_ImageSurface.c
===================================================================
RCS file: /cvs/cairo/cairo-java/src/jni/org_freedesktop_cairo_ImageSurface.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- org_freedesktop_cairo_ImageSurface.c	23 Feb 2005 18:17:52 -0000	1.1
+++ org_freedesktop_cairo_ImageSurface.c	5 Apr 2005 00:36:59 -0000	1.2
@@ -25,22 +25,27 @@
 JNIEXPORT jobject JNICALL Java_org_freedesktop_cairo_ImageSurface_cairo_1image_1surface_1create
   (JNIEnv *env, jclass cls, jint format, jint width, jint height)
 {
-	return getHandleFromPointer(env, cairo_image_surface_create((cairo_format_t)format, width, height));
+	cairo_surface_t *surface = cairo_image_surface_create(
+			(cairo_format_t)format, width, height);
+	return getHandleFromPointer(env, surface);
 }
 
 /*
  * Class:     org_freedesktop_cairo_ImageSurface
  * Method:    cairo_image_surface_create_for_data
- * Signature: (Ljava/lang/String;IIII)Lorg/gnu/glib/Handle;
+ * Signature: ([CIIII)Lorg/gnu/glib/Handle;
  */
 JNIEXPORT jobject JNICALL Java_org_freedesktop_cairo_ImageSurface_cairo_1image_1surface_1create_1for_1data
-  (JNIEnv *env, jclass cls, jstring data, jint format, jint width, jint height, jint stride)
+  (JNIEnv *env, jclass cls, jcharArray data, jint format, jint width, jint height, jint stride)
 {
-	char* data_g = (char*)(*env)->GetStringUTFChars(env, data, NULL);
-	jobject hndl = getHandleFromPointer(env, cairo_image_surface_create_for_data(data_g,
-			(cairo_format_t)format, width, height, stride));
-	(*env)->ReleaseStringUTFChars(env, data, data_g);
-	return hndl;
+	unsigned char* data_g;
+	cairo_surface_t *surface;
+	
+	data_g = (unsigned char*)(*env)->GetCharArrayElements(env, data, NULL);
+	surface = cairo_image_surface_create_for_data(data_g,
+			(cairo_format_t)format, width, height, stride);
+	(*env)->ReleaseCharArrayElements(env, data, (jchar*)data_g, 0);
+	return getHandleFromPointer(env, surface);
 }
 
 #ifdef __cplusplus

Index: org_freedesktop_cairo_Cairo.c
===================================================================
RCS file: /cvs/cairo/cairo-java/src/jni/org_freedesktop_cairo_Cairo.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- org_freedesktop_cairo_Cairo.c	2 Apr 2005 13:46:40 -0000	1.14
+++ org_freedesktop_cairo_Cairo.c	5 Apr 2005 00:36:59 -0000	1.15
@@ -1304,15 +1304,18 @@
 /*
  * Class:     org_freedesktop_cairo_Cairo
  * Method:    cairo_set_target_image
- * Signature: (Lorg/gnu/glib/Handle;[BIIII)V
+ * Signature: (Lorg/gnu/glib/Handle;[cIIII)V
  */
 JNIEXPORT void JNICALL Java_org_freedesktop_cairo_Cairo_cairo_1set_1target_1image
-  (JNIEnv *env, jclass cls, jobject obj, jbyteArray data, jint format, jint width, jint height, jint stride)
+  (JNIEnv *env, jclass cls, jobject obj, jcharArray data, jint format, jint width, jint height, jint stride)
 {
-	cairo_t *cr = (cairo_t*)getPointerFromHandle(env, obj);
-	char* data_g = (char*)(*env)->GetByteArrayElements(env, data, NULL);
+	cairo_t *cr;
+	unsigned char* data_g;
+
+	cr = (cairo_t*)getPointerFromHandle(env, obj);
+	data_g = (unsigned char*)(*env)->GetCharArrayElements(env, data, NULL);
 	cairo_set_target_image(cr, data_g, (cairo_format_t)format, width, height, stride);
-	(*env)->ReleaseByteArrayElements(env, data, (jbyte*)data_g, 0);
+	(*env)->ReleaseCharArrayElements(env, data, (jchar*)data_g, 0);
 }
 
 /*




More information about the cairo-commit mailing list