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


C# ImageFormat.ToString方法代码示例

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


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

示例1: PathCreator

        public PathCreator(string urlBase, ImageFormat extension, string tempFolder, string staticFolder)
        {
            UrlBase = urlBase.Replace('\\', '/');

            TempRootFolder = tempFolder;
            TempFolderFormat = null;
            TempNameFormat = "{0}{1}." + extension.ToString().ToLower();

            StaticRootFolder = staticFolder;
            StaticFolderFormat = null;
            StaticNameFormat = "{0}." + extension.ToString().ToLower();
        }
开发者ID:RodionKulin,项目名称:ContentManagementBackend,代码行数:12,代码来源:PathCreator.cs

示例2: ShowQRCode

 /// <summary>
 /// Opens up a generated image containing a QR-code within which
 /// str is encoded.
 /// 
 /// The image can be found inside the bin folder.
 /// </summary>
 /// <param name="str">Content of the generated QR-code</param>
 /// <param name="width">Width of the image</param>
 /// <param name="height">Height of the image</param>
 /// <param name="format">Format of the image file</param>
 public static void ShowQRCode(string str, int width, int height, ImageFormat format)
 {
     Bitmap bmp = GenerateQRC(str, width, height);
     string address = @"..\AdrportQR." + format.ToString();
     bmp.Save(address, format);
     System.Diagnostics.Process.Start(address);
 }
开发者ID:gustavAR,项目名称:Spang,代码行数:17,代码来源:QRCodeGenerator.cs

