Creates Image from bitmap, sharing or copying bitmap pixels. If the bitmap is marked immutable, and its pixel memory is shareable, it may be shared instead of copied. Image is returned if bitmap is valid. Valid Bitmap parameters include: dimensions are greater than zero;
(@NotNull Bitmap bitmap)
| 194 | * @see <a href="https://fiddle.skia.org/c/@Image_MakeFromBitmap">https://fiddle.skia.org/c/@Image_MakeFromBitmap</a> |
| 195 | */ |
| 196 | @NotNull @Contract("_ -> new") |
| 197 | public static Image makeRasterFromBitmap(@NotNull Bitmap bitmap) { |
| 198 | try { |
| 199 | assert bitmap != null : "Can’t makeFromBitmap with bitmap == null"; |
| 200 | Stats.onNativeCall(); |
| 201 | long ptr = _nMakeRasterFromBitmap(Native.getPtr(bitmap)); |
| 202 | if (ptr == 0) |
| 203 | throw new RuntimeException("Failed to Image::makeFromBitmap " + bitmap); |
| 204 | return new Image(ptr); |
| 205 | } finally { |
| 206 | ReferenceUtil.reachabilityFence(bitmap); |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | /** |
| 211 | * @deprecated - use {@link #makeRasterFromPixmap(Pixmap)} |