当前位置: 首页>>代码示例>>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;未经允许,请勿转载。