示例3: ConvertWordToImage

        /// <summary>
        /// 将Word文档转换为图片的方法(该方法基于第三方DLL),你可以像这样调用该方法:
        /// ConvertPDF2Image("F:\\PdfFile.doc", "F:\\", "ImageFile", 1, 20, ImageFormat.Png, 256);
        /// </summary>
        /// <param name="pdfInputPath">Word文件路径</param>
        /// <param name="imageOutputPath">图片输出路径,如果为空,默认值为Word所在路径</param>
        /// <param name="imageName">图片的名字,不需要带扩展名,如果为空,默认值为Word的名称</param>
        /// <param name="startPageNum">从PDF文档的第几页开始转换,如果为0,默认值为1</param>
        /// <param name="endPageNum">从PDF文档的第几页开始停止转换,如果为0,默认值为Word总页数</param>
        /// <param name="imageFormat">设置所需图片格式,如果为null,默认格式为PNG</param>
        /// <param name="resolution">设置图片的像素,数字越大越清晰,如果为0,默认值为128,建议最大值不要超过1024</param>
        public static void ConvertWordToImage(string wordInputPath, string imageOutputPath,
            string imageName, int startPageNum, int endPageNum, ImageFormat imageFormat, float resolution)
        {
            try
            {
                // open word file
                Aspose.Words.Document doc = new Aspose.Words.Document(wordInputPath);

                // validate parameter
                if (doc == null) { throw new Exception("Word文件无效或者Word文件被加密!"); }
                if (imageOutputPath.Trim().Length == 0) { imageOutputPath = Path.GetDirectoryName(wordInputPath); }
                if (!Directory.Exists(imageOutputPath)) { Directory.CreateDirectory(imageOutputPath); }
                if (imageName.Trim().Length == 0) { imageName = Path.GetFileNameWithoutExtension(wordInputPath); }
                if (startPageNum <= 0) { startPageNum = 1; }
                if (endPageNum > doc.PageCount || endPageNum <= 0) { endPageNum = doc.PageCount; }
                if (startPageNum > endPageNum) { int tempPageNum = startPageNum; startPageNum = endPageNum; endPageNum = startPageNum; }
                if (imageFormat == null) { imageFormat = ImageFormat.Png; }
                if (resolution <= 0) { resolution = 128; }

                ImageSaveOptions imageSaveOptions = new ImageSaveOptions(GetSaveFormat(imageFormat));
                imageSaveOptions.Resolution = resolution;

                // start to convert each page
                for (int i = startPageNum; i <= endPageNum; i++)
                {
                    imageSaveOptions.PageIndex = i - 1;
                    doc.Save(Path.Combine(imageOutputPath, imageName) + "_" + i.ToString() + "." + imageFormat.ToString(), imageSaveOptions);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
开发者ID:alqadasifathi,项目名称:OfficeTools.Pdf2Image.Word2Image,代码行数:45,代码来源:Program.cs

示例4: Set

        public static void Set(Uri uri, Style style, ImageFormat format)
        {
            Stream stream = new WebClient().OpenRead(uri.ToString());

            if (stream == null) return;

            Image img = Image.FromStream(stream);
            string tempPath = Path.Combine(Path.GetTempPath(), "img." + format.ToString());
            img.Save(tempPath, format);

            RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Control Panel\Desktop", true);
            if (style == Style.Stretched)
            {
                key.SetValue(@"WallpaperStyle", 2.ToString());
                key.SetValue(@"TileWallpaper", 0.ToString());
            }

            if (style == Style.Centered)
            {
                key.SetValue(@"WallpaperStyle", 1.ToString());
                key.SetValue(@"TileWallpaper", 0.ToString());
            }

            if (style == Style.Tiled)
            {
                key.SetValue(@"WallpaperStyle", 1.ToString());
                key.SetValue(@"TileWallpaper", 1.ToString());
            }

            SystemParametersInfo(SpiSetdeskwallpaper,
                0,
                tempPath,
                SpifUpdateinifile | SpifSendwininichange);
        }
开发者ID:ashesxera,项目名称:Unsplasher,代码行数:34,代码来源:Wallpaper.cs

示例5: SetUp

		public void SetUp ()		
		{
			imageFmt = ImageFormat.Bmp; 
			imageFmtStr = imageFmt.ToString ();
		
			imgFmtConv = new ImageFormatConverter();
			imgFmtConvFrmTD = (ImageFormatConverter) TypeDescriptor.GetConverter (imageFmt);			
		}
开发者ID:nlhepler,项目名称:mono,代码行数:8,代码来源:TestImageFormatConverter.cs

示例6: FormShowFrames

        public FormShowFrames(string framesPath, ImageFormat imageFormat, bool allowDeletion = true)
        {
            this.framesPath = framesPath;
            this.imageExtension = "." + imageFormat.ToString().ToLower();
            this.allowDeletion = allowDeletion;

            InitializeComponent();
        }
开发者ID:Nhowka,项目名称:WebMCam,代码行数:8,代码来源:FormShowFrames.cs

示例7: ConvertPDF2Image

        /// <summary>
        /// 将PDF文档转换为图片的方法,你可以像这样调用该方法:ConvertPDF2Image("F:\\A.pdf", "F:\\", "A", 0, 0, null, 0);
        /// 因为大多数的参数都有默认值,startPageNum默认值为1,endPageNum默认值为总页数,
        /// imageFormat默认值为ImageFormat.Jpeg,resolution默认值为1
        /// </summary>
        /// <param name="pdfInputPath">PDF文件路径</param>
        /// <param name="imageOutputPath">图片输出路径</param>
        /// <param name="imageName">图片的名字,不需要带扩展名</param>
        /// <param name="startPageNum">从PDF文档的第几页开始转换,默认值为1</param>
        /// <param name="endPageNum">从PDF文档的第几页开始停止转换,默认值为PDF总页数</param>
        /// <param name="imageFormat">设置所需图片格式</param>
        /// <param name="resolution">设置图片的分辨率,数字越大越清晰,默认值为1</param>
        public static void ConvertPDF2Image(string pdfInputPath, string imageOutputPath,
            string imageName, int startPageNum, int endPageNum, ImageFormat imageFormat, double resolution)
        {
            Acrobat.CAcroPDDoc pdfDoc = null;
            Acrobat.CAcroPDPage pdfPage = null;
            Acrobat.CAcroRect pdfRect = null;
            Acrobat.CAcroPoint pdfPoint = null;

            // Create the document (Can only create the AcroExch.PDDoc object using late-binding)
            // Note using VisualBasic helper functions, have to add reference to DLL
            pdfDoc = (Acrobat.CAcroPDDoc)Microsoft.VisualBasic.Interaction.CreateObject("AcroExch.PDDoc", "");

            // validate parameter
            if (!pdfDoc.Open(pdfInputPath)) { throw new FileNotFoundException(); }
            if (!Directory.Exists(imageOutputPath)) { Directory.CreateDirectory(imageOutputPath); }
            if (startPageNum <= 0) { startPageNum = 1; }
            if (endPageNum > pdfDoc.GetNumPages() || endPageNum <= 0) { endPageNum = pdfDoc.GetNumPages(); }
            if (startPageNum > endPageNum) { int tempPageNum = startPageNum; startPageNum = endPageNum; endPageNum = startPageNum; }
            if (imageFormat == null) { imageFormat = ImageFormat.Jpeg; }
            if (resolution <= 0) { resolution = 1; }

            // start to convert each page
            for (int i = startPageNum; i <= endPageNum; i++)
            {
                pdfPage = (Acrobat.CAcroPDPage)pdfDoc.AcquirePage(i - 1);
                pdfPoint = (Acrobat.CAcroPoint)pdfPage.GetSize();
                pdfRect = (Acrobat.CAcroRect)Microsoft.VisualBasic.Interaction.CreateObject("AcroExch.Rect", "");

                int imgWidth = (int)((double)pdfPoint.x * resolution);
                int imgHeight = (int)((double)pdfPoint.y * resolution);

                pdfRect.Left = 0;
                pdfRect.right = (short)imgWidth;
                pdfRect.Top = 0;
                pdfRect.bottom = (short)imgHeight;

                // Render to clipboard, scaled by 100 percent (ie. original size)
                // Even though we want a smaller image, better for us to scale in .NET
                // than Acrobat as it would greek out small text
                pdfPage.CopyToClipboard(pdfRect, 0, 0, (short)(100 * resolution));

                IDataObject clipboardData = Clipboard.GetDataObject();

                if (clipboardData.GetDataPresent(DataFormats.Bitmap))
                {
                    Bitmap pdfBitmap = (Bitmap)clipboardData.GetData(DataFormats.Bitmap);
                    pdfBitmap.Save(Path.Combine(imageOutputPath, imageName) + i.ToString() + "." + imageFormat.ToString(), imageFormat);
                    pdfBitmap.Dispose();
                }
            }

            pdfDoc.Close();
            Marshal.ReleaseComObject(pdfPage);
            Marshal.ReleaseComObject(pdfRect);
            Marshal.ReleaseComObject(pdfDoc);
            Marshal.ReleaseComObject(pdfPoint);

        }
开发者ID:alqadasifathi,项目名称:OfficeTools.Pdf2Image.Word2Image,代码行数:70,代码来源:Program.cs

示例8: ByImageFormat

		public static ImageTypeMapping ByImageFormat(ImageFormat imageFormat)
		{
			ImageTypeMapping imageTypeMapping = ImageTypeMapper.mappings.Find((ImageTypeMapping candidate) => candidate.ImageFormatEquals(imageFormat));
			if (imageTypeMapping == null)
			{
				throw new UnknownImageTypeException(imageFormat.ToString());
			}
			return imageTypeMapping;
		}
开发者ID:mikhp,项目名称:greatmaps,代码行数:9,代码来源:ImageTypeMapper.cs

示例9: ScreenShot

 /// <summary>
 /// コンストラクタ。
 /// </summary>
 public ScreenShot()
 {
     _dir = Option.Instance().SaveDirectory;
     _fileFmt = Option.Instance().FileNameFormat;
     _imgFmt = Option.Instance().ImageFormat;
     // 拡張子を設定する。Jpegの場合は"jpg"、それ以外は名称をそのままに小文字に変換している。
     _ext = _imgFmt.Equals(ImageFormat.Jpeg) ? "jpg" : _imgFmt.ToString().ToLower();
     _matches = Rx.Matches(_fileFmt);
 }
开发者ID:rabbitka,项目名称:RabiShot,代码行数:12,代码来源:ScreenShot.cs

示例10: SearchingKeyInImgFormats

 public static string SearchingKeyInImgFormats(ImageFormat value)
 {
     var resultKey = value.ToString();
     foreach(var el in ImgFormats)
     {
         if (value == el.Value)
             resultKey = el.Key;
     }
     return resultKey;
 }
开发者ID:UNIT6-open,项目名称:TWAIN-Web,代码行数:10,代码来源:GlobalDictionaries.cs

示例11: SaveImage

 public String SaveImage(string title, ImageFormat format)
 {
     string pathTmp = "";
     count++;
     if (bitmap != null)
     {
         Console.Write(format.ToString());
         pathTmp = @"c:\\saves\\" + title + "\\" + count + ".jpeg";
         bitmap.Save(pathTmp, ImageFormat.Jpeg);
     }
     return pathTmp;
 }
开发者ID:raymonnetje,项目名称:ImageDownloader,代码行数:12,代码来源:Downloader.cs

示例12: GetExtensionFromImageFormat

 /// <summary>
 /// Returns the correct file extension for the given <see cref="T:System.Drawing.Imaging.ImageFormat"/>.
 /// </summary>
 /// <param name="imageFormat">
 /// The <see cref="T:System.Drawing.Imaging.ImageFormat"/> to return the extension for.
 /// </param>
 /// <returns>
 /// The correct file extension for the given <see cref="T:System.Drawing.Imaging.ImageFormat"/>.
 /// </returns>
 public static string GetExtensionFromImageFormat(ImageFormat imageFormat)
 {
     switch (imageFormat.ToString())
     {
         case "Gif":
             return ".gif";
         case "Bmp":
             return ".bmp";
         case "Png":
             return ".png";
         default:
             return ".jpg";
     }
 }
开发者ID:hputtick,项目名称:ImageProcessor,代码行数:23,代码来源:ImageUtils.cs

示例13: ToBase64ImageTag

        public static string ToBase64ImageTag(this Bitmap bmp, ImageFormat imageFormat)
        {
            string imgTag = string.Empty;
            string base64String = string.Empty;

            base64String = bmp.ToBase64String(imageFormat);

            imgTag = "<img src=\"data:image/" + imageFormat.ToString() + ";base64,";
            imgTag += base64String + "\" ";
            imgTag += "width=\"" + bmp.Width.ToString() + "\" ";
            imgTag += "height=\"" + bmp.Height.ToString() + "\" />";

            return imgTag;
        }
开发者ID:JiaMauJian,项目名称:doitwelltemp,代码行数:14,代码来源:ExtBitmap.cs

示例14: SaveFractalImage

        public void SaveFractalImage(ImageFormat format,string name)
        {
            if(_renderViewPresenter.ActualFractalImage != null)
            {
                FolderBrowserDialog d = new FolderBrowserDialog();
                if (d.ShowDialog() == DialogResult.OK)
                {
                    string savePath = string.Format("{0}\\{1}.{2}",
                        d.SelectedPath,
                        name,
                        format.ToString());

                    _renderViewPresenter.ActualFractalImage.Save(savePath);
                }
            }
        }
开发者ID:Astrocyt,项目名称:Fractal,代码行数:16,代码来源:PropertiesViewPresenter.cs

示例15: DetermineFileExtension

 /// <summary>
 /// ImageFormatから拡張子を求める。
 /// </summary>
 public static string DetermineFileExtension(ImageFormat format)
 {
     try
     {
         return ImageCodecInfo.GetImageEncoders()
                 .First(x => x.FormatID == format.Guid)
                 .FilenameExtension
                 .Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries)
                 .First()
                 .Trim('*')
                 .ToLower();
     }
     catch (Exception)
     {
         return "." + format.ToString().ToLower();
     }
 }
开发者ID:ymisono,项目名称:VBReportSample,代码行数:20,代码来源:DrawingHelper.cs


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