Beispiel #1
0
        public MainWindow()
        {
            InitializeComponent();

            try
            {
                var tiffs = TiffHelper.ReadDoubleByteTiff(@"D:\gaoqi\原始图像\tif\hengzhe.tif");

                var bmps = TiffHelper.SliceVetically(tiffs[0], 2);

                bmps = TiffHelper.SliceVetically(@"D:\gaoqi\原始图像\tif\hengzhe.tif", 2);

                var bmp1 = TiffHelper.ConvertTiffInfoToBitmap(bmps[0]);
                var bmp2 = TiffHelper.ConvertTiffInfoToBitmap(bmps[1]);

                TiffImage1.Source = BitmapToBitmapImage(bmp1);
                TiffImage2.Source = BitmapToBitmapImage(bmp2);

                var tiff1 = bmps[0];
                var tiff2 = bmps[1];

                TiffHelper.Create16BitGrayScaleTiff(tiff1.UshortBuffer, tiff1.Width, tiff1.Height, @"\tif\NewTiff1.tiff");
                TiffHelper.Create16BitGrayScaleTiff(tiff2.UshortBuffer, tiff2.Width, tiff2.Height, @"\tif\NewTiff2.tiff");
            }
            catch (Exception e)
            {
                Tracer.Exception(e);
            }
        }
Beispiel #2
0
        private void OpenFileDiag(object sender, RoutedEventArgs e)
        {
            // Configure open file dialog box
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.DefaultExt = ".tiff";                                           // Default file extension
            dlg.Filter     = " Tiff (.tiff)|*.tiff|(.tif)|*.tif|All Files|*.*"; // Filter files by extension

            // Show open file dialog box
            bool?result = dlg.ShowDialog();

            // Process open file dialog box results
            if (result == true)
            {
                // Open document
                string filename = dlg.FileName;

                var bmps = TiffHelper.SliceVetically(filename, 2);

                var bmp1 = TiffHelper.ConvertTiffInfoToBitmap(bmps[0]);
                var bmp2 = TiffHelper.ConvertTiffInfoToBitmap(bmps[1]);

                TiffImage1.Source = BitmapToBitmapImage(bmp1);
                TiffImage2.Source = BitmapToBitmapImage(bmp2);

                var tiff1 = bmps[0];
                var tiff2 = bmps[1];

                // Configure save file dialog box
                SaveFileDialog saveDlg = new SaveFileDialog();
                saveDlg.FileName   = "Tiff";                // Default file name
                saveDlg.DefaultExt = ".tiff";               // Default file extension
                saveDlg.Filter     = "Tiff (.tiff)|*.tiff"; // Filter files by extension

                // Show save file dialog box
                result = saveDlg.ShowDialog();

                // Process save file dialog box results
                if (result == true)
                {
                    // Save document
                    filename = saveDlg.FileName;

                    //TiffHelper.Create16BitGrayScaleTiff(tiff1.UshortBuffer, tiff1.Width, tiff1.Height, filename);
                    //TiffHelper.Create16BitGrayScaleTiff(tiff2.UshortBuffer, tiff2.Width, tiff2.Height, filename);

                    TiffHelper.CreateMultipage16BitTiff(
                        new List <List <ushort[]> >()
                    {
                        tiff1.UshortBuffer, tiff2.UshortBuffer
                    }, tiff1.Width, tiff1.Height,
                        filename);
                }
            }
        }
Beispiel #3
0
        public void GetExifIfdReference_ReturnsCorrectReference(TiffType type, ByteOrder byteOrder)
        {
            var tiffIfd = new TiffIfd
            {
                Entries = new[]
                {
                    new TiffIfdEntry {
                        Tag = 10, Type = TiffType.Ascii, Count = 10
                    },
                    TiffHelper.GenerateTiffIfdEntry(TiffTags.ExifIFD, type, 20u, byteOrder),
                    new TiffIfdEntry {
                        Tag = 20, Type = TiffType.Ascii, Count = 10
                    }
                }
            };

            var exifIfdReference = ExifReader.GetExifIfdReference(tiffIfd, byteOrder);

            Assert.Equal(new TiffIfdReference(20), exifIfdReference);
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            foreach (var frame in TiffHelper.GetAllPages("TEST.tif"))
            {
                var image = new Bitmap(frame);

                var rgbBitmap = BitonalConverter.ConvertToRGB(image);

                //var bitonalBitmap = BitionalConverter.ConvertToMonochrome(rgbBitmap);

                //bitonalBitmap.SaveAsTiff(string.Format("{0}.tif", Guid.NewGuid()));

                BitonalConverter.ConvertTo1Bit(rgbBitmap).SaveAsTiff("ConvertTo1Bit.tif");

                BitonalConverter.ConvertToBitonal(rgbBitmap).SaveAsTiff("ConvertToBitonal.tif");

                BitonalConverter.ConvertToMono2(rgbBitmap).SaveAsTiff("ConvertToMono2.tif");

                BitonalConverter.ConvertToMonochrome(rgbBitmap).SaveAsTiff("ConvertToMonochrome.tif");

                return;
            }
        }