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 ();

            }
        }
    }
  • 相关阅读:
    [BZOJ4553][TJOI2016&HEOI2016]序列
    树套树乱讲的代码
    树套树乱讲
    [Luogu4174][NOI2006]最大获益
    [BZOJ3879]SvT
    [BZOJ3611][HEOI2014]大工程
    [BZOJ1501][NOI2005]智慧珠游戏
    [BZOJ1499][NOI2005]瑰丽华尔兹
    [BZOJ3460] Jc的宿舍
    [HDU4812]D Tree
  • 原文地址:https://www.cnblogs.com/hbhbice/p/1894085.html
Copyright © 2011-2022 走看看