当前位置: 首页>>代码示例>>C#>>正文


C# ImageFileType类代码示例

本文整理汇总了C#中ImageFileType的典型用法代码示例。如果您正苦于以下问题:C# ImageFileType类的具体用法?C# ImageFileType怎么用?C# ImageFileType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ImageFileType类属于命名空间,在下文中一共展示了ImageFileType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CopyImage

        private static void CopyImage(string file, ImageFileType type)
        {
            string newFileFullPath = Path.Combine(destFolder, Path.GetFileName(file));
            if (type == ImageFileType.Jpeg)
                newFileFullPath += ".jpg";
            else if (type == ImageFileType.Png)
                newFileFullPath += ".png";

            if (File.Exists(newFileFullPath))
                return;

            if (ImageHelper.IsMobileSizeImage(file))
                return;

            try
            {
                if (!Directory.Exists(destFolder))
                    Directory.CreateDirectory(destFolder);

                File.Copy(file, newFileFullPath);
            }
            catch (Exception)
            {
            }
        }
开发者ID:xupefei,项目名称:Spotlight_Checker,代码行数:25,代码来源:Program.cs

示例2: RasterImage

 public RasterImage(BitmapSource source, ImageFileType fileType)
 {
     this.source = source;
     this.fileType = fileType;
     this.frames = new List<IFrame>(1)
     {
         new RasterFrame(source)
     };
 }
开发者ID:spadapet,项目名称:universal-image-scaler,代码行数:9,代码来源:RasterImage.cs

示例3: ImageSearchData

 internal ImageSearchData(SearchData result, Uri refUrl, Uri refClkUrl, long fileSize, ImageFileType fileFormat, int height, int width, Uri tmbUrl, int tmbHeight, int tmbWidth)
     : base(result.Title, result.Description, result.Url, result.ClickUrl)
 {
     mRefererUrl = refUrl;
     mRefererClickUrl = refClkUrl;
     mFileSize = fileSize;
     mFileFormat = fileFormat;
     mHeight = height;
     mWidth = width;
     mThumbnail = new Thumbnail(tmbUrl, tmbHeight, tmbWidth);
 }
开发者ID:kevinyang72,项目名称:CatchTheFish01,代码行数:11,代码来源:SearchData.cs

示例4: Capture

 public static void Capture( GraphicsDevice device, string filePath = null, ImageFileType format = ImageFileType.Png )
 {
     if( filePath == null )
     {
         if( !Directory.Exists( defaultFolder ) )
         {
             Directory.CreateDirectory( defaultFolder );
         }
         filePath = Path.Combine( defaultFolder, defaultName + "_" + ( FileCount( defaultFolder ) + 1 ).ToString() + "." + format.ToString().ToLower() );
     }
     device.BackBuffer.Save( filePath, format );
 }
开发者ID:adamxi,项目名称:SharpDXFramework,代码行数:12,代码来源:ScreenCapture.cs

示例5: GetFileType

		string GetFileType (ImageFileType type)
		{
			switch (type) {
			case ImageFileType.Bmp:
				return "bmp";
			case ImageFileType.Jpeg:
				return "jpeg";
			case ImageFileType.Png:
				return "png";
			default:
				throw new NotSupportedException ();
			}
		}
开发者ID:StEvUgnIn,项目名称:xwt,代码行数:13,代码来源:ImageHandler.cs

示例6: RtfImage

		internal RtfImage(string fileName, ImageFileType type)
		{
			_imgFname = fileName;
			_imgType = type;
			_alignment = Align.None;
			_margins = new Margins();
			_keepAspectRatio = true;
			_blockHead = @"{\pard";
			_blockTail = @"\par}";
			_startNewPage = false;
			
			Image image = Image.FromFile(fileName);
			_width = (image.Width / image.HorizontalResolution) * 72;
			_height = (image.Height / image.VerticalResolution) * 72;
		}
开发者ID:peterson1,项目名称:ErrH,代码行数:15,代码来源:RtfImage.cs

示例7: OutputSet

        public OutputSet(SourceImage owner, string name)
        {
            this.owner = owner;
            this.name = name;
            this.description = string.Empty;
            this.expanded = true;
            this.transformType = ImageTransformType.None;
            this.outputType = ImageHelpers.IsBitmapType(owner.Image.FileType)
                ? owner.Image.FileType
                : ImageFileType.DefaultRasterize;
            this.images = new ObservableCollection<OutputImage>();

            this.UpdateSize();

            owner.PropertyChanged += this.OnOwnerPropertyChanged;
        }
开发者ID:spadapet,项目名称:universal-image-scaler,代码行数:16,代码来源:OutputSet.cs

示例8: Image

        /// <summary>
        /// Create a new image.
        /// </summary>
        /// <param name="Url">URL from where the image data can be fetched through a web browser (about 512 pixels).</param>
        /// <param name="Thumbnail">URL from where a thumbnail of the image can be fetched through a webbrowser (about 128 pixels).</param>
        /// <param name="Category">Describes what the image is used for.</param>
        /// <param name="Type">Image type like: gif, jpeg, png, svg.</param>
        /// <param name="Width">Width of the full scale image.</param>
        /// <param name="Height">Height of the full scale image.</param>
        public Image(Uri                Url,
                     Uri                Thumbnail,
                     ImageCategoryType  Category,
                     ImageFileType      Type,
                     UInt32             Width,
                     UInt32             Height)
        {
            #region Initial checks

            if (Url == null)
                throw new ArgumentNullException("Url", "The given parameter must not be null!");

            #endregion

            this._Url        = Url;
            this._Thumbnail  = Thumbnail;
            this._Category   = Category;
            this._Type       = Type;
            this._Width      = Width;
            this._Height     = Height;
        }
开发者ID:OpenChargingCloud,项目名称:WWCP_OCPI,代码行数:30,代码来源:Image.cs

示例9: SearchGalleryAdvancedRequest

        /// <exception cref="ArgumentNullException">
        ///     Thrown when a null reference is passed to a method that does not accept it as a
        ///     valid argument.
        /// </exception>
        internal string SearchGalleryAdvancedRequest(string url,
            string qAll = null, string qAny = null,
            string qExactly = null, string qNot = null,
            ImageFileType? fileType = null, ImageSize? imageSize = null)
        {
            if (string.IsNullOrWhiteSpace(url))
                throw new ArgumentNullException(nameof(url));

            if (string.IsNullOrWhiteSpace(qAll) &&
                string.IsNullOrWhiteSpace(qAny) &&
                string.IsNullOrWhiteSpace(qExactly) &&
                string.IsNullOrWhiteSpace(qNot))
                throw new ArgumentNullException(null,
                    "At least one search parameter must be provided (All | Any | Exactly | Not).");

            var query = new StringBuilder();

            if (!string.IsNullOrWhiteSpace(qAll))
                query.Append($"&q_all={WebUtility.UrlEncode(qAll)}");

            if (!string.IsNullOrWhiteSpace(qAny))
                query.Append($"&q_any={WebUtility.UrlEncode(qAny)}");

            if (!string.IsNullOrWhiteSpace(qExactly))
                query.Append($"&q_exactly={WebUtility.UrlEncode(qExactly)}");

            if (!string.IsNullOrWhiteSpace(qNot))
                query.Append($"&q_not={WebUtility.UrlEncode(qNot)}");

            if (fileType != null)
                query.Append($"&q_type={WebUtility.UrlEncode(fileType.ToString().ToLower())}");

            if (imageSize != null)
                query.Append($"&q_size_px={WebUtility.UrlEncode(imageSize.ToString().ToLower())}");

            return $"{url}?{query}".Replace("?&", "?");
        }
开发者ID:DamienDennehy,项目名称:Imgur.API,代码行数:41,代码来源:GalleryRequestBuilder.cs

示例10: GetScaledPath

        public string GetScaledPath(double scale, string fileNameOverride = null, ImageFileType fileTypeOverride = ImageFileType.None)
        {
            string path;
            int insertPos = -1;

            if (string.IsNullOrEmpty(fileNameOverride))
            {
                path = this.pathScaleLength > 0
                    ? this.path.Remove(this.pathScaleStart, this.pathScaleLength - 1)
                    : this.path;

                insertPos = this.pathScaleStart;
            }
            else
            {
                path = Path.Combine(this.FullDir, fileNameOverride);
                insertPos = path.Length - Path.GetExtension(path).Length;
            }

            if (insertPos != -1 && scale > 0)
            {
                path = path.Insert(insertPos, $".scale-{(int)(scale * 100.0)}");
            }

            if (fileTypeOverride != ImageFileType.None && fileTypeOverride != this.Image.FileType)
            {
                string oldExtension = Path.GetExtension(path);
                string newExtension = oldExtension;

                switch (fileTypeOverride)
                {
                    case ImageFileType.Bmp:
                        newExtension = ".bmp";
                        break;

                    case ImageFileType.Jpeg:
                        newExtension = ".jpg";
                        break;

                    case ImageFileType.Png:
                        newExtension = ".png";
                        break;

                    default:
                        Debug.Fail("Can't save with file extension for: " + fileTypeOverride);
                        break;
                }

                if (oldExtension != newExtension)
                {
                    path = path.Remove(path.Length - oldExtension.Length, oldExtension.Length) + newExtension;
                }
            }

            return path;
        }
开发者ID:spadapet,项目名称:universal-image-scaler,代码行数:56,代码来源:SourceImage.cs

示例11: Save

 public void Save(string file, ImageFileType fileType)
 {
     using (var f = File.OpenWrite (file))
         Save (f, fileType);
 }
开发者ID:henriquemotaesteves,项目名称:xwt,代码行数:5,代码来源:Image.cs

示例12: TestLoadAndSave

        public void TestLoadAndSave()
        {
            var dxsdkDir = Environment.GetEnvironmentVariable("DXSDK_DIR");

            if (string.IsNullOrEmpty(dxsdkDir))
                throw new NotSupportedException("Install DirectX SDK June 2010 to run this test (DXSDK_DIR env variable is missing).");

            GC.Collect();
            GC.WaitForFullGCComplete();
            testMemoryBefore = GC.GetTotalMemory(true);

            var files = new List<string>();
            files.AddRange(Directory.EnumerateFiles(Path.Combine(dxsdkDir, @"Samples\Media"), "*.dds", SearchOption.AllDirectories));
            files.AddRange(Directory.EnumerateFiles(Path.Combine(dxsdkDir, @"Samples\Media"), "*.jpg", SearchOption.AllDirectories));
            files.AddRange(Directory.EnumerateFiles(Path.Combine(dxsdkDir, @"Samples\Media"), "*.bmp", SearchOption.AllDirectories));

            const int Count = 1; // Change this to perform memory benchmarks
            var types = new ImageFileType[] {
                ImageFileType.Dds,
            };

            for (int i = 0; i < Count; i++)
            {
                for (int j = 0; j < types.Length; j++)
                {
                    Console.Write("[{0}] ", i);
                    ProcessFiles(files, types[j]);
                }
            }
        }
开发者ID:releed,项目名称:paradox,代码行数:30,代码来源:TestImage.cs

示例13: ProcessFiles

        private void ProcessFiles(IEnumerable<string> files, ImageFileType intermediateFormat)
        {

            Console.WriteLine("Testing {0}", intermediateFormat);
            Console.Out.Flush();
            int imageCount = 0;
            var clock = Stopwatch.StartNew();
            foreach (var file in files)
            {
                // Load an image from a file and dispose it.
                Image image;
                using (var inStream = File.OpenRead(file))
                    image = Image.Load(inStream);
                image.Dispose();

                // Load an image from a buffer
                var buffer = File.ReadAllBytes(file);

                using (image = Image.Load(buffer))
                {

                    // Write this image to a memory stream using DDS format.
                    var tempStream = new MemoryStream();
                    image.Save(tempStream, intermediateFormat);
                    tempStream.Position = 0;

                    // Save to a file on disk
                    var name = Enum.GetName(typeof(ImageFileType), intermediateFormat).ToLower();
                    using (var outStream = File.OpenWrite(Path.ChangeExtension(Path.GetFileName(file), name)))
                        image.Save(outStream, intermediateFormat);

                    if (intermediateFormat == ImageFileType.Dds)
                    {
                        // Reload the image from the memory stream.
                        var image2 = Image.Load(tempStream);
                        CompareImage(image, image2, file);
                        image2.Dispose();
                    }
                }

                imageCount++;
            }
            var time = clock.ElapsedMilliseconds;
            clock.Stop();

            GC.Collect();
            GC.WaitForPendingFinalizers();
            var testMemoryAfter = GC.GetTotalMemory(true);
            Console.WriteLine("Loaded {0} and convert to (Dds, Jpg, Png, Gif, Bmp, Tiff) image from DirectXSDK test Memory: {1} bytes, in {2}ms", imageCount, testMemoryAfter - testMemoryBefore, time);
        }
开发者ID:releed,项目名称:paradox,代码行数:50,代码来源:TestImage.cs

示例14: GetContainerFormatFromFileType

 private static Guid GetContainerFormatFromFileType(ImageFileType fileType)
 {
     switch (fileType)
     {
         case ImageFileType.Bmp:
             return ContainerFormatGuids.Bmp;
         case ImageFileType.Jpg:
             return ContainerFormatGuids.Jpeg;
         case ImageFileType.Gif:
             return ContainerFormatGuids.Gif;
         case ImageFileType.Png:
             return ContainerFormatGuids.Png;
         case ImageFileType.Tiff:
             return ContainerFormatGuids.Tiff;
         case ImageFileType.Wmp:
             return ContainerFormatGuids.Wmp;
         default:
             throw new NotSupportedException("Format not supported");
     }
 }
开发者ID:numo16,项目名称:SharpDX,代码行数:20,代码来源:WICHelper.cs

示例15: SaveToWICMemory

 private static void SaveToWICMemory(PixelBuffer[] pixelBuffer, int count, WICFlags flags, ImageFileType fileType, Stream stream)
 {
     if (count > 1)
         EncodeMultiframe(pixelBuffer, count, flags, GetContainerFormatFromFileType(fileType), stream);
     else
         EncodeSingleFrame(pixelBuffer[0], flags, GetContainerFormatFromFileType(fileType), stream);
 }
开发者ID:numo16,项目名称:SharpDX,代码行数:7,代码来源:WICHelper.cs


注:本文中的ImageFileType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。