Beispiel #1
0
        public Pixelmap GetPixelmap(int index)
        {
            if (index < FirstFrame || index > LastFrame)
                throw new ApplicationException("Invalid frame position: " + index);

            uint[] pixels = new uint[Width * Height];
            uint[] unprocessedPixels = new uint[Width * Height];
            byte[] displayBitmapBytes = new byte[Width * Height];
            byte[] rawBitmapBytes = new byte[(Width * Height * 3) + 40 + 14 + 1];

            var frameInfo = new SerNativeFrameInfo();

            TangraCore.SERGetFrame(index, pixels, unprocessedPixels, rawBitmapBytes, displayBitmapBytes, (ushort)BitPix, ref frameInfo);

            m_CurrentFrameInfo = new SerFrameInfo(frameInfo);

            using (var memStr = new MemoryStream(rawBitmapBytes))
            {
                Bitmap displayBitmap;

                try
                {
                    displayBitmap = (Bitmap)Bitmap.FromStream(memStr);
                }
                catch (Exception ex)
                {
                    Trace.WriteLine(ex.GetFullStackTrace());
                    displayBitmap = new Bitmap(Width, Height);
                }

                var rv = new Pixelmap(Width, Height, BitPix, pixels, displayBitmap, displayBitmapBytes);
                rv.UnprocessedPixels = unprocessedPixels;
                rv.FrameState = new FrameStateData()
                {
                    SystemTime = m_CurrentFrameInfo.TimeStampUtc
                };

                if (UseTimeStamp != SerUseTimeStamp.None)
                {
                    if (UseTimeStamp == SerUseTimeStamp.FireCaptureLog)
                    {
                        DateTime dt;
                        if (m_FireCaptureTimeStamps.TryGetValue(1 + index, out dt))
                            rv.FrameState.CentralExposureTime = dt;
                    }
                    else if (UseTimeStamp == SerUseTimeStamp.SerEmbeddedUtcTime)
                    {
                        rv.FrameState.CentralExposureTime = m_CurrentFrameInfo.TimeStampUtc;
                    }
                }

                return rv;
            }
        }
Beispiel #2
0
        public Pixelmap GetIntegratedFrame(int startFrameNo, int framesToIntegrate, bool isSlidingIntegration, bool isMedianAveraging)
        {
            if (startFrameNo < FirstFrame || startFrameNo > LastFrame)
                throw new ApplicationException("Invalid frame position: " + startFrameNo);

            int actualFramesToIntegrate = Math.Min(startFrameNo + framesToIntegrate, LastFrame - 1) - startFrameNo;

            uint[] pixels = new uint[Width * Height];
            uint[] unprocessedPixels = new uint[Width * Height];
            byte[] displayBitmapBytes = new byte[Width * Height];
            byte[] rawBitmapBytes = new byte[(Width * Height * 3) + 40 + 14 + 1];
            var frameInfo = new SerNativeFrameInfo();

            TangraCore.SERGetIntegratedFrame(startFrameNo, actualFramesToIntegrate, isSlidingIntegration, isMedianAveraging, pixels, unprocessedPixels, rawBitmapBytes, displayBitmapBytes, (ushort)BitPix, ref frameInfo);

            m_CurrentFrameInfo = new SerFrameInfo(frameInfo);

            using (var memStr = new MemoryStream(rawBitmapBytes))
            {
                Bitmap displayBitmap = (Bitmap)Bitmap.FromStream(memStr);

                var rv = new Pixelmap(Width, Height, BitPix, pixels, displayBitmap, displayBitmapBytes);
                rv.UnprocessedPixels = unprocessedPixels;
                rv.FrameState = new FrameStateData()
                {
                    SystemTime = m_CurrentFrameInfo.TimeStampUtc
                };

                if (UseTimeStamp != SerUseTimeStamp.None)
                {
                    if (UseTimeStamp == SerUseTimeStamp.FireCaptureLog)
                    {
                        DateTime dt, dt2;
                        if (actualFramesToIntegrate % 2 == 0 && actualFramesToIntegrate > 1)
                        {
                            if (
                                m_FireCaptureTimeStamps.TryGetValue(startFrameNo + actualFramesToIntegrate/2, out dt) &&
                                m_FireCaptureTimeStamps.TryGetValue(1 + startFrameNo + actualFramesToIntegrate/2, out dt2))
                            {
                                rv.FrameState.CentralExposureTime = dt.AddTicks((dt2 - dt).Ticks/2);
                            }
                        }
                        else
                        {
                            if (m_FireCaptureTimeStamps.TryGetValue(1 + startFrameNo + actualFramesToIntegrate / 2, out dt))
                                rv.FrameState.CentralExposureTime = dt;
                        }
                    }
                    else if (UseTimeStamp == SerUseTimeStamp.SerEmbeddedUtcTime)
                    {
                        rv.FrameState.CentralExposureTime = m_CurrentFrameInfo.TimeStampUtc;
                    }
                }

                return rv;
            }
        }