Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- namespace ConsoleApp1
- {
- class Program
- {
- static void Main(string[] args)
- {
- TiffBitmapDecoder tiffBitmapDecoder = new TiffBitmapDecoder(new Uri(@"D:\sunset.tif"), BitmapCreateOptions.None, BitmapCacheOption.Default);
- BitmapFrame bitmapFrame = tiffBitmapDecoder.Frames[0];
- FormatConvertedBitmap formatConvertedBitmap = new FormatConvertedBitmap();
- formatConvertedBitmap.BeginInit();
- formatConvertedBitmap.Source = bitmapFrame;
- formatConvertedBitmap.DestinationFormat = PixelFormats.Rgb24;
- formatConvertedBitmap.EndInit();
- int stride = ((formatConvertedBitmap.PixelWidth * formatConvertedBitmap.Format.BitsPerPixel + 31) >> 5) << 2;
- byte[] pixels = new byte[formatConvertedBitmap.PixelHeight * stride];
- formatConvertedBitmap.CopyPixels(pixels, stride, 0);
- File.WriteAllBytes(@"D:\sunset_rgb24.raw", pixels);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement