Exemple #1
0
        private void m_btnSave_Click(object sender, EventArgs e)
        {
            SaveFileDialog dlgSave = new SaveFileDialog();

            dlgSave.Filter = "bmp files (*.bmp)|*.bmp|wsq files (*.wsq)|*.wsq";
            if (dlgSave.ShowDialog() == DialogResult.OK)
            {
                if (dlgSave.FilterIndex == 1)
                {
                    MyBitmapFile myFile = new MyBitmapFile(m_hDevice.ImageSize.Width, m_hDevice.ImageSize.Height, m_Frame);
                    FileStream   file   = new FileStream(dlgSave.FileName, FileMode.Create);
                    file.Write(myFile.BitmatFileData, 0, myFile.BitmatFileData.Length);
                    file.Close();
                    SetMessageText("Bitmap file is saved to " + dlgSave.FileName);
                }
                else //wsq
                {
                    float  fBitRate = 0.75f; // in the range of 0.75 - 2.25, lower value with higher compression rate
                    byte[] wsqImage = m_hDevice.WSQ_FromRawImage(m_Frame, m_hDevice.ImageSize.Width, m_hDevice.ImageSize.Height, fBitRate);
                    if (wsqImage != null)
                    {
                        FileStream file = new FileStream(dlgSave.FileName, FileMode.Create);
                        file.Write(wsqImage, 0, wsqImage.Length);
                        file.Close();
                        SetMessageText("WSQ file is saved to " + dlgSave.FileName);
                    }
                }
            }
        }
Exemple #2
0
 private void CaptureThread()
 {
     m_bScanning = true;
     while (!m_bCancelOperation)
     {
         GetFrame();
         if (m_Frame != null)
         {
             MyBitmapFile myFile    = new MyBitmapFile(m_hDevice.ImageSize.Width, m_hDevice.ImageSize.Height, m_Frame);
             MemoryStream BmpStream = new MemoryStream(myFile.BitmatFileData);
             Bitmap       Bmp       = new Bitmap(BmpStream);
             m_picture.Image = Bmp;
         }
         else
         {
             m_picture.Image = null;
         }
         Thread.Sleep(10);
     }
     m_bScanning = false;
 }