col method

List<num> col(
  1. int x
)

Implementation

List<num> col(int x) {
  final size = _height * _channels;
  final result = List<num>.filled(size, 0);
  final stride = _width * _channels;

  for (var y = 0; y < _height; y++) {
    for (var c = 0; c < _channels; c++) {
      final srcIdx = y * stride + x * _channels + c;
      final dstIdx = y * _channels + c;
      result[dstIdx] = switch (dtype) {
        StbiDType.u8 => ptr.cast<ffi.Uint8>()[srcIdx],
        StbiDType.u16 => ptr.cast<ffi.Uint16>()[srcIdx],
        StbiDType.f32 => ptr.cast<ffi.Float>()[srcIdx],
      };
    }
  }
  return result;
}