MCPcopy Create free account
hub / github.com/Snapchat/Valdi / bytesPerPixel

Function bytesPerPixel

src/valdi_modules/src/valdi/drawing/web/BitmapNative.ts:17–33  ·  view source on GitHub ↗
(ct: BitmapColorType)

Source from the content-addressed store, hash-verified

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
31function ensureRowBytes(rowBytes: number, width: number, colorType: BitmapColorType): number {
32 if (rowBytes && rowBytes >= width * bytesPerPixel(colorType)) return rowBytes;
33 return width * bytesPerPixel(colorType);
34}
35
36export function createNativeBitmap(

Callers 1

ensureRowBytesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected