Beispiel #1
0
        static void Main(string[] args)
        {
            using (TiffFile file = new TiffFile("F:\\Downloads\\Public\\VLI\\heic0601a.ptiff"))
            {
                TiffImage image = file.Images[5];

                using (Bitmap bitmap = image.GetTile(0 * 256, 0 * 256))
                    bitmap.Save("0.jpg", ImageFormat.Jpeg);

                using (Bitmap bitmap = image.GetTile(1 * 256, 0 * 256))
                    bitmap.Save("1.jpg", ImageFormat.Jpeg);

                using (Bitmap bitmap = image.GetTile(0 * 256, 1 * 256))
                    bitmap.Save("2.jpg", ImageFormat.Jpeg);

                using (Bitmap bitmap = image.GetTile(1 * 256, 1 * 256))
                    bitmap.Save("3.jpg", ImageFormat.Jpeg);
            }
        }
        private static void DrawRow(TiffImage image, System.Drawing.Point offset, Rectangle region, Rectangle tile, Graphics graphics)
        {
            while (tile.IntersectsWith(region))
            {
                Rectangle fragment    = Rectangle.Intersect(tile, region);
                Rectangle source      = fragment.OffsetCopy(tile.Location.NegateCopy());
                Rectangle destination = fragment.OffsetCopy(region.Location.NegateCopy());

                using (Bitmap tileImage = image.GetTile(tile.X - offset.X, tile.Y - offset.Y))
                {
                    graphics.DrawImage(tileImage, destination, source, GraphicsUnit.Pixel);

#if DEBUG
                    graphics.DrawRectangle(Pens.Yellow, destination);
#endif
                }

                tile = NextTileX(image, offset, tile);
            }
        }