Inheritance: GDIInfoContext
Ejemplo n.º 1
0
        public PGDIRenderer(GDIContext gdi)
        {
            Graphics = new GDIRenderer(gdi);

            HollowBrush = new GDIBrush(BrushStyle.Hollow, HatchStyle.Horizontal, (Colorref)0, Guid.NewGuid());

            Graphics.UseDefaultPen();
            Graphics.UseDefaultBrush();
        }
Ejemplo n.º 2
0
        public static GDIContext CreateForDisplay(string displayName)
        {
            IntPtr hdc = IntPtr.Zero;

            hdc = GDI32.CreateDC("DISPLAY", displayName, null, IntPtr.Zero);
            GDIContext newContext = new GDIContext(hdc, true);

            return newContext;
        }
Ejemplo n.º 3
0
        public static GDIContext CreateForDevice(string device, string name)
        {
            IntPtr hdc = IntPtr.Zero;

            hdc = GDI32.CreateDC(device, name, null, IntPtr.Zero);
            GDIContext newContext = new GDIContext(hdc, true);

            return newContext;
        }
Ejemplo n.º 4
0
        protected GDIPixmap(int width, int height, BitCount bitsperpixel)
            : base(IntPtr.Zero, true)
        {
            if (bitsperpixel == BitCount.Bits24)
                RectInfo = new PixelRectangleInfo(width, height, PixelLayout.Bgr, PixelComponentType.Byte, Alignment);
            else
                RectInfo = new PixelRectangleInfo(width, height, PixelLayout.Bgra, PixelComponentType.Byte, Alignment);
            
            this.fBitCount = bitsperpixel;
    
            GDIContext context = GDIContext.CreateForDefaultDisplay();

            IntPtr theHandle = CreatePixmapHandle(Width, Height, bitsperpixel);
            SetHandle(theHandle);

            fMemoryContext = GDIContext.CreateForMemory();
            m_OldBMHandle = fMemoryContext.SelectObject(this);

           
        }
Ejemplo n.º 5
0
        public Form1()
            :base("GDI Video", 10, 10, 1024, 480)
        {
            fScreenContext = GDIContext.CreateForDefaultDisplay();

            fCamera = new VfwCameraDevice(0, 320, 240, 15, User32.WS_CHILD | User32.WS_VISIBLE, this.Handle);
            //fCamera = new VfwCameraDevice(320, 240);
            fCamera.FrameDelegate = FrameReceived;
            fBitmapInfo = fCamera.GetBitmapInfo();

            fDecompressor = VfwDeCompressor.Create(Vfw.ICTYPE_VIDEO);

            // Allocate a pixel buffer to receive decompressed bits
            //fPixelBuffer = new PixelBuffer24(fCamera.Width, fCamera.Height);

            //fCamera.StartStreaming();
            fCamera.PreviewRate = 33;
            //fCamera.ShowPreviewWindow();

            fCaptureDispatcher = new TimedDispatcher(1.0 / 15, CaptureFrame, null);
            fCaptureDispatcher.Start();
        }
Ejemplo n.º 6
0
        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;
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
0
 public GDIView(GDIContext dc)
 {
     fDeviceContext = dc;
 }
Ejemplo n.º 9
0
 internal GDIInfoContext(GDIContext aDC)
     : this(GDI32.CreateCompatibleDC(aDC), true)
 {
 }
Ejemplo n.º 10
0
        // get the combined world to device coordinate space mapping
        public bool GetDPtoLP(GDIContext hDC)
        {
            if (!GDI32.GetWorldTransform(hDC, out fMatrix))
                return false;

            POINT origin = new POINT();
            GDI32.GetWindowOrgEx(hDC, out origin);
            Translate(-(float)origin.X, -(float)origin.Y);

            SIZE sizew = new SIZE();
            SIZE sizev = new SIZE();
            GDI32.GetWindowExtEx(hDC, out sizew);
            GDI32.GetViewportExtEx(hDC, out sizev);

            Scale((float)sizew.Width / sizev.Height, (float)sizew.Height / sizev.Height);

            GDI32.GetViewportOrgEx(hDC, out origin);
            Translate((float)origin.X, (float)origin.Y);

            return true;
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Create a GDIContext so that drawing to the desktop can occur.
        /// On Vista, the drawing will be behind all windows, but will draw on top
        /// of any icons on the actual desktop.
        /// For Windows XP, the drawing will be behind those icons as well.
        /// </summary>
        /// <returns>The Device Context for drawing to the desktop background.</returns>
        public static GDIContext CreateForDesktopBackground()
        {
            IntPtr hDC = IntPtr.Zero;

            // First get a handle on the Program Manager window using FindWindow
            IntPtr hProgMan = User32.FindWindow("ProgMan", null);

            if (IntPtr.Zero != hProgMan)
            {
                // The only child of this window is the Shell Window
                // So get that handle.
                IntPtr hShellView = User32.GetWindow(hProgMan, User32.GW_CHILD);

                // Now that we have the shell window, get the ListView, which is the 
                // child displaying everything.
                IntPtr hListView = User32.GetWindow(hShellView, User32.GW_CHILD);

                // Finally, get the DeviceContext handle for this list view
                hDC = User32.GetDC(hListView);
            }
            else
            {
                // If null was returned, then we're probably on Vista, and need to ask for
                // The "Program Manager" window.
                if (IntPtr.Zero == hProgMan)
                {
                    hProgMan = User32.FindWindow("Program Manager", null);
                    hDC = User32.GetDC(hProgMan);
                }
            }


            // And create a GDIContext for it
            GDIContext aContext = new GDIContext(hDC, false);

            return aContext;

        }
Ejemplo n.º 12
0
        public static GDIContext CreateForWindowClientArea(IntPtr hWnd)
        {
            IntPtr hdc = IntPtr.Zero;

            hdc = User32.GetDC(hWnd);
            //hdc = User32.GetDCEx(hWnd, IntPtr.Zero, DeviceContextValues.Window);
            GDIContext newContext = new GDIContext(hdc, false);

            return newContext;
        }
Ejemplo n.º 13
0
        public static GDIContext CreateForWholeWindow(IntPtr hWnd)
        {
            IntPtr hdc = IntPtr.Zero;

            hdc = User32.GetWindowDC(hWnd);
            GDIContext newContext = new GDIContext(hdc, false);

            return newContext;
        }
Ejemplo n.º 14
0
        public static GDIContext CreateForMemory()
        {
            IntPtr hdc;

            hdc = GDI32.CreateCompatibleDC(GDIContext.CreateForDefaultDisplay());
            GDIContext newConText = new GDIContext(hdc, true);

            return newConText;
        }
Ejemplo n.º 15
0
        public static GDIContext CreateForAllAttachedMonitors()
        {
            IntPtr hdc = IntPtr.Zero;

            hdc = GDI32.CreateDC("DISPLAY", null, null, IntPtr.Zero);
            GDIContext newContext = new GDIContext(hdc, true);

            // public static IntPtr CreateDC(string lpszDriver, string lpszDevice, IntPtr lpInitData);

            return newContext;
        }
Ejemplo n.º 16
0
        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;
        }
Ejemplo n.º 17
0
        public static GDIContext CreateForDefaultDisplay()
        {
            IntPtr hdc = IntPtr.Zero;

            hdc = User32.GetWindowDC(User32.GetDesktopWindow());
            GDIContext newContext = new GDIContext(hdc, false);

            return newContext;
        }