@@ -3941,41 +3941,25 @@ public void To24Bit()
39413941 }
39423942 }
39433943 else
3944- if ( Buffers [ 0 ] . PixelFormat == PixelFormat . Format16bppGrayScale || Buffers [ 0 ] . PixelFormat == PixelFormat . Format8bppIndexed )
3944+ if ( Buffers [ 0 ] . PixelFormat == PixelFormat . Format16bppGrayScale )
39453945 {
3946- if ( Buffers [ 0 ] . PixelFormat == PixelFormat . Format16bppGrayScale )
3946+ //We run 8bit so we get 24 bit rgb.
3947+ for ( int i = 0 ; i < Buffers . Count ; i ++ )
39473948 {
3948- for ( int i = 0 ; i < Buffers . Count ; i ++ )
3949- {
3950- Buffers [ i ] . Image = AForge . Imaging . Image . Convert16bppTo8bpp ( Buffers [ i ] ) ;
3951- }
3952- for ( int c = 0 ; c < Channels . Count ; c ++ )
3953- {
3954- for ( int i = 0 ; i < Channels [ c ] . range . Length ; i ++ )
3955- {
3956- Channels [ c ] . range [ i ] . Min = ( int ) ( ( ( float ) Channels [ c ] . range [ i ] . Min / ( float ) ushort . MaxValue ) * byte . MaxValue ) ;
3957- Channels [ c ] . range [ i ] . Max = ( int ) ( ( ( float ) Channels [ c ] . range [ i ] . Max / ( float ) ushort . MaxValue ) * byte . MaxValue ) ;
3958- }
3959- Channels [ c ] . BitsPerPixel = 8 ;
3960- }
3949+ Buffers [ i ] = AForge . Imaging . Image . Convert16bppTo8bpp ( Buffers [ i ] ) ;
39613950 }
3962- List < Bitmap > bfs = new List < Bitmap > ( ) ;
3963- if ( Buffers . Count % 3 != 0 )
3964- for ( int i = 0 ; i < Buffers . Count ; i ++ )
3965- {
3966- Bitmap bs = new Bitmap ( ID , SizeX , SizeY , Buffers [ i ] . PixelFormat , Buffers [ i ] . Bytes , new ZCT ( Buffers [ i ] . Coordinate . Z , 0 , Buffers [ i ] . Coordinate . T ) , i , Buffers [ i ] . Plane ) ;
3967- Bitmap bbs = Bitmap . RGB8To24 ( bs ) ;
3968- bs . Dispose ( ) ;
3969- bs = null ;
3970- bfs . Add ( bbs ) ;
3971- }
3972- else
3973- for ( int i = 0 ; i < Buffers . Count ; i ++ )
3974- {
3975- Bitmap bs = Bitmap . GetBitmapRGB ( Buffers [ i ] . SizeX , Buffers [ i ] . SizeY , PixelFormat . Format24bppRgb , Buffers [ i ] . Bytes ) ;
3976- bfs . Add ( bs ) ;
3977- }
3978- Buffers = bfs ;
3951+ To24Bit ( ) ;
3952+ }
3953+ else if ( Buffers [ 0 ] . PixelFormat == PixelFormat . Format8bppIndexed )
3954+ {
3955+ List < Bitmap > bms = new List < Bitmap > ( ) ;
3956+ //We run 8bit so we get 24 bit rgb.
3957+ for ( int i = 0 ; i < Buffers . Count ; i += 3 )
3958+ {
3959+ bms . Add ( Bitmap . RGB8To24 ( new Bitmap [ ] { Buffers [ i ] , Buffers [ i + 1 ] , Buffers [ i + 2 ] } ) ) ;
3960+ }
3961+ Buffers . Clear ( ) ;
3962+ Buffers . AddRange ( bms ) ;
39793963 UpdateCoords ( SizeZ , 1 , SizeT ) ;
39803964 }
39813965 foreach ( var item in Buffers )
@@ -7529,7 +7513,7 @@ public static BioImage OpenOME(string file, int serie, bool tab, bool addToImage
75297513 b . bitsPerPixel = 16 ;
75307514 b . series = serie ;
75317515 string order = reader . getDimensionOrder ( ) ;
7532- if ( vips )
7516+ if ( vips && tile )
75337517 OpenVips ( b ) ;
75347518 //Lets get the channels and initialize them
75357519 int i = 0 ;
0 commit comments