Пример #1
0
        /// <summary>
        /// Creates a new image and world file, placing the default bounds at the origin, with one pixel per unit.
        /// </summary>
        /// <param name="fileName">The string fileName.</param>
        /// <param name="width">The integer width.</param>
        /// <param name="height">The integer height.</param>
        /// <param name="bandType">The ImageBandType that clarifies how the separate bands are layered in the image.</param>
        /// <returns>The create image.</returns>
        public override IImageData Create(string fileName, int width, int height, ImageBandType bandType)
        {
            Filename  = fileName;
            WorldFile = new WorldFile();
            double[] aff = { 1.0, 0, 0, -1.0, 0, height };
            Bounds             = new RasterBounds(height, width, aff);
            WorldFile.Filename = WorldFile.GenerateFilename(fileName);
            Width    = width;
            Height   = height;
            _myImage = new Bitmap(width, height);
            string      ext         = Path.GetExtension(fileName);
            ImageFormat imageFormat = ext switch
            {
                ".bmp" => ImageFormat.Bmp,
                ".emf" => ImageFormat.Emf,
                ".exf" => ImageFormat.Exif,
                ".gif" => ImageFormat.Gif,
                ".ico" => ImageFormat.Icon,
                ".jpg" => ImageFormat.Jpeg,
                ".mbp" => ImageFormat.MemoryBmp,
                ".png" => ImageFormat.Png,
                ".tif" => ImageFormat.Tiff,
                ".wmf" => ImageFormat.Wmf,
                _ => throw new ArgumentOutOfRangeException(nameof(fileName), DataStrings.FileTypeNotSupported),
            };

            _myImage.Save(fileName, imageFormat);

            NumBands      = 4;
            BytesPerPixel = 4;
            CopyBitmapToValues();

            return(this);
        }
Пример #2
0
 /// <summary>
 /// Saves the image to the specified fileName
 /// </summary>
 /// <param name="fileName">
 /// The string fileName to save this as
 /// </param>
 public override void SaveAs(string fileName)
 {
     Filename = fileName;
     if (WorldFile != null)
     {
         WorldFile.Filename = WorldFile.GenerateFilename(fileName);
     }
     Save();
 }
Пример #3
0
        /// <summary>
        /// Creates a new image and world file, placing the default bounds at the origin, with one pixel per unit.
        /// </summary>
        /// <param name="fileName">
        /// The string fileName
        /// </param>
        /// <param name="width">
        /// The integer width
        /// </param>
        /// <param name="height">
        /// The integer height
        /// </param>
        /// <param name="bandType">The ImageBandType that clarifies how the separate bands are layered in the image.</param>
        public override IImageData Create(string fileName, int width, int height, ImageBandType bandType)
        {
            Filename = fileName;
            WorldFile = new WorldFile();
            double[] aff = new[] { 1.0, 0, 0, -1.0, 0, height };
            Bounds = new RasterBounds(height, width, aff);
            WorldFile.Filename = WorldFile.GenerateFilename(fileName);
            Width = width;
            Height = height;
            _myImage = new Bitmap(width, height);
            string ext = Path.GetExtension(fileName);
            switch (ext)
            {
                case ".bmp":
                    _myImage.Save(fileName, ImageFormat.Bmp);
                    break;
                case ".emf":
                    _myImage.Save(fileName, ImageFormat.Emf);
                    break;
                case ".exf":
                    _myImage.Save(fileName, ImageFormat.Exif);
                    break;
                case ".gif":
                    _myImage.Save(fileName, ImageFormat.Gif);
                    break;
                case ".ico":
                    _myImage.Save(fileName, ImageFormat.Icon);
                    break;
                case ".jpg":
                    _myImage.Save(fileName, ImageFormat.Jpeg);
                    break;
                case ".mbp":
                    _myImage.Save(fileName, ImageFormat.MemoryBmp);
                    break;
                case ".png":
                    _myImage.Save(fileName, ImageFormat.Png);
                    break;
                case ".tif":
                    _myImage.Save(fileName, ImageFormat.Tiff);
                    break;
                case ".wmf":
                    _myImage.Save(fileName, ImageFormat.Wmf);
                    break;
            }

            NumBands = 4;
            BytesPerPixel = 4;
            CopyBitmapToValues();

            return this;
        }
