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

            }
        }
    }
  • 相关阅读:
    打印杨辉三角C语言小程序
    奇怪的比赛蓝桥杯
    (转)Silverlight CoreCLR结构浅析
    试一试!
    (转)使用自定义行为扩展 WCF
    分组合并的使用
    多进程,多线程(转载)
    在 ASP.NET 网页中不经过回发而实现客户端回调(需要实现ICallbackEventHandler接口)
    读书笔记
    WCF学习笔记3(客户端内部运行机制分析)
  • 原文地址:https://www.cnblogs.com/hbhbice/p/1894085.html
Copyright © 2011-2022 走看看