| 453 | } |
| 454 | |
| 455 | QJniObject IconManager::makeAndroidBitmap(const QImage &img) |
| 456 | { |
| 457 | auto size = img.size(); |
| 458 | if (size.width() < 1 || size.height() < 1) { |
| 459 | return QJniObject(); |
| 460 | } |
| 461 | auto image = img.format() == QImage::Format_RGBA8888 ? img : img.convertToFormat(QImage::Format_RGBA8888); |
| 462 | auto bitmap = createBitmap(size); |
| 463 | auto env = QJniEnvironment(); |
| 464 | auto jniEnv = env.jniEnv(); |
| 465 | auto info = AndroidBitmapInfo(); |
| 466 | if (AndroidBitmap_getInfo(jniEnv, bitmap.object(), &info) != ANDROID_BITMAP_RESULT_SUCCESS || info.format != ANDROID_BITMAP_FORMAT_RGBA_8888) { |
| 467 | return QJniObject(); |
| 468 | } |
| 469 | void *pixels; |
| 470 | if (AndroidBitmap_lockPixels(jniEnv, bitmap.object(), &pixels) != ANDROID_BITMAP_RESULT_SUCCESS) { |
| 471 | return QJniObject(); |
| 472 | } |
| 473 | if (info.stride == static_cast<std::uint32_t>(image.bytesPerLine())) { |
| 474 | std::memcpy(pixels, image.constBits(), info.stride * info.height); |
| 475 | } else { |
| 476 | auto *bmpPtr = static_cast<uchar *>(pixels); |
| 477 | const auto width = std::min(info.width, static_cast<uint>(image.width())); |
| 478 | const auto height = std::min(info.height, static_cast<uint>(image.height())); |
| 479 | for (unsigned y = 0; y < height; y++, bmpPtr += info.stride) { |
| 480 | std::memcpy(bmpPtr, image.constScanLine(y), width); |
| 481 | } |
| 482 | } |
| 483 | if (AndroidBitmap_unlockPixels(jniEnv, bitmap.object()) != ANDROID_BITMAP_RESULT_SUCCESS) { |
| 484 | return QJniObject(); |
| 485 | } |
| 486 | return bitmap; |
| 487 | } |
| 488 | #endif |
| 489 | |
| 490 | QString aboutDialogAttribution() |
nothing calls this directly
no test coverage detected