@@ -13,14 +13,14 @@ internal class StandardImageWriter : ImageWriterBase
1313{
1414 private readonly ImageType imageType ;
1515
16- public int DepthSlice { get ; set ; }
16+ public int ? SliceX { get ; set ; }
17+ public int ? SliceY { get ; set ; }
18+ public int ? SliceZ { get ; set ; }
1719
1820
1921 public StandardImageWriter ( Stream stream , ImageType imageType ) : base ( stream )
2022 {
2123 this . imageType = imageType ;
22-
23- DepthSlice = 0 ;
2424 }
2525
2626 public override async Task ProcessAsync ( string luaScript , CancellationToken token = default )
@@ -47,12 +47,29 @@ public override async Task ProcessAsync(string luaScript, CancellationToken toke
4747 processor . Initialize ( ) ;
4848
4949 for ( var x = 0 ; x < ImageWidth ; x ++ ) {
50- var pixel = ImageDimensions switch {
51- 3 => processor . ProcessPixel ( point . X + x , point . Y , DepthSlice ) ,
52- 2 => processor . ProcessPixel ( point . X + x , point . Y ) ,
53- 1 => processor . ProcessPixel ( point . X + x ) ,
54- _ => throw new ApplicationException ( $ "Unsupported dimension count '{ ImageDimensions } '!") ,
55- } ;
50+ object [ ] pixel ;
51+
52+ switch ( ImageDimensions ) {
53+ case 3 :
54+ if ( SliceX . HasValue ) {
55+ pixel = processor . ProcessPixel ( SliceX . Value , point . X + x , point . Y ) ;
56+ }
57+ else if ( SliceY . HasValue ) {
58+ pixel = processor . ProcessPixel ( point . X + x , SliceY . Value , point . Y ) ;
59+ }
60+ else {
61+ pixel = processor . ProcessPixel ( point . X + x , point . Y , SliceZ ?? 0 ) ;
62+ }
63+ break ;
64+ case 2 :
65+ pixel = processor . ProcessPixel ( point . X + x , point . Y ) ;
66+ break ;
67+ case 1 :
68+ pixel = processor . ProcessPixel ( point . X + x ) ;
69+ break ;
70+ default :
71+ throw new ApplicationException ( $ "Unsupported dimension count '{ ImageDimensions } '!") ;
72+ }
5673
5774 if ( PixelFormat is PixelFormat . R_NORM or PixelFormat . R_INT ) {
5875 var value = Convert . ToSingle ( ( double ) pixel [ 0 ] ) ;
0 commit comments