Beispiel #1
0
        // Updating bitmap in picture
        private void MyUpdatePicture()
        {
            if (m_image.isValid())
            {
                m_lut.inmax = HScrollLutMax.Value;
                m_lut.inmin = HScrollLutMin.Value;

                Rectangle rc = new Rectangle(0, 0, m_image.width, m_image.height);
                m_bitmap = new Bitmap(m_image.width, m_image.height);
                SUBACQERR err = subacq.copydib(ref m_bitmap, m_image.bufframe, ref rc, m_lut.inmax, m_lut.inmin);

                if (err == SUBACQERR.SUCCESS)
                {
                    PicDisplay.Image = m_bitmap;
                }
                else
                {
                    PicDisplay.Image = null;
                    MyShowStatus(String.Format("NG: SUBACQERR: 0x{0:X8}", (int)err));
                }
            }
            else
            {
                PicDisplay.Image = null;
            }
        }
Beispiel #2
0
        public static SUBACQERR copydib(ref Bitmap bitmap, DCAMBUF_FRAME src, ref Rectangle rect, int lutmax, int lutmin)
        {
            int w = rect.Width;
            int h = rect.Height;

            if (w > bitmap.Width)
            {
                w = bitmap.Width;
            }
            if (h > bitmap.Height)
            {
                h = bitmap.Height;
            }
            if (w > src.width)
            {
                w = src.width;
            }
            if (h > src.height)
            {
                h = src.height;
            }

            BitmapData     dst   = bitmap.LockBits(rect, ImageLockMode.ReadWrite, PixelFormat.Format32bppRgb);
            SUBACQ_COPYDIB param = new SUBACQ_COPYDIB();

            param.size   = Marshal.SizeOf(typeof(SUBACQ_COPYDIB));
            param.option = 0;

            param.src          = src.buf;
            param.srcrowbytes  = src.rowbytes;
            param.srcpixeltype = src.type;

            param.dst            = dst.Scan0;
            param.dstrowbytes    = dst.Stride;
            param.dstpixelformat = dst.PixelFormat;

            param.width  = w;
            param.height = h;
            param.left   = rect.Left;
            param.top    = rect.Top;

            param.lut    = IntPtr.Zero;
            param.lutmax = lutmax;
            param.lutmin = lutmin;

            // ---- call subacq4_copydib function in subacq4.dll ----

            SUBACQERR err = subacqdll.copydib(ref param);

            bitmap.UnlockBits(dst);

            return(err);
        }