@@ -588,11 +588,16 @@ public IDisposable StartRendering(Action onCompleted, Action<Exception> onError
588588 Connect ( Source , dest , FrameFormat . Gray8 , FrameFormat . Rgb565 ) ;
589589 continue ;
590590 }
591- // gray4 -> rgb24
591+ // gray8 -> rgb24
592592 if ( sourceGray8 != null && destRgb24 != null ) {
593593 Connect ( Source , dest , FrameFormat . Gray8 , FrameFormat . Rgb24 ) ;
594594 continue ;
595595 }
596+ // gray8 -> bitmap
597+ if ( sourceGray8 != null && destBitmap != null ) {
598+ Connect ( Source , dest , FrameFormat . Gray8 , FrameFormat . Bitmap ) ;
599+ continue ;
600+ }
596601 // rgb565 -> rgb24
597602 if ( sourceRgb565 != null && destRgb24 != null ) {
598603 Connect ( Source , dest , FrameFormat . Rgb565 , FrameFormat . Rgb24 ) ;
@@ -650,6 +655,16 @@ public IDisposable StartRendering(Action onCompleted, Action<Exception> onError
650655 Connect ( Source , dest , FrameFormat . Gray4 , FrameFormat . Gray2 ) ;
651656 continue ;
652657 }
658+ // gray8 -> gray4
659+ if ( sourceGray8 != null && destGray4 != null ) {
660+ Connect ( Source , dest , FrameFormat . Gray8 , FrameFormat . Gray4 ) ;
661+ continue ;
662+ }
663+ // gray8 -> gray2
664+ if ( sourceGray8 != null && destGray2 != null ) {
665+ Connect ( Source , dest , FrameFormat . Gray8 , FrameFormat . Gray2 ) ;
666+ continue ;
667+ }
653668 // colored gray6 -> rgb565
654669 if ( sourceColoredGray6 != null && destRgb565 != null ) {
655670 Connect ( Source , dest , FrameFormat . ColoredGray6 , FrameFormat . Rgb565 ) ;
@@ -960,6 +975,30 @@ private void Connect(ISource source, IDestination dest, FrameFormat from, FrameF
960975 var sourceGray8 = source as IGray8Source ;
961976 switch ( to ) {
962977
978+ // gray8 -> gray4
979+ case FrameFormat . Gray4 :
980+ AssertCompatibility ( source , sourceGray8 , dest , destGray4 , from , to ) ;
981+ Subscribe (
982+ sourceGray8 . GetGray8Frames ( ! dest . NeedsDuplicateFrames ) ,
983+ frame => frame
984+ . TransformHdScaling ( destFixedSize , ScalerMode )
985+ . ConvertToGray4 ( )
986+ . TransformGray ( this , destFixedSize , destMultiSize ) ,
987+ destGray4 . RenderGray4 ) ;
988+ break ;
989+
990+ // gray8 -> gray2
991+ case FrameFormat . Gray2 :
992+ AssertCompatibility ( source , sourceGray8 , dest , destGray2 , from , to ) ;
993+ Subscribe (
994+ sourceGray8 . GetGray8Frames ( ! dest . NeedsDuplicateFrames ) ,
995+ frame => frame
996+ . TransformHdScaling ( destFixedSize , ScalerMode )
997+ . ConvertToGray2 ( )
998+ . TransformGray ( this , destFixedSize , destMultiSize ) ,
999+ destGray2 . RenderGray2 ) ;
1000+ break ;
1001+
9631002 // gray8 -> gray8
9641003 case FrameFormat . Gray8 :
9651004 AssertCompatibility ( source , sourceGray8 , dest , destGray8 , from , to ) ;
@@ -984,7 +1023,7 @@ private void Connect(ISource source, IDestination dest, FrameFormat from, FrameF
9841023 ) ;
9851024 break ;
9861025
987- // gray4 -> rgb24
1026+ // gray8 -> rgb24
9881027 case FrameFormat . Rgb24 :
9891028 AssertCompatibility ( source , sourceGray8 , dest , destRgb24 , from , to ) ;
9901029 Subscribe (
@@ -996,6 +1035,19 @@ private void Connect(ISource source, IDestination dest, FrameFormat from, FrameF
9961035 destRgb24 . RenderRgb24 ) ;
9971036 break ;
9981037
1038+ // gray8 -> bitmap
1039+ case FrameFormat . Bitmap :
1040+ AssertCompatibility ( source , sourceGray8 , dest , destBitmap , from , to ) ;
1041+ Subscribe (
1042+ sourceGray8 . GetGray8Frames ( ! dest . NeedsDuplicateFrames ) ,
1043+ frame => frame
1044+ . TransformHdScaling ( destFixedSize , ScalerMode )
1045+ . ConvertGrayToBmp ( _gray8Palette ?? _gray8Colors )
1046+ . Transform ( this , destFixedSize , destMultiSize ) ,
1047+ destBitmap . RenderBitmap ) ;
1048+ break ;
1049+
1050+
9991051 default :
10001052 throw new ArgumentOutOfRangeException ( nameof ( to ) , to , null ) ;
10011053 }
0 commit comments