Пример #4
0
        /// <summary>
        /// Creates a new image and world file, placing the default bounds at the origin, with one pixel per unit.
        /// </summary>
        /// <param name="fileName">
        /// The string fileName
        /// </param>
        /// <param name="width">
        /// The integer width
        /// </param>
        /// <param name="height">
        /// The integer height
        /// </param>
        /// <param name="bandType">The ImageBandType that clarifies how the separate bands are layered in the image.</param>
        public override IImageData Create(string fileName, int width, int height, ImageBandType bandType)
        {
            Filename  = fileName;
            WorldFile = new WorldFile();
            double[] aff = new[] { 1.0, 0, 0, -1.0, 0, height };
            Bounds             = new RasterBounds(height, width, aff);
            WorldFile.Filename = WorldFile.GenerateFilename(fileName);
            Width    = width;
            Height   = height;
            _myImage = new Bitmap(width, height);
            string ext = Path.GetExtension(fileName);

            switch (ext)
            {
            case ".bmp":
                _myImage.Save(fileName, ImageFormat.Bmp);
                break;

            case ".emf":
                _myImage.Save(fileName, ImageFormat.Emf);
                break;

            case ".exf":
                _myImage.Save(fileName, ImageFormat.Exif);
                break;

            case ".gif":
                _myImage.Save(fileName, ImageFormat.Gif);
                break;

            case ".ico":
                _myImage.Save(fileName, ImageFormat.Icon);
                break;

            case ".jpg":
                _myImage.Save(fileName, ImageFormat.Jpeg);
                break;

            case ".mbp":
                _myImage.Save(fileName, ImageFormat.MemoryBmp);
                break;

            case ".png":
                _myImage.Save(fileName, ImageFormat.Png);
                break;

            case ".tif":
                _myImage.Save(fileName, ImageFormat.Tiff);
                break;

            case ".wmf":
                _myImage.Save(fileName, ImageFormat.Wmf);
                break;
            }

            NumBands      = 4;
            BytesPerPixel = 4;
            CopyBitmapToValues();

            return(this);
        }
Пример #5
0
        /// <summary>
        /// Creates a new image and world file, placing the default bounds at the origin, with one pixel per unit.
        /// </summary>
        /// <param name="fileName">  The string fileName </param>
        /// <param name="width">  The integer width </param>
        /// <param name="height"> The integer height </param>
        /// <param name="bandType">The ImageBandType that clarifies how the separate bands are layered in the image.</param>
        public override IImageData Create(string fileName, int width, int height, ImageBandType bandType)
        {
            Filename  = fileName;
            WorldFile = new WorldFile();
            double[] aff = { 1.0, 0, 0, -1.0, 0, height };
            Bounds             = new RasterBounds(height, width, aff);
            WorldFile.Filename = WorldFile.GenerateFilename(fileName);
            Width    = width;
            Height   = height;
            _myImage = new Bitmap(width, height);
            string      ext = Path.GetExtension(fileName);
            ImageFormat imageFormat;

            switch (ext)
            {
            case ".bmp":
                imageFormat = ImageFormat.Bmp;
                break;

            case ".emf":
                imageFormat = ImageFormat.Emf;
                break;

            case ".exf":
                imageFormat = ImageFormat.Exif;
                break;

            case ".gif":
                imageFormat = ImageFormat.Gif;
                break;

            case ".ico":
                imageFormat = ImageFormat.Icon;
                break;

            case ".jpg":
                imageFormat = ImageFormat.Jpeg;
                break;

            case ".mbp":
                imageFormat = ImageFormat.MemoryBmp;
                break;

            case ".png":
                imageFormat = ImageFormat.Png;
                break;

            case ".tif":
                imageFormat = ImageFormat.Tiff;
                break;

            case ".wmf":
                imageFormat = ImageFormat.Wmf;
                break;

            default:
                throw new ArgumentOutOfRangeException("fileName", "File format is unsupported.");
            }

            _myImage.Save(fileName, imageFormat);

            NumBands      = 4;
            BytesPerPixel = 4;
            CopyBitmapToValues();

            return(this);
        }