Creates Image from pixels. Image is returned if pixels are valid. Valid Pixmap parameters include: dimensions are greater than zero; each dimension fits in 29 bits; ColorType and AlphaType are valid, and ColorType is not ColorType.UNKNOWN; row bytes
(ImageInfo imageInfo, byte[] bytes, long rowBytes)
| 105 | * @see <a href="https://fiddle.skia.org/c/@Image_MakeRasterCopy">https://fiddle.skia.org/c/@Image_MakeRasterCopy</a> |
| 106 | */ |
| 107 | public static Image makeRasterFromBytes(ImageInfo imageInfo, byte[] bytes, long rowBytes) { |
| 108 | try { |
| 109 | Stats.onNativeCall(); |
| 110 | long ptr = _nMakeRasterFromBytes(imageInfo._width, |
| 111 | imageInfo._height, |
| 112 | imageInfo._colorInfo._colorType.ordinal(), |
| 113 | imageInfo._colorInfo._alphaType.ordinal(), |
| 114 | Native.getPtr(imageInfo._colorInfo._colorSpace), |
| 115 | bytes, |
| 116 | rowBytes); |
| 117 | if (ptr == 0) |
| 118 | throw new RuntimeException("Failed to makeRaster " + imageInfo + " " + bytes + " " + rowBytes); |
| 119 | return new Image(ptr); |
| 120 | } finally { |
| 121 | ReferenceUtil.reachabilityFence(imageInfo._colorInfo._colorSpace); |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | /** |
| 126 | * @deprecated - use {@link #makeRasterFromData(ImageInfo, Data, long)} |
no test coverage detected