Newer
Older
MiniTias / lib / services / raw_capture_service.dart
import 'package:flutter/services.dart';

/// Camera2 API を使用してフル解像度の YUV 画像をキャプチャするサービス.
class RawCaptureService {
  static const _channel = MethodChannel('com.example.mini_tias/raw_capture');

  /// フロントカメラからフル解像度の YUV データをキャプチャする.
  ///
  /// 返り値は YUV データを含む Map:
  /// - width, height: 画像サイズ
  /// - yPlane, uPlane, vPlane: YUV プレーンのバイトデータ
  /// - yRowStride, uvRowStride, uvPixelStride: ストライド情報
  Future<Map<String, dynamic>> captureFullResolutionYuv() async {
    final result = await _channel.invokeMethod('captureFullResolutionYuv');
    return Map<String, dynamic>.from(result as Map);
  }

  /// MediaStore にファイルを登録し,PC から MTP で見えるようにする.
  Future<void> scanFile(String path) async {
    await _channel.invokeMethod('scanFile', {'path': path});
  }
}