Beispiel #1
0
        /// <summary>
        /// 长截图函数,合并图像部分还有待完善
        /// </summary>
        /// <param name="selectRect"></param>
        /// <returns></returns>
        private Bitmap captureLongBitmap(Rectangle selectRect)
        {
            List <Bitmap> bitmaps = new List <Bitmap>();
            int           dwData  = (int)(0.9 * selectRect.Height);
            Bitmap        bitmap  = captureBitmap(selectRect);

            bitmaps.Add(bitmap);
            Double distance    = 0;
            int    wheelPointX = selectRect.X + selectRect.Width / 2;
            int    wheelPointY = selectRect.Y + selectRect.Height / 2;

            while (true)
            {
                MouseSimulation.MoveMouseWHEEL(wheelPointX, wheelPointY, -dwData);
                System.Threading.Thread.Sleep(DELAY_TIME);
                bitmap   = captureBitmap(selectRect);
                distance = ImageTool.Calculate_Distance(bitmap, bitmaps[bitmaps.Count - 1]);
                if (distance < 0.4)
                {
                    //bitmaps.Add(bitmap);
                    Console.WriteLine("滚动结束," + distance.ToString());
                    break;
                }
                else
                {
                    bitmaps.Add(bitmap);
                    Console.WriteLine("滚动图片" + bitmaps.Count.ToString() + "," + distance.ToString());
                }
            }
            int i = 0;

            foreach (Bitmap b in bitmaps)
            {
                string filename = "roll/" + i++.ToString() + ".png";
                b.Save(filename, ImageFormat.Png);
            }
            Bitmap longBitmap = generateLongBitmap(bitmaps, selectRect);

            return(longBitmap);
        }