loadFromFile method
- required String filePath,
- DicomConfig? config,
Loads a DICOM file from the local file system.
This triggers the heavy lifting in the Rust engine on a background thread. Once parsed, the raw pixel data is automatically converted into a GPU-ready texture.
filePath - Absolute path to the .dcm file.
config - Optional configuration to tune the Rust engine.
Implementation
Future<void> loadFromFile({
required final String filePath,
final DicomConfig? config,
}) async {
if (_isLoading) return;
if (_shader == null) await initialize();
_setLoading(true);
_clearError();
try {
// Use the service to load the frame
final result = await _service.loadFrame(filePath, config: config);
_currentFrame = result;
// Create GPU texture from raw pixel data
if (result.pixelData.isNotEmpty) {
_rawTexture = await _createTexture(
result.pixelData,
result.metadata.width,
result.metadata.height,
);
}
// Initialize interactive windowing values
_currentWindowCenter = result.metadata.windowCenter;
_currentWindowWidth = result.metadata.windowWidth;
} catch (e) {
_errorMessage = 'Failed to load DICOM: ${e.toString()}';
notifyListeners();
throw DicomProcessingException(_errorMessage!);
} finally {
_setLoading(false);
}
}