private void ShowBitmap2(BitmapData bitmapData) { { if (bitmapData.DateTime != _currentShownTime || _redisplay) { _redisplay = false; // The following code does these functions: // Get a IntPtr to the start of the GBR bitmap // Transform via sample transformation (To be replaced with your C++ code) // Create a Bitmap with the result // Create a new Bitmap scaled to visible area on screen // Assign new Bitmap into PictureBox // Dispose first Bitmap // // The transformation is therefore done on the original image, but if the transformation is // keeping to the same size, then this would be much more effective if the resize was done first, // and the transformation afterwards. // Scaling can be done by setting the Width and Height on the int width = bitmapData.GetPlaneWidth(0); int height = bitmapData.GetPlaneHeight(0); int stride = bitmapData.GetPlaneStride(0); // When using RGB / BGR bitmaps, they have all bytes continues in memory. The PlanePointer(0) is used for all planes: IntPtr plane0 = bitmapData.GetPlanePointer(0); //IntPtr newPlane0 = transform.Perform(plane0, width * height * 3); // Make the sample transformation / color change IntPtr newPlane0 = _transform.Perform(plane0, stride, width, height); // Make the sample transformation / color change Image myImage = new Bitmap(width, height, stride, PixelFormat.Format24bppRgb, newPlane0); if (pictureBox.Width != 0 && pictureBox.Height != 0) // Ignore when window is not visible { // We need to resize to the displayed area pictureBox.Image = new Bitmap(myImage, pictureBox.Width, pictureBox.Height); myImage.Dispose(); // ---- bitmapData.Dispose(); Need to be disposed on the calling thread _transform.Release(newPlane0); //textBoxTime.Text = bitmapData.DateTime.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss.fff"); } } _currentShownTime = bitmapData.DateTime; Debug.WriteLine("Image time: " + bitmapData.DateTime.ToLocalTime().ToString("HH.mm.ss.fff") + ", Mode=" + _mode); } _requestInProgress = false; }
private void ShowBitmap2(BitmapData bitmapData) { { if (bitmapData.DateTime != _currentShownTime || _redisplay) { _redisplay = false; // The following code does these functions: // Get a IntPtr to the start of the GBR bitmap // Transform via sample transformation (To be replaced with your C++ code) // Create a Bitmap with the result // Create a new Bitmap scaled to visible area on screen // Assign new Bitmap into PictureBox // Dispose first Bitmap // // The transformation is therefore done on the original image, but if the transformation is // keeping to the same size, then this would be much more effective if the resize was done first, // and the transformation afterwards. // Scaling can be done by setting the Width and Height on the int width = bitmapData.GetPlaneWidth(0); int height = bitmapData.GetPlaneHeight(0); int stride = bitmapData.GetPlaneStride(0); // When using RGB / BGR bitmaps, they have all bytes continues in memory. The PlanePointer(0) is used for all planes: IntPtr plane0 = bitmapData.GetPlanePointer(0); IntPtr newPlane0 = transform.Perform(plane0, stride, width, height); // Make the sample transformation / color change Image myImage = new Bitmap(width, height, stride, PixelFormat.Format24bppRgb, newPlane0); // We need to resize to the displayed area pictureBox.Image = new Bitmap(myImage, pictureBox.Width, pictureBox.Height); myImage.Dispose(); // ---- bitmapData.Dispose(); transform.Release(newPlane0); textBoxTime.Text = bitmapData.DateTime.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss.fff"); // Inform the PlybackController of the time information - so skipping can be done correctly //Update 2016 EnvironmentManager.Instance.SendMessage(new VideoOS.Platform.Messaging.Message(MessageId.SmartClient.PlaybackTimeInformation, new PlaybackTimeInformationData() { Item = _selectedItem.FQID, CurrentTime = bitmapData.DateTime, PreviousTime = bitmapData.PreviousDateTime, NextTime = bitmapData.NextDateTime })); if (_mode == PlaybackPlayModeData.Stop) { //Update 2016 EnvironmentManager.Instance.SendMessage(new VideoOS.Platform.Messaging.Message(MessageId.SmartClient.PlaybackCommand, new PlaybackCommandData() { Command = PlaybackData.Goto, DateTime = bitmapData.DateTime })); } _currentShownTime = bitmapData.DateTime; Debug.WriteLine("Image time: " + bitmapData.DateTime.ToLocalTime().ToString("HH.mm.ss.fff") + ", Mode=" + _mode); } _requestInProgress = false; } }