| 15 | case BitmapColorType.RGBA8888: |
| 16 | case BitmapColorType.BGRA8888: |
| 17 | return 4; |
| 18 | case BitmapColorType.Alpha8: |
| 19 | case BitmapColorType.Gray8: |
| 20 | return 1; |
| 21 | case BitmapColorType.RGBAF16: |
| 22 | return 8; // 4 channels * 2 bytes |
| 23 | case BitmapColorType.RGBAF32: |
| 24 | return 16; // 4 channels * 4 bytes |
| 25 | case BitmapColorType.UNKNOWN: |
| 26 | default: |
| 27 | return 4; |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | function ensureRowBytes(rowBytes: number, width: number, colorType: BitmapColorType): number { |
| 32 | if (rowBytes && rowBytes >= width * bytesPerPixel(colorType)) return rowBytes; |
| 33 | return width * bytesPerPixel(colorType); |
| 34 | } |
| 35 | |
| 36 | export function createNativeBitmap( |