(@NotNull Image image)
| 50 | } |
| 51 | |
| 52 | @NotNull @Contract("-> new") |
| 53 | public static Bitmap makeFromImage(@NotNull Image image) { |
| 54 | assert image != null : "Can’t makeFromImage with image == null"; |
| 55 | Bitmap bitmap = new Bitmap(); |
| 56 | bitmap.allocPixels(image.getImageInfo()); |
| 57 | if (image.readPixels(bitmap)) |
| 58 | return bitmap; |
| 59 | else { |
| 60 | bitmap.close(); |
| 61 | throw new RuntimeException("Failed to readPixels from " + image); |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Swaps the fields of the two bitmaps. |
no test coverage detected