private void OnEventStillImage() { uint nWidth = 0, nHeight = 0; if (toupcam_.PullStillImage(IntPtr.Zero, 24, out nWidth, out nHeight)) /* peek the width and height */ { Bitmap sbmp = new Bitmap((int)nWidth, (int)nHeight, PixelFormat.Format24bppRgb); BitmapData bmpdata = sbmp.LockBits(new Rectangle(0, 0, sbmp.Width, sbmp.Height), ImageLockMode.WriteOnly, sbmp.PixelFormat); toupcam_.PullStillImage(bmpdata.Scan0, 24, out nWidth, out nHeight); sbmp.UnlockBits(bmpdata); sbmp.Save("toupcamdemowinformcs2.jpg"); } }
public void capture() { // stopLiveMode(); //setResolution(1); captureBm = new Bitmap(2048, 1536); BitmapData bData = captureBm.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb); uint cWidth = 0; uint cHeight = 0; myCamera.PullStillImage(bData.Scan0, 24, out cWidth, out cHeight); captureBm.UnlockBits(bData); stopLiveMode(); captureBm.Save(FileName); captureBm.Dispose(); }