1 #include <com.badlogic.gdx.graphics.g2d.Gdx2DPixmap.h> 2 3 //@line:270 4 5 #include <gdx2d/gdx2d.h> 6 #include <stdlib.h> 7 JNIEXPORT jobject JNICALL Java_com_badlogic_gdx_graphics_g2d_Gdx2DPixmap_load(JNIEnv* env, jclass clazz, jlongArray nativeData, jbyteArray buffer, jint offset, jint len) { 8 9 //@line:275 10 11 const unsigned char* p_buffer = (const unsigned char*)env->GetPrimitiveArrayCritical(buffer, 0); 12 gdx2d_pixmap* pixmap = gdx2d_load(p_buffer + offset, len); 13 env->ReleasePrimitiveArrayCritical(buffer, (char*)p_buffer, 0); 14 15 if(pixmap==0) 16 return 0; 17 18 jobject pixel_buffer = env->NewDirectByteBuffer((void*)pixmap->pixels, pixmap->width * pixmap->height * gdx2d_bytes_per_pixel(pixmap->format)); 19 jlong* p_native_data = (jlong*)env->GetPrimitiveArrayCritical(nativeData, 0); 20 p_native_data[0] = (jlong)pixmap; 21 p_native_data[1] = pixmap->width; 22 p_native_data[2] = pixmap->height; 23 p_native_data[3] = pixmap->format; 24 env->ReleasePrimitiveArrayCritical(nativeData, p_native_data, 0); 25 26 return pixel_buffer; 27 28 } 29 30 JNIEXPORT jobject JNICALL Java_com_badlogic_gdx_graphics_g2d_Gdx2DPixmap_newPixmap(JNIEnv* env, jclass clazz, jlongArray nativeData, jint width, jint height, jint format) { 31 32 //@line:294 33 34 gdx2d_pixmap* pixmap = gdx2d_new(width, height, format); 35 if(pixmap==0) 36 return 0; 37 38 jobject pixel_buffer = env->NewDirectByteBuffer((void*)pixmap->pixels, pixmap->width * pixmap->height * gdx2d_bytes_per_pixel(pixmap->format)); 39 jlong* p_native_data = (jlong*)env->GetPrimitiveArrayCritical(nativeData, 0); 40 p_native_data[0] = (jlong)pixmap; 41 p_native_data[1] = pixmap->width; 42 p_native_data[2] = pixmap->height; 43 p_native_data[3] = pixmap->format; 44 env->ReleasePrimitiveArrayCritical(nativeData, p_native_data, 0); 45 46 return pixel_buffer; 47 48 } 49 50 JNIEXPORT void JNICALL Java_com_badlogic_gdx_graphics_g2d_Gdx2DPixmap_free(JNIEnv* env, jclass clazz, jlong pixmap) { 51 52 53 //@line:310 54 55 gdx2d_free((gdx2d_pixmap*)pixmap); 56 57 58 } 59 60 JNIEXPORT void JNICALL Java_com_badlogic_gdx_graphics_g2d_Gdx2DPixmap_clear(JNIEnv* env, jclass clazz, jlong pixmap, jint color) { 61 62 63 //@line:314 64 65 gdx2d_clear((gdx2d_pixmap*)pixmap, color); 66 67 68 } 69 70 JNIEXPORT void JNICALL Java_com_badlogic_gdx_graphics_g2d_Gdx2DPixmap_setPixel(JNIEnv* env, jclass clazz, jlong pixmap, jint x, jint y, jint color) { 71 72 73 //@line:318 74 75 gdx2d_set_pixel((gdx2d_pixmap*)pixmap, x, y, color); 76 77 78 } 79 80 JNIEXPORT jint JNICALL Java_com_badlogic_gdx_graphics_g2d_Gdx2DPixmap_getPixel(JNIEnv* env, jclass clazz, jlong pixmap, jint x, jint y) { 81 82 83 //@line:322 84 85 return gdx2d_get_pixel((gdx2d_pixmap*)pixmap, x, y); 86 87 88 } 89 90 JNIEXPORT void JNICALL Java_com_badlogic_gdx_graphics_g2d_Gdx2DPixmap_drawLine(JNIEnv* env, jclass clazz, jlong pixmap, jint x, jint y, jint x2, jint y2, jint color) { 91 92 93 //@line:326 94 95 gdx2d_draw_line((gdx2d_pixmap*)pixmap, x, y, x2, y2, color); 96 97 98 } 99 100 JNIEXPORT void JNICALL Java_com_badlogic_gdx_graphics_g2d_Gdx2DPixmap_drawRect(JNIEnv* env, jclass clazz, jlong pixmap, jint x, jint y, jint width, jint height, jint color) { 101 102 103 //@line:330 104 105 gdx2d_draw_rect((gdx2d_pixmap*)pixmap, x, y, width, height, color); 106 107 108 } 109 110 JNIEXPORT void JNICALL Java_com_badlogic_gdx_graphics_g2d_Gdx2DPixmap_drawCircle(JNIEnv* env, jclass clazz, jlong pixmap, jint x, jint y, jint radius, jint color) { 111 112 113 //@line:334 114 115 gdx2d_draw_circle((gdx2d_pixmap*)pixmap, x, y, radius, color); 116 117 118 } 119 120 JNIEXPORT void JNICALL Java_com_badlogic_gdx_graphics_g2d_Gdx2DPixmap_fillRect(JNIEnv* env, jclass clazz, jlong pixmap, jint x, jint y, jint width, jint height, jint color) { 121 122 123 //@line:338 124 125 gdx2d_fill_rect((gdx2d_pixmap*)pixmap, x, y, width, height, color); 126 127 128 } 129 130 JNIEXPORT void JNICALL Java_com_badlogic_gdx_graphics_g2d_Gdx2DPixmap_fillCircle(JNIEnv* env, jclass clazz, jlong pixmap, jint x, jint y, jint radius, jint color) { 131 132 133 //@line:342 134 135 gdx2d_fill_circle((gdx2d_pixmap*)pixmap, x, y, radius, color); 136 137 138 } 139 140 JNIEXPORT void JNICALL Java_com_badlogic_gdx_graphics_g2d_Gdx2DPixmap_fillTriangle(JNIEnv* env, jclass clazz, jlong pixmap, jint x1, jint y1, jint x2, jint y2, jint x3, jint y3, jint color) { 141 142 143 //@line:346 144 145 gdx2d_fill_triangle((gdx2d_pixmap*)pixmap, x1, y1, x2, y2, x3, y3, color); 146 147 148 } 149 150 JNIEXPORT void JNICALL Java_com_badlogic_gdx_graphics_g2d_Gdx2DPixmap_drawPixmap(JNIEnv* env, jclass clazz, jlong src, jlong dst, jint srcX, jint srcY, jint srcWidth, jint srcHeight, jint dstX, jint dstY, jint dstWidth, jint dstHeight) { 151 152 153 //@line:351 154 155 gdx2d_draw_pixmap((gdx2d_pixmap*)src, (gdx2d_pixmap*)dst, srcX, srcY, srcWidth, srcHeight, dstX, dstY, dstWidth, dstHeight); 156 157 158 } 159 160 JNIEXPORT void JNICALL Java_com_badlogic_gdx_graphics_g2d_Gdx2DPixmap_setBlend(JNIEnv* env, jclass clazz, jint blend) { 161 162 163 //@line:355 164 165 gdx2d_set_blend(blend); 166 167 168 } 169 170 JNIEXPORT void JNICALL Java_com_badlogic_gdx_graphics_g2d_Gdx2DPixmap_setScale(JNIEnv* env, jclass clazz, jint scale) { 171 172 173 //@line:359 174 175 gdx2d_set_scale(scale); 176 177 178 } 179 180 JNIEXPORT jstring JNICALL Java_com_badlogic_gdx_graphics_g2d_Gdx2DPixmap_getFailureReason(JNIEnv* env, jclass clazz) { 181 182 183 //@line:363 184 185 return env->NewStringUTF(gdx2d_get_failure_reason()); 186 187 188 } 189 190