當前位置: 首頁>>代碼示例>>C#>>正文


C# Metafile.Save方法代碼示例

本文整理匯總了C#中System.Drawing.Imaging.Metafile.Save方法的典型用法代碼示例。如果您正苦於以下問題:C# Metafile.Save方法的具體用法?C# Metafile.Save怎麽用?C# Metafile.Save使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Drawing.Imaging.Metafile的用法示例。


在下文中一共展示了Metafile.Save方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: SaveClipboardEmf

        private static void SaveClipboardEmf(Stream stream, ImageFormat format)
        {
            OpenClipboard();

            try
            {
                if (!IsClipboardFormatAvailable(CF_ENHMETAFILE))
                {
                    Failed("No enhanced metafile data available.");
                }

                IntPtr ptr = GetClipboardData(CF_ENHMETAFILE);

                if (ptr == IntPtr.Zero)
                {
                    Failed("Unable to retrieve data from clipboard even through Clipboard previously indicated data exists.");
                }

                var metafile = new Metafile(ptr, true);
                metafile.Save(stream, format);
            }
            finally
            {
                // "An application should call the CloseClipboard function after every successful call to OpenClipboard."
                //   -- http://msdn.microsoft.com/en-us/library/windows/desktop/ms649048(v=vs.85).aspx
                CloseClipboard();
            }
        }
開發者ID:eHanlin,項目名稱:Hanlin.Common,代碼行數:28,代碼來源:ClipboardHelper.cs

示例2: saveAsImageFile

 void saveAsImageFile()
 {
     if (File.Exists(m_strTreeFile))
     {
         Graphics grfx = CreateGraphics();
         IntPtr ipHdc = grfx.GetHdc();
         string strMetafile = createFileName("emf");
         mf = new Metafile(strMetafile, ipHdc);
         grfx.ReleaseHdc(ipHdc);
         grfx.Dispose();
         Graphics grfxMF = Graphics.FromImage(mf);
         grfxMF.PageUnit = GraphicsUnit.Millimeter;
         grfxMF.PageScale = .01f;
         SolidBrush brush = new SolidBrush(tree.BackgroundColor);
         PointF pf = new PointF(0f, 0f);
         if (Environment.OSVersion.Platform == PlatformID.Win32Windows)
         {   // adjust because Win98 is extra high (for some reason...)
             pf.Y = grfxMF.DpiY / .254f;
         }
         if (tree.TrySmoothing && tree.TryPixelOffset)
             tree.XSize += 6; // adjust for the pixel offset
         grfxMF.FillRectangle(brush, 0, 0, tree.XSize, tree.YSize + (int)pf.Y);
         tree.Draw(grfxMF, tree.LinesColor);
         brush.Dispose();
         grfxMF.Dispose();
         string strFile;
         if (m_bUseBmp)
         {
             strFile = createFileName("bmp");
             mf.Save(strFile, ImageFormat.Bmp);
         }
         if (m_bUseGif)
         {
             strFile = createFileName("gif");
             mf.Save(strFile, ImageFormat.Gif);
         }
         if (m_bUseJpg)
         {
             strFile = createFileName("jpg");
             mf.Save(strFile, ImageFormat.Jpeg);
         }
         if (m_bUsePng)
         {
             strFile = createFileName("png");
             mf.Save(strFile, ImageFormat.Png);
         }
         if (m_bUseTif)
         {
             strFile = createFileName("tif");
             mf.Save(strFile, ImageFormat.Tiff);
         }
         mf.Dispose();
         if (!m_bUseEmf)
             File.Delete(strMetafile);
     }
 }
開發者ID:cdyangupenn,項目名稱:CarlaLegacy,代碼行數:56,代碼來源:LingTree.cs

