@@ -108,49 +108,5 @@ public static int getNumberofTiffPages(Tiff image)
108108
109109 return pageCount ;
110110 }
111-
112- public static SKBitmap OpenTiff ( Stream tiffStream )
113- {
114- // https://stackoverflow.com/questions/50312937/skiasharp-tiff-support
115-
116- tiffStream . Position = 0 ;
117- // open a TIFF stored in the stream
118- using ( var tifImg = Tiff . ClientOpen ( "in-memory" , "r" , tiffStream , new TiffStream ( ) ) )
119- {
120- tifImg . SetDirectory ( 1 ) ;
121-
122- // read the dimensions
123- var width = tifImg . GetField ( TiffTag . IMAGEWIDTH ) [ 0 ] . ToInt ( ) ;
124- var height = tifImg . GetField ( TiffTag . IMAGELENGTH ) [ 0 ] . ToInt ( ) ;
125-
126- // create the bitmap
127- var bitmap = new SKBitmap ( ) ;
128- var info = new SKImageInfo ( width , height ) ;
129-
130- // create the buffer that will hold the pixels
131- var raster = new int [ width * height ] ;
132-
133- // get a pointer to the buffer, and give it to the bitmap
134- var ptr = GCHandle . Alloc ( raster , GCHandleType . Pinned ) ;
135- bitmap . InstallPixels ( info , ptr . AddrOfPinnedObject ( ) , info . RowBytes , null , ( addr , ctx ) => ptr . Free ( ) , null ) ;
136-
137- // read the image into the memory buffer
138- if ( ! tifImg . ReadRGBAImageOriented ( width , height , raster , Orientation . TOPLEFT , true ) )
139- {
140- // not a valid TIF image.
141- return null ;
142- }
143-
144- // swap the red and blue because SkiaSharp may differ from the tiff
145- if ( SKImageInfo . PlatformColorType == SKColorType . Bgra8888 )
146- {
147- SKSwizzle . SwapRedBlue ( ptr . AddrOfPinnedObject ( ) , raster . Length ) ;
148- }
149-
150- File . WriteAllBytes ( "test.bmp" , bitmap . Bytes ) ;
151-
152- return bitmap ;
153- }
154- }
155111 }
156112}
0 commit comments