905 |
905 |
906 // |
906 // |
907 // Image class JNI calls |
907 // Image class JNI calls |
908 // |
908 // |
909 |
909 |
910 jint JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_image_1create__III |
910 jint JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_image_1create__IIII |
911 (JNIEnv* aJniEnv , jclass, jint aWidth , jint aHeight, jint aFillColor) |
911 (JNIEnv* aJniEnv , jclass, jint aWidth , jint aHeight, jint aFillColor, jint aType) |
912 { |
912 { |
913 Image* img = NULL; |
913 Image* img = NULL; |
914 GFX_TRY |
914 GFX_TRY |
915 { |
915 { |
916 SWT_LOG_JNI_CALL(); |
916 SWT_LOG_JNI_CALL(); |
917 img = GraphicsFactory::createImage(aWidth, aHeight, aFillColor); |
917 img = GraphicsFactory::createImage(aWidth, aHeight, aFillColor, (TImageType)aType); |
918 } |
918 } |
919 GFX_CATCH |
919 GFX_CATCH |
920 return POINTER_TO_HANDLE(img); |
920 return POINTER_TO_HANDLE(img); |
921 } |
921 } |
922 |
922 |
932 } |
932 } |
933 GFX_CATCH |
933 GFX_CATCH |
934 return POINTER_TO_HANDLE(newImage); |
934 return POINTER_TO_HANDLE(newImage); |
935 } |
935 } |
936 |
936 |
937 jint JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_image_1create___3IIIZ |
937 JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_image_1create__IIIIII |
938 (JNIEnv* aJniEnv, jclass, jintArray aRgbData, jint aWidth, jint aHeight, jboolean aHasAlpha) |
938 (JNIEnv* aJniEnv, jclass, jint aImageHandle, jint aX, jint aY, jint aWidth, jint aHeight, jint aTypeOfCopy) |
|
939 { |
|
940 Image* newImage = NULL; |
|
941 GFX_TRY |
|
942 { |
|
943 SWT_LOG_JNI_CALL(); |
|
944 HANDLE_TO_POINTER(Image*, image, aImageHandle); |
|
945 newImage = GraphicsFactory::createImage(image, aX, aY, aWidth, aHeight, (TImageType)aTypeOfCopy); |
|
946 } |
|
947 GFX_CATCH |
|
948 return POINTER_TO_HANDLE(newImage); |
|
949 } |
|
950 |
|
951 jint JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_image_1create___3IIIZI |
|
952 (JNIEnv* aJniEnv, jclass, jintArray aRgbData, jint aWidth, jint aHeight, jboolean aHasAlpha, jint aType) |
939 { |
953 { |
940 Image* img = NULL; |
954 Image* img = NULL; |
941 GFX_TRY |
955 GFX_TRY |
942 { |
956 { |
943 SWT_LOG_JNI_CALL(); |
957 SWT_LOG_JNI_CALL(); |
944 |
|
945 int length = aJniEnv->GetArrayLength(aRgbData); |
958 int length = aJniEnv->GetArrayLength(aRgbData); |
946 |
|
947 int* buffer = new int[length]; // might throw bad_alloc |
959 int* buffer = new int[length]; // might throw bad_alloc |
948 AutoRelease<int> release(buffer, true); |
960 AutoRelease<int> release(buffer, true); |
949 swtApp->jniUtils().GetJavaIntArrayRegionToIntArray(aJniEnv, aRgbData, 0, length, buffer); // might throw bad_alloc |
961 swtApp->jniUtils().GetJavaIntArrayRegionToIntArray(aJniEnv, aRgbData, 0, length, buffer); // might throw bad_alloc |
950 |
962 img = GraphicsFactory::createImage(buffer, aWidth, aHeight, aHasAlpha, (TImageType)aType); |
951 img = GraphicsFactory::createImage(buffer, aWidth, aHeight, aHasAlpha); |
|
952 } |
963 } |
953 GFX_CATCH |
964 GFX_CATCH |
954 return POINTER_TO_HANDLE(img); |
965 return POINTER_TO_HANDLE(img); |
955 } |
966 } |
956 |
967 |
957 jint JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_image_1create__Lorg_eclipse_swt_graphics_ImageData_2 |
968 jint JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_image_1create__Lorg_eclipse_swt_graphics_ImageData_2I |
958 (JNIEnv* aJniEnv , jclass, jobject aImageData) |
969 (JNIEnv* aJniEnv , jclass, jobject aImageData, jint aType) |
959 { |
970 { |
960 Image* img = NULL; |
971 Image* img = NULL; |
961 GFX_TRY |
972 GFX_TRY |
962 { |
973 { |
963 SWT_LOG_JNI_CALL(); |
974 SWT_LOG_JNI_CALL(); |
964 img = swtApp->jniUtils().CreateImage(aJniEnv, aImageData); |
975 img = swtApp->jniUtils().CreateImage(aJniEnv, aImageData, aType); |
965 } |
976 } |
966 GFX_CATCH |
977 GFX_CATCH |
967 return POINTER_TO_HANDLE(img); |
978 return POINTER_TO_HANDLE(img); |
968 } |
979 } |
969 |
980 |
1006 HANDLE_TO_POINTER(Image*, image, aImageHandle); |
1017 HANDLE_TO_POINTER(Image*, image, aImageHandle); |
1007 height = static_cast<jint>( image->getHeight() ); |
1018 height = static_cast<jint>( image->getHeight() ); |
1008 } |
1019 } |
1009 GFX_CATCH |
1020 GFX_CATCH |
1010 return height; |
1021 return height; |
|
1022 } |
|
1023 |
|
1024 jint JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_image_1getQPaintDeviceHandle |
|
1025 (JNIEnv* aJniEnv, jclass, jint aImageHandle) |
|
1026 { |
|
1027 QPaintDevice* device = NULL; |
|
1028 GFX_TRY |
|
1029 { |
|
1030 SWT_LOG_JNI_CALL(); |
|
1031 HANDLE_TO_POINTER(Image*, image, aImageHandle); |
|
1032 device = image->getBindable(); |
|
1033 } |
|
1034 GFX_CATCH |
|
1035 return POINTER_TO_HANDLE(device); |
|
1036 } |
|
1037 |
|
1038 JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_image_1getType |
|
1039 (JNIEnv* aJniEnv, jclass, jint aImageHandle) |
|
1040 { |
|
1041 jint type = ENone; |
|
1042 GFX_TRY |
|
1043 { |
|
1044 SWT_LOG_JNI_CALL(); |
|
1045 HANDLE_TO_POINTER(Image*, image, aImageHandle); |
|
1046 type = static_cast<jint>( image->type() ); |
|
1047 } |
|
1048 GFX_CATCH |
|
1049 return type; |
1011 } |
1050 } |
1012 |
1051 |
1013 jint JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_image_1getWidth |
1052 jint JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_image_1getWidth |
1014 (JNIEnv* aJniEnv , jclass, jint aImageHandle) |
1053 (JNIEnv* aJniEnv , jclass, jint aImageHandle) |
1015 { |
1054 { |
1035 int length = aJniEnv->GetArrayLength(aRgbData); |
1074 int length = aJniEnv->GetArrayLength(aRgbData); |
1036 |
1075 |
1037 int* buffer = new int[length]; // might throw bad_alloc |
1076 int* buffer = new int[length]; // might throw bad_alloc |
1038 AutoRelease<int> release(buffer, true); |
1077 AutoRelease<int> release(buffer, true); |
1039 ::memset(buffer, 0, sizeof(int)*length); |
1078 ::memset(buffer, 0, sizeof(int)*length); |
|
1079 swtApp->jniUtils().GetJavaIntArrayRegionToIntArray(aJniEnv, aRgbData, 0, length, buffer); |
1040 |
1080 |
1041 // get the data (populated to data array) |
1081 // get the data (populated to data array) |
1042 image->getRgb(buffer, aOffset, aScanlength, aX, aY, aWidth, aHeight); |
1082 image->getRgb(buffer, aOffset, aScanlength, aX, aY, aWidth, aHeight); |
1043 |
1083 |
1044 // Copy data back to java |
1084 // Copy data back to java |
1136 image = NULL; |
1176 image = NULL; |
1137 } |
1177 } |
1138 GFX_CATCH |
1178 GFX_CATCH |
1139 } |
1179 } |
1140 |
1180 |
1141 jint JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_image_1getPixmapHandle |
|
1142 (JNIEnv* aJniEnv , jclass, jint aImageHandle) |
|
1143 { |
|
1144 jint pixmapHandle = 0; |
|
1145 GFX_TRY |
|
1146 { |
|
1147 SWT_LOG_JNI_CALL(); |
|
1148 HANDLE_TO_POINTER(Image*, image, aImageHandle); |
|
1149 pixmapHandle = POINTER_TO_HANDLE(image->getPixmap()); |
|
1150 } |
|
1151 GFX_CATCH |
|
1152 return pixmapHandle; |
|
1153 } |
|
1154 |
|
1155 jboolean JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_image_1detectCollision |
1181 jboolean JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_image_1detectCollision |
1156 (JNIEnv* aJniEnv, jclass, jint aImage1PixmapHandle, jint aTransform1, jint aP1x, jint aP1y, jint aR1x1, jint aR1y1, jint aR1x2, jint aR1y2, |
1182 (JNIEnv* aJniEnv, jclass, jint aImage1Handle, jint aTransform1, jint aP1x, jint aP1y, jint aR1x1, jint aR1y1, jint aR1x2, jint aR1y2, |
1157 jint aImage2PixmapHandle, jint aTransform2, jint aP2x, jint aP2y, jint aR2x1, jint aR2y1, jint aR2x2, jint aR2y2) |
1183 jint aImage2Handle, jint aTransform2, jint aP2x, jint aP2y, jint aR2x1, jint aR2y1, jint aR2x2, jint aR2y2) |
1158 { |
1184 { |
1159 jboolean collides = JNI_FALSE; |
1185 jboolean collides = JNI_FALSE; |
1160 GFX_TRY |
1186 GFX_TRY |
1161 { |
1187 { |
1162 SWT_LOG_JNI_CALL(); |
1188 SWT_LOG_JNI_CALL(); |
1163 collides = gfxUtils::detectCollision(aImage1PixmapHandle, aTransform1, aP1x, aP1y, aR1x1, aR1y1, aR1x2, aR1y2, |
1189 HANDLE_TO_POINTER(Image*, image1, aImage1Handle); |
1164 aImage2PixmapHandle, aTransform2, aP2x, aP2y, aR2x1, aR2y1, aR2x2, aR2y2); |
1190 HANDLE_TO_POINTER(Image*, image2, aImage2Handle); |
|
1191 collides = gfxUtils::detectCollision(image1, aTransform1, aP1x, aP1y, aR1x1, aR1y1, aR1x2, aR1y2, |
|
1192 image2, aTransform2, aP2x, aP2y, aR2x1, aR2y1, aR2x2, aR2y2); |
1165 } |
1193 } |
1166 GFX_CATCH |
1194 GFX_CATCH |
1167 return collides; |
1195 return collides; |
1168 } |
1196 } |
1169 |
1197 |
1212 GFX_CATCH |
1240 GFX_CATCH |
1213 return POINTER_TO_HANDLE(image); |
1241 return POINTER_TO_HANDLE(image); |
1214 } |
1242 } |
1215 |
1243 |
1216 jint JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_imageLoader_1init |
1244 jint JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_imageLoader_1init |
1217 (JNIEnv* aJniEnv , jclass) |
1245 (JNIEnv* aJniEnv , jclass, jint aType) |
1218 { |
1246 { |
1219 ImageLoader* loader = NULL; |
1247 ImageLoader* loader = NULL; |
1220 GFX_TRY |
1248 GFX_TRY |
1221 { |
1249 { |
1222 SWT_LOG_JNI_CALL(); |
1250 SWT_LOG_JNI_CALL(); |
1223 loader = GraphicsFactory::createImageLoader(); |
1251 loader = GraphicsFactory::createImageLoader((TImageType)aType); |
1224 } |
1252 } |
1225 GFX_CATCH |
1253 GFX_CATCH |
1226 return POINTER_TO_HANDLE(loader); |
1254 return POINTER_TO_HANDLE(loader); |
1227 } |
1255 } |
1228 |
1256 |
1260 SWT_LOG_JNI_CALL(); |
1288 SWT_LOG_JNI_CALL(); |
1261 HANDLE_TO_POINTER(ImageLoader*, loader, aHandle); |
1289 HANDLE_TO_POINTER(ImageLoader*, loader, aHandle); |
1262 loader->setLoadSize(aWidth, aHeight); |
1290 loader->setLoadSize(aWidth, aHeight); |
1263 } |
1291 } |
1264 GFX_CATCH |
1292 GFX_CATCH |
|
1293 } |
|
1294 |
|
1295 JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_imageloader_1setResultImageType |
|
1296 (JNIEnv* aJniEnv, jclass, jint aHandle, jint aType) |
|
1297 { |
|
1298 GFX_TRY |
|
1299 { |
|
1300 SWT_LOG_JNI_CALL(); |
|
1301 HANDLE_TO_POINTER(ImageLoader*, loader, aHandle); |
|
1302 loader->setResultImageType((TImageType)aType); |
|
1303 } |
|
1304 GFX_CATCH |
1265 } |
1305 } |
1266 |
1306 |
1267 JNIEXPORT jobject JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_imageLoader_1getImageSize |
1307 JNIEXPORT jobject JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_imageLoader_1getImageSize |
1268 (JNIEnv *aJniEnv, jclass, jbyteArray aData) |
1308 (JNIEnv *aJniEnv, jclass, jbyteArray aData) |
1269 { |
1309 { |