//opencv读取图片 cv::Mat image; //const char *fileName = "HeadImage-UI/Photo-001.bmp"; const char *fileName = "HeadImage-UI/53d253192be47412.jpg!200x200.jpg"; image = cv::imread(fileName); //bitmap冲回image Graphics::TBitmap *bitmap = new Graphics::TBitmap; bitmap->PixelFormat = pf24bit; bitmap->Height = image.rows; bitmap->Width = image.cols; for(int y=0;y<bitmap->Height;y++) { uchar *ptr = image.ptr<uchar>(y); Byte *p=(Byte*)bitmap->ScanLine[y]; for(int x=0;x<bitmap->Width;x++) { p[0] = ptr[0]; p[1] = ptr[1]; p[2] = ptr[2]; p+=3; ptr+=3; } } Image1->Picture->Bitmap = bitmap;
时间: 2024-10-13 22:18:05