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


C# ImageFormat.ToString方法代码示例

本文整理汇总了C#中ImageFormat.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# ImageFormat.ToString方法的具体用法?C# ImageFormat.ToString怎么用?C# ImageFormat.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ImageFormat的用法示例。


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

示例1: GetUri

 /// <summary>
 /// Gets the full path to the image asset, suitable for current screen resolution
 /// </summary>
 /// <param name="path">Path to image asset, relative to app root</param>
 /// <returns></returns>
 public static Uri GetUri(string path, ImageFormat imageFormat = ImageFormat.JPG) {
   switch (ResolutionHelper.CurrentResolution) {
     case Resolutions.HD:
       return new Uri("{0}.Screen-720p.{1}".FormatWith(path, imageFormat.ToString().ToLowerInvariant()), UriKind.Relative);
     case Resolutions.WXGA:
       return new Uri("{0}.Screen-WXGA.{1}".FormatWith(path, imageFormat.ToString().ToLowerInvariant()), UriKind.Relative);
     case Resolutions.WVGA:
       return new Uri("{0}.Screen-WVGA.{1}".FormatWith(path, imageFormat.ToString().ToLowerInvariant()), UriKind.Relative);
     default:
       throw new InvalidOperationException("Unknown resolution type");
   }
 }
开发者ID:Hitchhikrr,项目名称:IgooanaApp,代码行数:17,代码来源:MultiResImage.cs

示例2: CreateImageBuilder

		public override object CreateImageBuilder (int width, int height, ImageFormat format)
		{
			var flags = CGBitmapFlags.ByteOrderDefault;
			int bytesPerRow;
			switch (format) {

			case ImageFormat.ARGB32:
				bytesPerRow = width * 4;
				flags |= CGBitmapFlags.PremultipliedFirst;
				break;

			case ImageFormat.RGB24:
				bytesPerRow = width * 3;
				flags |= CGBitmapFlags.None;
				break;

			default:
				throw new NotImplementedException ("ImageFormat: " + format.ToString ());
			}

			var bmp = new CGBitmapContext (IntPtr.Zero, width, height, 8, bytesPerRow, Util.DeviceRGBColorSpace, flags);
			bmp.TranslateCTM (0, height);
			bmp.ScaleCTM (1, -1);
			return new CGContextBackend {
				Context = bmp,
				Size = new CGSize (width, height),
				InverseViewTransform = bmp.GetCTM ().Invert ()
			};
		}
开发者ID:m13253,项目名称:xwt,代码行数:29,代码来源:ImageBuilderBackendHandler.cs

示例3: TakeScreenShot

    public static void TakeScreenShot(IWebDriver webDriver, string screenShotFileNameWithoutExtension, ImageFormat imageFormat, string screenShotDirectoryPath) {
        Screenshot screenShot = null;
        var browserName = string.Empty;

        if (webDriver.GetType() == typeof(InternetExplorerDriver)) {
            screenShot = ((InternetExplorerDriver)webDriver).GetScreenshot();
            browserName = "IE";
        }

        if (webDriver.GetType() == typeof(FirefoxDriver)) {
            screenShot = ((FirefoxDriver)webDriver).GetScreenshot();
            browserName = "Firefox";
        }

        if (webDriver.GetType() == typeof(ChromeDriver)) {
            screenShot = ((ChromeDriver)webDriver).GetScreenshot();
            browserName = "Chrome";
        }

        var screenShotFileName = screenShotFileNameWithoutExtension + "." + imageFormat.ToString().ToLower();

        if (screenShot != null) {
            if (!string.IsNullOrEmpty(screenShotDirectoryPath)) {
                Directory.CreateDirectory(screenShotDirectoryPath).CreateSubdirectory(browserName);
                var browserScreenShotDirectoryPath = Path.Combine(screenShotDirectoryPath, browserName);
                Directory.CreateDirectory(browserScreenShotDirectoryPath);
                var screenShotFileFullPath = Path.Combine(browserScreenShotDirectoryPath, screenShotFileName);
                screenShot.SaveAsFile(screenShotFileFullPath, imageFormat);
            }
        }
    }
开发者ID:tablesmit,项目名称:browserscreenshots,代码行数:31,代码来源:Screenshots.cs

示例4: FromStream

        public static Image FromStream(Stream stream, ImageFormat format)
        {
            switch (format)
            {
                case ImageFormat.Tga:
                    return Tga.FromStream(stream);
            }

            throw new NotImplementedException("ImageFormat." + format.ToString() + " not implemented.");
        }
开发者ID:smack0007,项目名称:SharpImage,代码行数:10,代码来源:Image.cs

示例5: GetImageAsync

        public Task<IControl> GetImageAsync(ImageSource imageSource, ImageFormat format, CancellationToken cancellationToken)
        {
            var fileSource = (FileImageSource)imageSource;
            string asset = fileSource.File;

            if (format == ImageFormat.Unknown)
                format = ImageFactory.DetectFormat(asset);

            string cacheKey = format.ToString() + "|" + asset;

            return _cachedImages.GetOrAdd(cacheKey, k => GetImage(fileSource, format));
        }
开发者ID:powerdude,项目名称:xamarin-forms-xna,代码行数:12,代码来源:FileImageSourceHandler.cs

示例6: GetImageAsync

        public Task<IControl> GetImageAsync(ImageSource imageSource, ImageFormat format, CancellationToken cancellationToken)
        {
            var uriSource = (UriImageSource)imageSource;
            if (uriSource.Uri.Scheme == "pack")
                uriSource.CachingEnabled = false;
            string asset = uriSource.Uri.ToString();

            if (format == ImageFormat.Unknown)
                format = ImageFactory.DetectFormat(asset);

            string cacheKey = format.ToString() + "|" + asset;

            return _cachedImages.GetOrAdd(cacheKey, k => GetImage(uriSource, format));
        }
开发者ID:powerdude,项目名称:xamarin-forms-xna,代码行数:14,代码来源:UriImageSourceHandler.cs

示例7: ConvertPDF2Image

    /// <summary>
    /// 将PDF文档转换为图片的方法
    /// </summary>
    /// <param name="pdfInputPath">PDF文件路径</param>
    /// <param name="imageOutputPath">图片输出路径</param>
    /// <param name="imageName">生成图片的名字</param>
    /// <param name="startPageNum">从PDF文档的第几页开始转换</param>
    /// <param name="endPageNum">从PDF文档的第几页开始停止转换</param>
    /// <param name="imageFormat">设置所需图片格式</param>
    /// <param name="definition">设置图片的清晰度,数字越大越清晰</param>
    public static void ConvertPDF2Image(string pdfInputPath, string imageOutputPath,
        string imageName, int startPageNum, int endPageNum, ImageFormat imageFormat, Definition definition)
    {
        PDFFile pdfFile = PDFFile.Open(pdfInputPath);

        if (!Directory.Exists(imageOutputPath))
        {
            Directory.CreateDirectory(imageOutputPath);
        }

        // validate pageNum
        if (startPageNum <= 0)
        {
            startPageNum = 1;
        }

        if (endPageNum > pdfFile.PageCount)
        {
            endPageNum = pdfFile.PageCount;
        }

        if (startPageNum > endPageNum)
        {
            int tempPageNum = startPageNum;
            startPageNum = endPageNum;
            endPageNum = startPageNum;
        }

        // start to convert each page
        try
        {
            for (int i = startPageNum; i <= endPageNum; i++)
            {
                Bitmap pageImage = pdfFile.GetPageImage(i - 1, 56 * (int)definition);
                pageImage.Save(imageOutputPath + imageName + i.ToString() + "." + imageFormat.ToString(), imageFormat);
                pageImage.Dispose();
            }
        }
        catch (System.Exception ex)
        {

        }
        pdfFile.Dispose();
    }
开发者ID:fairo-lr,项目名称:YardPlan,代码行数:54,代码来源:Vessel_BerthNEW.aspx.cs

示例8: CreateImageBuilder

        public override object CreateImageBuilder(int width, int height, ImageFormat format)
        {
            var flags = CGBitmapFlags.ByteOrderDefault;
            int bytesPerRow;
            switch (format) {

            case ImageFormat.ARGB32:
                bytesPerRow = width * 4;
                flags |= CGBitmapFlags.PremultipliedFirst;
                break;

            case ImageFormat.RGB24:
                bytesPerRow = width * 3;
                flags |= CGBitmapFlags.None;
                break;

            default:
                throw new NotImplementedException ("ImageFormat: " + format.ToString ());
            }
            return new CGContextBackend {
                Context = new CGBitmapContext (IntPtr.Zero, width, height, 8, bytesPerRow, Util.DeviceRGBColorSpace, flags),
                Size = new SizeF (width, height)
            };
        }
开发者ID:garuma,项目名称:xwt,代码行数:24,代码来源:ImageBuilderBackendHandler.cs

示例9: GetCacheFilePath

        /// <summary>
        /// Gets the cache file path based on a set of parameters
        /// </summary>
        private string GetCacheFilePath(string originalPath, ImageSize outputSize, int quality, DateTime dateModified, ImageFormat format, bool addPlayedIndicator, double percentPlayed, int? unwatchedCount, string backgroundColor)
        {
            var filename = originalPath;

            filename += "width=" + outputSize.Width;

            filename += "height=" + outputSize.Height;

            filename += "quality=" + quality;

            filename += "datemodified=" + dateModified.Ticks;

            filename += "f=" + format;

            if (addPlayedIndicator)
            {
                filename += "pl=true";
            }

            if (percentPlayed > 0)
            {
                filename += "p=" + percentPlayed;
            }

            if (unwatchedCount.HasValue)
            {
                filename += "p=" + unwatchedCount.Value;
            }

            if (!string.IsNullOrEmpty(backgroundColor))
            {
                filename += "b=" + backgroundColor;
            }

            filename += "v=" + Version;

            return GetCachePath(ResizedImageCachePath, filename, "." + format.ToString().ToLower());
        }
开发者ID:loose-wardrobe,项目名称:Emby,代码行数:41,代码来源:ImageProcessor.cs

示例10: ConvertToBitmap

        public override object ConvertToBitmap(object handle, double width, double height, double scaleFactor, ImageFormat format)
        {
            int pixelWidth = (int)(width * scaleFactor);
            int pixelHeight = (int)(height * scaleFactor);

            if (handle is CustomImage) {
                var flags = CGBitmapFlags.ByteOrderDefault;
                int bytesPerRow;
                switch (format) {
                case ImageFormat.ARGB32:
                    bytesPerRow = pixelWidth * 4;
                    flags |= CGBitmapFlags.PremultipliedFirst;
                    break;

                case ImageFormat.RGB24:
                    bytesPerRow = pixelWidth * 3;
                    flags |= CGBitmapFlags.None;
                    break;

                default:
                    throw new NotImplementedException ("ImageFormat: " + format.ToString ());
                }

                var bmp = new CGBitmapContext (IntPtr.Zero, pixelWidth, pixelHeight, 8, bytesPerRow, Util.DeviceRGBColorSpace, flags);
                bmp.TranslateCTM (0, pixelHeight);
                bmp.ScaleCTM ((float)scaleFactor, (float)-scaleFactor);

                var ctx = new CGContextBackend {
                    Context = bmp,
                    Size = new SizeF ((float)width, (float)height),
                    InverseViewTransform = bmp.GetCTM ().Invert (),
                    ScaleFactor = scaleFactor
                };

                var ci = (CustomImage)handle;
                ci.DrawInContext (ctx);

                var img = new NSImage (((CGBitmapContext)bmp).ToImage (), new SizeF (pixelWidth, pixelHeight));
                var imageData = img.AsTiff ();
                var imageRep = (NSBitmapImageRep)NSBitmapImageRep.ImageRepFromData (imageData);
                var im = new NSImage ();
                im.AddRepresentation (imageRep);
                im.Size = new SizeF ((float)width, (float)height);
                bmp.Dispose ();
                return im;
            }
            else {
                NSImage img = (NSImage)handle;
                NSBitmapImageRep bitmap = img.Representations ().OfType<NSBitmapImageRep> ().FirstOrDefault ();
                if (bitmap == null) {
                    var imageData = img.AsTiff ();
                    var imageRep = (NSBitmapImageRep)NSBitmapImageRep.ImageRepFromData (imageData);
                    var im = new NSImage ();
                    im.AddRepresentation (imageRep);
                    im.Size = new SizeF ((float)width, (float)height);
                    return im;
                }
                return handle;
            }
        }
开发者ID:henriquemotaesteves,项目名称:xwt,代码行数:60,代码来源:ImageHandler.cs

示例11: GetSavePaths

        public IEnumerable<string> GetSavePaths(IHasImages item, ImageType type, ImageFormat format, int index)
        {
            var season = item as Season;

            if (!SupportsItem(item, type, season))
            {
                return new string[] { };
            }

            var extension = "." + format.ToString().ToLower();

            // Backdrop paths
            if (type == ImageType.Backdrop)
            {
                if (index == 0)
                {
                    if (item.IsInMixedFolder)
                    {
                        return new[] { GetSavePathForItemInMixedFolder(item, type, "fanart", extension) };
                    }

                    if (season != null && season.IndexNumber.HasValue)
                    {
                        var seriesFolder = season.SeriesPath;

                        var seasonMarker = season.IndexNumber.Value == 0
                                               ? "-specials"
                                               : season.IndexNumber.Value.ToString("00", _usCulture);

                        var imageFilename = "season" + seasonMarker + "-fanart" + extension;

                        return new[] { Path.Combine(seriesFolder, imageFilename) };
                    }

                    return new[]
                        {
                            Path.Combine(item.ContainingFolderPath, "fanart" + extension)
                        };
                }

                if (item.IsInMixedFolder)
                {
                    return new[] { GetSavePathForItemInMixedFolder(item, type, "fanart" + index.ToString(_usCulture), extension) };
                }

                var extraFanartFilename = GetBackdropSaveFilename(item.GetImages(ImageType.Backdrop), "fanart", "fanart", index);

                return new[]
                    {
                        Path.Combine(item.ContainingFolderPath, "extrafanart", extraFanartFilename + extension),
                        Path.Combine(item.ContainingFolderPath, "extrathumbs", "thumb" + index.ToString(_usCulture) + extension)
                    };
            }

            if (type == ImageType.Primary)
            {
                if (season != null && season.IndexNumber.HasValue)
                {
                    var seriesFolder = season.SeriesPath;

                    var seasonMarker = season.IndexNumber.Value == 0
                                           ? "-specials"
                                           : season.IndexNumber.Value.ToString("00", _usCulture);

                    var imageFilename = "season" + seasonMarker + "-poster" + extension;

                    return new[] { Path.Combine(seriesFolder, imageFilename) };
                }

                if (item is Episode)
                {
                    var seasonFolder = Path.GetDirectoryName(item.Path);
                    
                    var imageFilename = Path.GetFileNameWithoutExtension(item.Path) + "-thumb" + extension;

                    return new[] { Path.Combine(seasonFolder, imageFilename) };
                }

                if (item.IsInMixedFolder || item is MusicVideo)
                {
                    return new[] { GetSavePathForItemInMixedFolder(item, type, string.Empty, extension) };
                }

                if (item is MusicAlbum || item is MusicArtist)
                {
                    return new[] { Path.Combine(item.ContainingFolderPath, "folder" + extension) };
                }

                return new[] { Path.Combine(item.ContainingFolderPath, "poster" + extension) };
            }

            if (type == ImageType.Banner)
            {
                if (season != null && season.IndexNumber.HasValue)
                {
                    var seriesFolder = season.SeriesPath;

                    var seasonMarker = season.IndexNumber.Value == 0
                                           ? "-specials"
                                           : season.IndexNumber.Value.ToString("00", _usCulture);
//.........这里部分代码省略.........
开发者ID:rezafouladian,项目名称:Emby,代码行数:101,代码来源:XbmcImageSaver.cs

示例12: Save

 public void Save(Stream stream, ImageFormat imageFormat, int quality)
 {
     if (this._disposed)
     {
         throw new ObjectDisposedException("CompactImage");
     }
     if (this._handle != IntPtr.Zero)
     {
         Native.RIL_Save(this._handle, stream, imageFormat.ToString(), quality);
     }
 }
开发者ID:north0808,项目名称:haina,代码行数:11,代码来源:CompactImage.cs

示例13: Load

 public void Load(Stream stream, ImageFormat imageFormat, int frame, Color backgroundColor, LoadOptions loadOptions, System.Drawing.Size maxSize)
 {
     if (this._disposed)
     {
         throw new ObjectDisposedException("CompactImage");
     }
     if (this._handle != IntPtr.Zero)
     {
         Native.RIL_Close(this._handle);
     }
     Native.RLoadOut @out = Native.RIL_Load(null, stream, imageFormat.ToString(), frame, backgroundColor, loadOptions, maxSize, this._progressFunc);
     this._handle = @out.Handle;
     this._fullSize = (System.Drawing.Size) @out.FullSize;
     this._size = (System.Drawing.Size) @out.Size;
     this._depth = @out.Depth;
     this._numberOfFrames = @out.NumberOfFrames;
     this._loadedFrame = frame;
     this.OnChanged();
 }
开发者ID:north0808,项目名称:haina,代码行数:19,代码来源:CompactImage.cs

示例14: Fit

        /// <summary>
        /// Fits the specified image to the supplied max width and height.
        /// </summary>
        /// <param name="image">The image.</param>
        /// <param name="maxWidth">Width of the max.</param>
        /// <param name="maxHeight">Height of the max.</param>
        /// <param name="fitMode">The fit mode.</param>
        /// <param name="scaleMode">The scale mode.</param>
        /// <param name="alignMode">The align mode.</param>
        /// <param name="format">The format.</param>
        /// <param name="quality">The quality.</param>
        /// <param name="colors">The colors.</param>
        /// <param name="bgColor">Color of the background.</param>
        /// <returns></returns>
        public static IFilteredImage Fit(this IFilteredImage image, int maxWidth, int maxHeight, 
            FitMode fitMode = FitMode.Pad, ScaleMode scaleMode = ScaleMode.Down,
            AlignMode alignMode = AlignMode.MiddleCenter, ImageFormat format = ImageFormat.Auto,
            int quality = 90, int colors = 256, string bgColor = "")
        {
            image.Filters.Add("w", maxWidth);
            image.Filters.Add("h", maxHeight);

            if(fitMode != FitMode.Pad)
                image.Filters.Add("mode", fitMode.ToString().ToLower());

            if(scaleMode != ScaleMode.Down)
                image.Filters.Add("scale", scaleMode.ToString().ToLower());

            if(alignMode != AlignMode.MiddleCenter)
                image.Filters.Add("anchor", alignMode.ToString().ToLower());

            if(format != ImageFormat.Auto)
                image.Filters.Add("format", format.ToString().ToLower());

            if(quality != 90)
                image.Filters.Add("quality", Math.Min(100, Math.Max(0, quality)));

            if (colors != 256)
                image.Filters.Add("colors", Math.Min(256, Math.Max(2, quality)));

            if (!string.IsNullOrEmpty(bgColor))
                image.Filters.Add("bgcolor", bgColor);

            return image;
        }
开发者ID:TSalaam,项目名称:karbon-cms,代码行数:45,代码来源:FileApiExtensions.cs

示例15: Recorder

    /// <summary>
    /// Constructor
    /// </summary>
    /// <param name="imageFormat">Image Format to save images as</param>
    public Recorder(ImageFormat imageFormat = null)
    {
        if (imageFormat == null)
            return;

        this.imageFormat = imageFormat;
        this.imageExtension = "." + imageFormat.ToString().ToLower();
    }
开发者ID:Nhowka,项目名称:WebMCam,代码行数:12,代码来源:Recorder.cs


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