pixel method

List<num> pixel(
  1. int x,
  2. int y
)

Implementation

List<num> pixel(int x, int y) {
  final stride = _width * _channels;
  final offset = y * stride + x * _channels;
  return switch (dtype) {
    StbiDType.u8 => (ptr.cast<ffi.Uint8>() + offset).asTypedList(_channels),
    StbiDType.u16 => (ptr.cast<ffi.Uint16>() + offset).asTypedList(_channels),
    StbiDType.f32 => (ptr.cast<ffi.Float>() + offset).asTypedList(_channels),
  };
}