예제 #1
0
        private static void Main(string[] args)
        {
            //var r = CaptureUtil.DefGetCaptureData(ref offset, ref width, ref height);
            IntPtr hwnd = IntPtr.Zero;
            IntPtr hdc  = IntPtr.Zero;

            if (CaptureUtil.GetWindowHDC(ref hwnd, ref hdc))
            {
                int x = 0;
                int y = 0;
                CaptureUtil.GetWindowSize(hwnd, ref x, ref y);

                // 4k / 4 = 1k
                // sqrt(1024) = 32
                int       num        = 0;
                const int blockSize  = 128;
                var       bitmap     = new BITMAP();
                var       bitmapSize = CaptureUtil.DefGetCaptureBlockBitmap(hwnd, hdc, 0, 0, blockSize, blockSize, ref bitmap);
                int       blockSizeW = (x + blockSize - 1) / blockSize;
                int       blockSizeH = (y + blockSize - 1) / blockSize;
                for (int i = 0; i < blockSizeW; ++i)
                {
                    for (int j = 0; j < blockSizeH; ++j)
                    {
                        var r      = CaptureUtil.DefGetCaptureData(hwnd, hdc, bitmapSize, bitmap, i * blockSize, j * blockSize, blockSize, blockSize);
                        var result = CaptureUtil.ConvertBmpToJpeg(r);
                        using (FileStream fs = new FileStream(@"D:\Test\test" + num + @".jpg", FileMode.Create, FileAccess.Write))
                        {
                            fs.Write(result, 0, result.Length);
                        }
                        ++num;
                    }
                }
            }
        }
예제 #2
0
파일: Program.cs 프로젝트: shangshen/cozy
        private static void Main(string[] args)
        {
            var result = CaptureUtil.ConvertBmpToJpeg(CaptureUtil.DefGetCaptureData());

            using (FileStream fs = new FileStream(@"D:\test.jpg", FileMode.Create, FileAccess.Write))
            {
                fs.Write(result, 0, result.Length);
            }
            Console.ReadKey();
        }