/// <include file='doc\PrivateFontCollection.uex' path='docs/doc[@for="PrivateFontCollection.AddFontFile"]/*' /> /// <devdoc> /// <para> /// Adds a font from the specified file to /// this <see cref='System.Drawing.Text.PrivateFontCollection'/>. /// </para> /// </devdoc> public void AddFontFile(string filename) { IntSecurity.DemandReadFileIO(filename); int status = SafeNativeMethods.GdipPrivateAddFontFile(new HandleRef(this, nativeFontCollection), filename); if (status != SafeNativeMethods.Ok) { throw SafeNativeMethods.StatusException(status); } }
public void SetOutputChannelColorProfile(string colorProfileFilename, ColorAdjustType type) { IntSecurity.DemandReadFileIO(colorProfileFilename); int status = SafeNativeMethods.Gdip.GdipSetImageAttributesOutputChannelColorProfile(new HandleRef(this, this.nativeImageAttributes), type, true, colorProfileFilename); if (status != 0) { throw SafeNativeMethods.Gdip.StatusException(status); } }
/// <include file='doc\PrivateFontCollection.uex' path='docs/doc[@for="PrivateFontCollection.AddFontFile"]/*' /> /// <devdoc> /// <para> /// Adds a font from the specified file to /// this <see cref='System.Drawing.Text.PrivateFontCollection'/>. /// </para> /// </devdoc> public void AddFontFile(string filename) { IntSecurity.DemandReadFileIO(filename); int status = SafeNativeMethods.Gdip.GdipPrivateAddFontFile(new HandleRef(this, nativeFontCollection), filename); if (status != SafeNativeMethods.Gdip.Ok) { throw SafeNativeMethods.Gdip.StatusException(status); } // Register private font with GDI as well so pure GDI-based controls (TextBox, Button for instance) can access it. SafeNativeMethods.AddFontFile(filename); }
public Metafile(string filename) { IntSecurity.DemandReadFileIO(filename); IntPtr metafile = IntPtr.Zero; int status = SafeNativeMethods.Gdip.GdipCreateMetafileFromFile(filename, out metafile); if (status != SafeNativeMethods.Gdip.Ok) { throw SafeNativeMethods.Gdip.StatusException(status); } SetNativeImage(metafile); }
/// <include file='doc\Metafile.uex' path='docs/doc[@for="Metafile.Metafile17"]/*' /> /// <devdoc> /// <para> /// Initializes a new instance of the <see cref='System.Drawing.Imaging.Metafile'/> class with the specified filename. /// </para> /// </devdoc> public Metafile(string fileName, IntPtr referenceHdc, EmfType type, String description) { IntSecurity.DemandReadFileIO(fileName); IntSecurity.ObjectFromWin32Handle.Demand(); IntPtr metafile = IntPtr.Zero; int status = SafeNativeMethods.GdipRecordMetafileFileName(fileName, new HandleRef(null, referenceHdc), (int)type, NativeMethods.NullHandleRef, (int)MetafileFrameUnit.GdiCompatible, description, out metafile); if (status != SafeNativeMethods.Ok) { throw SafeNativeMethods.StatusException(status); } SetNativeImage(metafile); }
/// <include file='doc\Metafile.uex' path='docs/doc[@for="Metafile.Metafile22"]/*' /> /// <devdoc> /// <para> /// Initializes a new instance of the <see cref='System.Drawing.Imaging.Metafile'/> class with the /// specified filename. /// </para> /// </devdoc> public Metafile(string fileName, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, EmfType type, String description) { IntSecurity.DemandReadFileIO(fileName); IntSecurity.ObjectFromWin32Handle.Demand(); IntPtr metafile = IntPtr.Zero; GPRECTF rectf = new GPRECTF(frameRect); int status = SafeNativeMethods.GdipRecordMetafileFileName(fileName, new HandleRef(null, referenceHdc), (int)type, ref rectf, (int)frameUnit, description, out metafile); if (status != SafeNativeMethods.Ok) { throw SafeNativeMethods.StatusException(status); } SetNativeImage(metafile); }
public static MetafileHeader GetMetafileHeader(string fileName) { IntSecurity.DemandReadFileIO(fileName); MetafileHeader header = new MetafileHeader(); IntPtr memory = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(MetafileHeaderEmf))); try { int status = SafeNativeMethods.Gdip.GdipGetMetafileHeaderFromFile(fileName, memory); if (status != SafeNativeMethods.Gdip.Ok) { throw SafeNativeMethods.Gdip.StatusException(status); } int[] type = new int[] { 0 }; Marshal.Copy(memory, type, 0, 1); MetafileType metafileType = (MetafileType)type[0]; if (metafileType == MetafileType.Wmf || metafileType == MetafileType.WmfPlaceable) { // WMF header header.wmf = (MetafileHeaderWmf)UnsafeNativeMethods.PtrToStructure(memory, typeof(MetafileHeaderWmf)); header.emf = null; } else { // EMF header header.wmf = null; header.emf = (MetafileHeaderEmf)UnsafeNativeMethods.PtrToStructure(memory, typeof(MetafileHeaderEmf)); } } finally { Marshal.FreeHGlobal(memory); } return(header); }
public Metafile(string fileName, IntPtr referenceHdc, Rectangle frameRect, MetafileFrameUnit frameUnit, EmfType type, string description) { IntSecurity.DemandReadFileIO(fileName); IntSecurity.ObjectFromWin32Handle.Demand(); IntPtr metafile = IntPtr.Zero; int status; if (frameRect.IsEmpty) { status = SafeNativeMethods.Gdip.GdipRecordMetafileFileName(fileName, new HandleRef(null, referenceHdc), unchecked ((int)type), NativeMethods.NullHandleRef, unchecked ((int)frameUnit), description, out metafile); } else { GPRECT gprect = new GPRECT(frameRect); status = SafeNativeMethods.Gdip.GdipRecordMetafileFileNameI(fileName, new HandleRef(null, referenceHdc), unchecked ((int)type), ref gprect, unchecked ((int)frameUnit), description, out metafile); } if (status != SafeNativeMethods.Gdip.Ok) { throw SafeNativeMethods.Gdip.StatusException(status); } SetNativeImage(metafile); }