I am making a WinForms app using VS2012 c++/cli and using DrawImage to display HD images captured from a webcam.
The images are 1920 x 1080 bitmaps that I am trying to display on a Panel control. The Panel is 240 x 135 (i.e., exactly 1/8 of the HD image).
I am calling DrawImage as follows:
System::Drawing::Rectangle destRect = System::Drawing::Rectangle(0,0,Cam0Panel->Width,Cam0Panel->Height);
g->DrawImage(b,destRect);
This should specify to draw the image at the relative 0,0 location on the panel and size the image to be 240 x 135. However, the image will not display.
If I change the Height parameter to specify the Panel->Bottom (which is the absolute position in the app - ~630), the image does display and is correctly sized for width but is not correctly sized for height.
Any idea what I am doing wrong or how to correctly resize and display the image?
Here is a complete version of the code.
void Cam0Panel_Paint( Object^ /*sender*/, System::Windows::Forms::PaintEventArgs^ e )
{
System::Drawing::Bitmap^ b = ImageWinArray[CHANNEL_SELECT0];
Graphics^ g = e->Graphics;
g->InterpolationMode = System::Drawing::Drawing2D::InterpolationMode::Bilinear;
g->CompositingMode = System::Drawing::Drawing2D::CompositingMode::SourceCopy;
System::Drawing::Rectangle destRect = System::Drawing::Rectangle(0,0,Cam0Panel->Width,Cam0Panel->Bottom);
g->DrawImage(b,destRect);
}
Thanks for any help.
Aucun commentaire:
Enregistrer un commentaire