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

            }
        }
    }
  • 相关阅读:
    linux 学习随笔-shell基础知识
    linux 学习随笔-压缩和解压缩
    解析xml的4种方法详解
    集合工具类
    Map概述
    List集合概述
    Java集合框架
    Spring JdbcTemplate详解
    关于c3p0数据库连接池的简单使用
    Java通过JDBC封装通用DAO层
  • 原文地址:https://www.cnblogs.com/hbhbice/p/1894085.html
Copyright © 2020-2023  润新知