zoukankan      html  css  js  c++  java
  • WinCE 上截图

    核心代码如下:

    using System;

    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using System.Runtime.InteropServices;

    namespace Capture
    {
        
    public partial class Form1 : Form
        {
            [DllImport(
    "coredll.Dll")]

            
    private static extern IntPtr CreateDC(
                
    string lpszDriver, // 驱动名称 
                string lpszDevice, // 设备名称 
                string lpszOutput, // 无用,可以设定位"NULL" 
                IntPtr lpInitData // 任意的打印机数据 
                );
            [DllImport(
    "coredll.Dll")]
            
    private static extern bool BitBlt(
                IntPtr hdcDest, 
                
    int nXDest, 
                
    int nYDest, 
                
    int nWidth, 
                
    int nHeight, 
                IntPtr hdcSrc, 
                
    int nXSrc, 
                
    int nYSrc, 
                Int32 dwrop
                );

            
    private const int SRCCOPY  =0xCC0020;

            
    public Form1()
            {
                InitializeComponent();
            }

            
    private void button1_Click(object sender, EventArgs e)
            {
                
    int iHeight =Screen.PrimaryScreen.Bounds.Height;
                
    int iWidth = Screen.PrimaryScreen.Bounds.Width;
                IntPtr dc1 
    = CreateDC(nullnullnull, (IntPtr)null);
                Graphics gScreen 
    = Graphics.FromHdc(dc1);
                Image iGetPhoto 
    = new Bitmap(
                    iWidth
                    ,iHeight );
                Graphics gPhoto 
    = Graphics.FromImage(iGetPhoto);
                IntPtr iHandle 
    = gScreen.GetHdc();
                IntPtr iPhoto 
    = gPhoto.GetHdc();

                BitBlt(iPhoto, 
    00, iWidth, iHeight,
                    iHandle, 
    00, SRCCOPY);
                gScreen.ReleaseHdc(iHandle);
                gPhoto.ReleaseHdc(iPhoto);
                iGetPhoto.Save(
    @"\NandFlash\ice.bmp",System.Drawing .Imaging .ImageFormat .Bmp );
                iGetPhoto .Dispose ();

            }
        }
    }
  • 相关阅读:
    USACO 2019 January Contest Platinum T2: Exercise Route
    USACO 2016 December Contest Gold T3: Lasers and Mirrors
    USACO 2016 December Contest Gold T2: Cow Checklist
    USACO 2016 December Contest Gold T1: Moocast
    USACO 2016 US Open Contest Gold T3: 248
    洛谷p5369[PKUSC2018]最大前缀和
    洛谷p5465 [PKUSC2018]星际穿越
    洛谷p3778[APIO2017]商旅
    NOIP2018提高组题解
    NOIP2017提高组题解
  • 原文地址:https://www.cnblogs.com/hbhbice/p/1894085.html
Copyright © 2011-2022 走看看