當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。