void PrintDeviceContext(GDIContext dc) { DeviceTechnology tech = dc.TypeOfDevice; GDIRasterCapabilities rastercaps = dc.RasterCapabilities; GDITextCapabilities textcaps = dc.TextCapabilities; }
public static void Draw(GDIContext dc, ControlRenderingStyle renderStyle, Rectangle rect) { RECT aRect = new RECT(rect.X, rect.Y, rect.Width, rect.Height); User32.DrawFrameControl(dc, ref aRect, (int)renderStyle.ControlCategory, renderStyle.ControlType | (int)renderStyle.StateModifiers); }
public Form1() { InitializeComponent(); // Get the right device context fDeviceContext = GDIContext.CreateForWindowClientArea(this.Handle); // This is fairly fast for the window //fDeviceContext = GDIContext.CreateForDesktopBackground(); // This one is the desktop background and is fast //fDeviceContext = GDIContext.CreateForDefaultDisplay(); // This one is way slow on Vista fChannel = new GDIRenderer(fDeviceContext); fDemoCounter = 0; //this.Text = "PixTour"; bezierer = new BezierTest(ClientRectangle.Size); aTextTest = new TextTest(ClientRectangle.Size); PrintDeviceContext(fDeviceContext); }
GraphPortChunkEncoder fCommandDispatcher; // Used to do PixBlt to the net #endregion public DesktopCapture(ConferenceAttendee attendee) { fAttendee = attendee; fContext = GDIContext.CreateForDefaultDisplay(); //fCommandDispatcher = new GraphPortChunkEncoder(attendee); int width = 800; int height = 600; fResolution = new Resolution(width, height); fScreenImage = new GDIDIBSection(width, height); fGrayImage = new PixelArray<Lumb>(width, height, fScreenImage.Orientation, new Lumb()); // Start the thread that will take snapshots of the screen fGlobalTimer = new PrecisionTimer(); fFrameRate = 10; // Frames per second fSnapperRunning = true; fSnapperThread = new Thread(RunSnaps); // WAA //fSnapperThread.Start(); }
public static uint SelectFont(GDIContext hdc, System.Drawing.Font font) { GDI32.SelectObject(hdc, font.ToHfont()); uint size = GDI32.GetOutlineTextMetrics(hdc, 0, IntPtr.Zero); if (size != uint.MaxValue) { UnmanagedMemory otm = new UnmanagedMemory((int)size); uint err = GDI32.GetOutlineTextMetrics(hdc, size, otm.MemoryPointer); uint otmEMSquare = (uint)Marshal.ReadInt32(otm, 92); otm.Dispose(); LOGFONT log = new LOGFONT(); font.ToLogFont(log); log.lfHeight = -(int)otmEMSquare; font = System.Drawing.Font.FromLogFont(log); GDI32.SelectObject(hdc, font.ToHfont()); } return size; }
public static bool IsTrueType(GDIContext hdc, System.Drawing.Font font) { GDI32.SelectObject(hdc, font.ToHfont()); UnmanagedMemory tmPtr = new UnmanagedMemory(Marshal.SizeOf(typeof(TEXTMETRIC))); uint err = GDI32.GetTextMetrics(hdc, tmPtr.MemoryPointer); TEXTMETRIC tm = (TEXTMETRIC)Marshal.PtrToStructure(tmPtr.MemoryPointer, typeof(TEXTMETRIC)); tmPtr.Dispose(); return (tm.tmPitchAndFamily & 4) != 0; }
public static ushort GetGlyph(GDIContext hdc, uint uchar, out float2[] pnts, out sbyte[] onCurve, out short advanceWidth) { MAT2 mat = new MAT2(); IntPtr matPtr = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(MAT2))); Marshal.StructureToPtr(mat, matPtr, true); IntPtr gmPtr = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(GLYPHMETRICS))); int sz = GDI32.GetGlyphOutline(hdc, uchar, GDI32.GGO_NATIVE, gmPtr, 0, IntPtr.Zero, matPtr); GLYPHMETRICS gm = (GLYPHMETRICS)Marshal.PtrToStructure(gmPtr, typeof(GLYPHMETRICS)); advanceWidth = gm.gmCellIncX; IntPtr gbufPtr = Marshal.AllocCoTaskMem(sz); int err0 = GDI32.GetGlyphOutline(hdc, uchar, GDI32.GGO_NATIVE, gmPtr, sz, gbufPtr, matPtr); return GetOutline(new UnmanagedPointer(gbufPtr), sz, out pnts, out onCurve); }