using System.Threading.Tasks;
using XP.Hardware.Detector.Abstractions;

namespace XP.Hardware.Detector.Services
{
    /// <summary>
    /// 图像服务接口 | Image service interface
    /// 提供图像获取和 16 位 TIFF 保存功能，适用于连续采集和单帧采集
    /// </summary>
    public interface IImageService
    {
        /// <summary>
        /// 获取最新采集的原始 16 位图像数据 | Get latest captured raw 16-bit image data
        /// 返回 null 表示尚无图像 | Returns null if no image available
        /// </summary>
        ImageCapturedEventArgs LatestFrame { get; }

        /// <summary>
        /// 保存 16 位灰度图像为 TIFF 文件 | Save 16-bit grayscale image as TIFF file
        /// </summary>
        Task<DetectorResult> SaveAsTiffAsync(ushort[] imageData, int width, int height, string filePath);

        /// <summary>
        /// 保存 16 位灰度图像为 TIFF 文件，自动生成文件名 | Save with auto-generated filename
        /// </summary>
        Task<DetectorResult> SaveAsTiffAsync(ushort[] imageData, int width, int height, string saveDirectory, string prefix, int frameNumber);

        /// <summary>
        /// 保存最新帧为 16 位 TIFF（便捷方法）| Save latest frame as 16-bit TIFF (convenience method)
        /// </summary>
        /// <param name="saveDirectory">保存目录 | Save directory</param>
        /// <param name="prefix">文件名前缀 | Filename prefix</param>
        /// <returns>操作结果，无可用帧时返回失败 | Operation result, failure if no frame available</returns>
        Task<DetectorResult> SaveLatestFrameAsync(string saveDirectory, string prefix);

        /// <summary>
        /// 获取配置的默认保存目录 | Get configured default save directory
        /// </summary>
        string GetDefaultSaveDirectory();
    }
}