示例3: AddPictire

		void AddPictire(Plan plan, surfacesSurfaceLayerElementsElement innerElement, ref int pictureIndex)
		{
			try
			{
				if (innerElement.picture == null)
					return;

				foreach (var innerPicture in innerElement.picture)
				{
					if (string.IsNullOrEmpty(innerPicture.idx))
						innerPicture.idx = pictureIndex++.ToString();

					var picturesDirectory = GetPicturesDirectory();
					if (picturesDirectory == null)
						continue;
					var directoryInfo = new DirectoryInfo(picturesDirectory + "\\Sample" + innerPicture.idx + "." + innerPicture.ext);
					if (File.Exists(directoryInfo.FullName) == false)
						continue;

					if (innerPicture.ext == "emf")
					{
						var metafile = new Metafile(directoryInfo.FullName);
						innerPicture.ext = "bmp";
						directoryInfo = new DirectoryInfo(picturesDirectory + "\\Sample" + innerPicture.idx + "." + innerPicture.ext);
						metafile.Save(directoryInfo.FullName, ImageFormat.Bmp);
						metafile.Dispose();
					}

					var guid = ServiceFactoryBase.ContentService.AddContent(directoryInfo.FullName);
					var elementRectanglePicture = new ElementRectangle()
					{
						Left = Parse(innerElement.rect[0].left),
						Top = Parse(innerElement.rect[0].top),
						Height = Parse(innerElement.rect[0].bottom) - Parse(innerElement.rect[0].top),
						Width = Parse(innerElement.rect[0].right) - Parse(innerElement.rect[0].left),
					};

					if ((elementRectanglePicture.Left == 0) && (elementRectanglePicture.Top == 0) && (elementRectanglePicture.Width == plan.Width) && (elementRectanglePicture.Height == plan.Height))
					{
						plan.BackgroundImageSource = guid;
						plan.BackgroundSourceName = directoryInfo.FullName;
					}
					else
					{
						elementRectanglePicture.BackgroundImageSource = guid;
						elementRectanglePicture.BackgroundSourceName = directoryInfo.FullName;
						plan.ElementRectangles.Add(elementRectanglePicture);
					}
				}
			}
			catch (Exception e)
			{
				Logger.Error(e, "ConfigurationConverter.AddPictire");
			}
		}
開發者ID:saeednazari,項目名稱:Rubezh,代碼行數:55,代碼來源:ConfigurationConverter.PlansConverter.cs

示例4: AddPictire

        void AddPictire(Plan plan, surfacesSurfaceLayerElementsElement innerElement, ref int pictureIndex)
        {
            foreach (var innerPicture in innerElement.picture)
            {
                if (string.IsNullOrEmpty(innerPicture.idx))
                    innerPicture.idx = pictureIndex++.ToString();

                var directoryInfo = new DirectoryInfo(Environment.CurrentDirectory + "\\Pictures\\Sample" + innerPicture.idx + "." + innerPicture.ext);
                if (File.Exists(directoryInfo.FullName) == false)
                    continue;

                if (innerPicture.ext == "emf")
                {
                    var metafile = new Metafile(directoryInfo.FullName);
                    innerPicture.ext = "bmp";
                    directoryInfo = new DirectoryInfo(Environment.CurrentDirectory + "\\Pictures\\Sample" + innerPicture.idx + "." + innerPicture.ext);
                    metafile.Save(directoryInfo.FullName, ImageFormat.Bmp);
                    metafile.Dispose();
                }

                byte[] backgroundPixels = File.ReadAllBytes(directoryInfo.FullName);

                var elementRectanglePicture = new ElementRectangle()
                {
                    Left = Parse(innerElement.rect[0].left),
                    Top = Parse(innerElement.rect[0].top),
                    Height = Parse(innerElement.rect[0].bottom) - Parse(innerElement.rect[0].top),
                    Width = Parse(innerElement.rect[0].right) - Parse(innerElement.rect[0].left),
                    BackgroundPixels = backgroundPixels
                };

                if ((elementRectanglePicture.Left == 0) && (elementRectanglePicture.Top == 0) && (elementRectanglePicture.Width == plan.Width) && (elementRectanglePicture.Height == plan.Height))
                {
                    plan.BackgroundPixels = elementRectanglePicture.BackgroundPixels;
                }
                else
                {
                    plan.ElementRectangles.Add(elementRectanglePicture);
                }
            }
        }
開發者ID:hjlfmy,項目名稱:Rubezh,代碼行數:41,代碼來源:ConfigurationConverter.PlansConverter.cs


注:本文中的System.Drawing.Imaging.Metafile.Save方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。