Esempio n. 1
0
        //public static void CaptureJpg(RECT rect)
        //{2
        //    return;
        //    string tmp = SetPicPath(GTR_dnf.m_strPictureDir, GTR_dnf.OrdNo);
        //    ImageTool.GetScreenCapture(rect).Save(tmp, ImageFormat.Jpeg);
        //}
        public static void CaptureBmp(Bitmap BigBmp, RECT rect, string strPicName)
        {
            try
            {
                if (BigBmp == null)
                {
                    return;
                }
                int        width    = rect.right - rect.left;
                int        height   = rect.bottom - rect.top;
                Rectangle  srcRect  = new Rectangle(rect.left, rect.top, width, height);
                BitmapData bigBData = BigBmp.LockBits(srcRect, ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);

                Bitmap bmp = new Bitmap(width, height, bigBData.Stride, PixelFormat.Format24bppRgb, bigBData.Scan0);
                bmp.Save(strPicName);
                BigBmp.UnlockBits(bigBData);
            }
            catch (Exception e)
            {
                FileRW.WriteToFile(e.ToString());
                FileRW.WriteToFile(strPicName);
            }


            return;
            //ImageTool.GetScreenCapture(rect).Save(strPicName, ImageFormat.Bmp);
        }