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


C# Metafile.GetMetafileHeader方法代码示例

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


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

示例1: GetMetafileHeader

	public static MetafileHeader GetMetafileHeader(String fileName)
			{
				Metafile file = new Metafile(fileName);
				MetafileHeader header = file.GetMetafileHeader();
				file.Detach();
				return header;
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:7,代码来源:Metafile.cs

示例2: Metafile

	public static MetafileHeader GetMetafileHeader
				(IntPtr hmetafile, WmfPlaceableFileHeader wmfHeader)
			{
				Metafile file = new Metafile(hmetafile, wmfHeader);
				MetafileHeader header = file.GetMetafileHeader();
				file.Detach();
				return header;
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:8,代码来源:Metafile.cs

示例3: CheckEmptyHeader

		private void CheckEmptyHeader (Metafile mf, EmfType type)
		{
			MetafileHeader mh = mf.GetMetafileHeader ();
			Assert.AreEqual (0, mh.Bounds.X, "Bounds.X");
			Assert.AreEqual (0, mh.Bounds.Y, "Bounds.Y");
			Assert.AreEqual (0, mh.Bounds.Width, "Bounds.Width");
			Assert.AreEqual (0, mh.Bounds.Height, "Bounds.Height");
			Assert.AreEqual (0, mh.MetafileSize, "MetafileSize");
			switch (type) {
			case EmfType.EmfOnly:
				Assert.AreEqual (MetafileType.Emf, mh.Type, "Type");
				break;
			case EmfType.EmfPlusDual:
				Assert.AreEqual (MetafileType.EmfPlusDual, mh.Type, "Type");
				break;
			case EmfType.EmfPlusOnly:
				Assert.AreEqual (MetafileType.EmfPlusOnly, mh.Type, "Type");
				break;
			default:
				Assert.Fail ("Unknown EmfType '{0}'", type);
				break;
			}
		}
开发者ID:nlhepler,项目名称:mono,代码行数:23,代码来源:MetafileTest.cs

示例4: pd_PrintPage

        void pd_PrintPage(object sender, PrintPageEventArgs e)
        {
            //1. Avoid unintended rounding issues
            //   by specifying units directly as 100ths of a mm (GDI)
            //   This can be done by reading directly as a stream with no HDC
            var mf = new Metafile(_PrintingStreams[_PrintingIndex]);

            //2. Apply scaling to correct for dpi differences
            //   E.g. the mf.Width needs the PrintDpiX in order
            //        to be translated to a real width (in mm)
            var mfh = mf.GetMetafileHeader();
            e.Graphics.ScaleTransform(mfh.DpiX / _PrintingDPI.X,
                       mfh.DpiY / _PrintingDPI.Y, MatrixOrder.Prepend);

            //3. Apply scaling to fit to current page by shortest difference
            //   by comparing real page size with available printable area in 100ths of an inch
            var size = new PointF((float)mf.Size.Width / _PrintingDPI.X * 100.0f,
                                  (float)mf.Size.Height / _PrintingDPI.Y * 100.0f);
            size.X = (float)Math.Floor(e.PageSettings.PrintableArea.Width) / size.X;
            size.Y = (float)Math.Floor(e.PageSettings.PrintableArea.Height) / size.Y;
            var scale = Math.Min(size.X, size.Y);
            e.Graphics.ScaleTransform(scale, scale, MatrixOrder.Append);

            //4. Draw the image at the adjusted coordinates
            //   i.e. these are real coordinates so need to reverse the transform that is about
            //        to be applied so that when it is, these real coordinates will be the result.
            var points = new[] { new Point(e.PageSettings.Margins.Left, e.PageSettings.Margins.Top) };
            var matrix = e.Graphics.Transform;
            matrix.Invert();
            matrix.TransformPoints(points);
            //
            e.Graphics.DrawImageUnscaled(mf, points[0]);

            _PrintingIndex++;
            e.HasMorePages = (_PrintingIndex < _PrintingStreams.Count);
        }
开发者ID:itcthienkhiem,项目名称:DienLucHocMonCT,代码行数:36,代码来源:frmReport_The_kho.cs

示例5: GetMetafileHeader_FromFileStream_Emf

		public void GetMetafileHeader_FromFileStream_Emf ()
		{
			using (FileStream fs = File.OpenRead (getInFile (Emf))) {
				using (Metafile mf = new Metafile (fs)) {
					MetafileHeader header1 = mf.GetMetafileHeader ();
					Check_MetafileHeader_Emf (header1);
				}
			}
		}
开发者ID:nlhepler,项目名称:mono,代码行数:9,代码来源:MetafileTest.cs

示例6: GetMetafileHeader_FromMemoryStream_Emf

		public void GetMetafileHeader_FromMemoryStream_Emf ()
		{
			MemoryStream ms;
			string filename = getInFile (Emf);
			using (FileStream fs = File.OpenRead (filename)) {
				byte[] data = new byte[fs.Length];
				fs.Read (data, 0, data.Length);
				ms = new MemoryStream (data);
			}
			using (Metafile mf = new Metafile (ms)) {
				MetafileHeader header1 = mf.GetMetafileHeader ();
				Check_MetafileHeader_Emf (header1);
			}
			ms.Close ();
		}
开发者ID:nlhepler,项目名称:mono,代码行数:15,代码来源:MetafileTest.cs

示例7: GetMetafileHeader_FromFile_Emf

		public void GetMetafileHeader_FromFile_Emf ()
		{
			using (Metafile mf = new Metafile (getInFile (Emf))) {
				MetafileHeader header1 = mf.GetMetafileHeader ();
				Check_MetafileHeader_Emf (header1);
			}
		}
开发者ID:nlhepler,项目名称:mono,代码行数:7,代码来源:MetafileTest.cs

示例8: GetMetafileHeader_FromMemoryStream_WmfPlaceable

		public void GetMetafileHeader_FromMemoryStream_WmfPlaceable ()
		{
			MemoryStream ms;
			string filename = getInFile (WmfPlaceable);
			using (FileStream fs = File.OpenRead (filename)) {
				byte[] data = new byte[fs.Length];
				fs.Read (data, 0, data.Length);
				ms = new MemoryStream (data);
			}
			using (Metafile mf = new Metafile (ms)) {
				MetafileHeader header1 = mf.GetMetafileHeader ();
				Check_MetafileHeader_WmfPlaceable (header1);

				MetaHeader mh1 = header1.WmfHeader;
				Check_MetaHeader_WmfPlaceable (mh1);

				MetaHeader mh2 = mf.GetMetafileHeader ().WmfHeader;
				Assert.IsFalse (Object.ReferenceEquals (mh1, mh2), "Same object");
			}
			ms.Close ();
		}
开发者ID:nlhepler,项目名称:mono,代码行数:21,代码来源:MetafileTest.cs

示例9: GetMetafileHeader_FromFileStream_WmfPlaceable

		public void GetMetafileHeader_FromFileStream_WmfPlaceable ()
		{
			using (FileStream fs = File.OpenRead (getInFile (WmfPlaceable))) {
				using (Metafile mf = new Metafile (fs)) {
					MetafileHeader header1 = mf.GetMetafileHeader ();
					Check_MetafileHeader_WmfPlaceable (header1);

					MetaHeader mh1 = header1.WmfHeader;
					Check_MetaHeader_WmfPlaceable (mh1);

					MetaHeader mh2 = mf.GetMetafileHeader ().WmfHeader;
					Assert.IsFalse (Object.ReferenceEquals (mh1, mh2), "Same object");
				}
			}
		}
开发者ID:nlhepler,项目名称:mono,代码行数:15,代码来源:MetafileTest.cs

示例10: GetMetafileHeader_WmfPlaceable

		public void GetMetafileHeader_WmfPlaceable ()
		{
			using (Metafile mf = new Metafile (getInFile (WmfPlaceable))) {
				MetafileHeader header1 = mf.GetMetafileHeader ();
				Check_MetafileHeader_WmfPlaceable (header1);

				MetafileHeader header2 = mf.GetMetafileHeader ();
				Assert.IsFalse (Object.ReferenceEquals (header1, header2), "Same object");
			}
		}
开发者ID:nlhepler,项目名称:mono,代码行数:10,代码来源:MetafileTest.cs

示例11: send_metafile_to_printer

        private void send_metafile_to_printer(Metafile metafile, PrintPageEventArgs e)
        {

            // constants
            const float unit_factor = 100.0f;

            // prefs
            var desired_printing_dpi = new System.Drawing.SizeF(300.0f, 300.0f);

            // Retrieve metadfile information
            var metafile_header = metafile.GetMetafileHeader();
            var metafile_dpi = new System.Drawing.SizeF(metafile_header.DpiX, metafile_header.DpiY);

            // Based on the orientation command, adjust the printer orientation
            var orient_command = SSRSCommon.PageOrientationCommand.UseDefaultPrinterSetting;

            if (orient_command == SSRSCommon.PageOrientationCommand.ForceLandscape)
            {
                e.PageSettings.Landscape = true;
            }
            else if (orient_command == SSRSCommon.PageOrientationCommand.ForcePortrait)
            {
                e.PageSettings.Landscape = false;
            }
            else if (orient_command == SSRSCommon.PageOrientationCommand.UseDefaultPrinterSetting)
            {
                // do nothing
            }
            else if (orient_command == SSRSCommon.PageOrientationCommand.UseReportDesign)
            {
                bool design_landscape = metafile.Width > metafile.Height;
                e.PageSettings.Landscape = design_landscape;
            }

            // Retrieve information about the printer
            var papersize = new SD.SizeF(e.PageSettings.PaperSize.Width, e.PageSettings.PaperSize.Height);
            //var printable_size = new SD.SizeF(e.PageSettings.PrintableArea.Width, e.PageSettings.PrintableArea.Height);

            // ------------------------------------------------------------------
            // find the metafile size in printer units
            var dpi_factor = metafile_dpi.DivideBy(desired_printing_dpi);
            e.Graphics.ScaleTransform(dpi_factor.Width, dpi_factor.Height, System.Drawing.Drawing2D.MatrixOrder.Prepend);
            var metafile_size_normalized = metafile.Size.ToSizeF().DivideBy(desired_printing_dpi).MultiplyBy(unit_factor);
            var metafile_size_oriented = e.PageSettings.Landscape ? metafile_size_normalized.FlipSides() : metafile_size_normalized;

            // ----------------------------------------------------
            // Calculate the scaling factor to use on the metafile - do we need to shrink it down to fit the page or not.
            
            float scale_to_fit_factor = 1.0f; // 1.0 = don't scale the metafile at all
            if (!metafile_size_normalized.FitsInside(papersize))
            {
                scale_to_fit_factor = papersize.DivideBy(metafile_size_oriented).GetSmallestSide();
            }

            // we now have all the information we need to scale
            e.Graphics.ScaleTransform(scale_to_fit_factor, scale_to_fit_factor, System.Drawing.Drawing2D.MatrixOrder.Append);

            // shift the metafile by hard margin size to aling to the top left side of the paper
            int hm_offset_x = (int) e.PageSettings.HardMarginX*-1;
            int hm_offset_y = (int) e.PageSettings.HardMarginY * -1;
            var hm_offset = new SD.Point(hm_offset_x, hm_offset_y);
            var points = new[] { hm_offset };
            var matrix = e.Graphics.Transform;
            matrix.Invert();
            matrix.TransformPoints(points);

            // --------------------------------------------------------------------
            // Draw the image
            
            e.Graphics.DrawImageUnscaled(metafile, points[0]);
        }
开发者ID:saveenr,项目名称:saveenr,代码行数:71,代码来源:SSRSPrintPreview.cs


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