If (dlgOpenPic - & gt; The Execute ())//use TOpenDialog control select files
{
IplImage * pImage=cvLoadImage (dlgOpenPic - & gt; FileName. C_str (), CV_LOAD_IMAGE_COLOR);//using OPENCV function to load the picture
If (pImage==NULL)
return ;
CvFlip (pImage);
Int nWidth=pImage - & gt; Width;
Int nHeight=pImage - & gt; Height;
ImgShowPic - & gt; Picture - & gt; Bitmap - & gt; Width=nWidth;
ImgShowPic - & gt; Picture - & gt; Bitmap - & gt; Height=nHeight;
ImgShowPic - & gt; Picture - & gt; Bitmap - & gt; PixelFormat=pf24bit;//set the picture is 24 color display
Memcpy (imgShowPic - & gt; Picture - & gt; Bitmap - & gt; ScanLine [] nHeight - 1, pImage - & gt; ImageData pImage - & gt; ImageSize);//will load the image data to the Timage control,
CvReleaseImage (& amp; PImage);//the end to release the handle,
}
So you can show the picture of any format,
-- -- -- -- -- -- -- -- -- --
Old shall see if there is something wrong with this code?
CvFlip (pImage);
Memcpy (imgShowPic - & gt; Picture - & gt; Bitmap - & gt; ScanLine [] nHeight - 1, pImage - & gt; ImageData pImage - & gt; ImageSize);
The principle of two lines of code? ScanLine] [nHeight - 1 is the lowest address? BMP scan line is reverse?
CodePudding user response:
BCB in using opencv display picture
Zh516846937 17:35:36 2011-11-23 2771 collection
Tags: work image null
Copyright
Create a new project, to add a Timage control (dlgOpenPic), a TOpenDialog control (dlgOpenPic), a button,
Add the following statement: in the header file
#include
# include "CV. H"
# include "highgui. H"
# include "cxcore. H"
# pragma link "cv200 lib"
# pragma link "cxcore200 lib"
# pragma link "highgui200 lib"
This is to join the required header files and LIB library, then cv200. DLL, cxcore200. DLL, highgui200. DLL in the working directory,
These will be set after finishing engineering:
Configuration:
The Project - & gt; The Options - & gt;" Directories/Conditionals
"Conditionals: _DEBUG; SKIP_INCLUDES (add SKIP_INCLUDES),
These are set up is to write code,
The click event of the button to add the following code:
If (dlgOpenPic - & gt; The Execute ())//use TOpenDialog control select files
{
//code in the main building
CodePudding user response:
Should be, cvLoadImage (dlgOpenPic - & gt; FileName. C_str (), CV_LOAD_IMAGE_COLOR) transformed into RGB3 channel the image bitmap formats, namely 24 bitmap, and then upside down, because the VCL TBitmap establish bitmap DIB by default, is the bottom - & gt; Stored in order topCodePudding user response: