您的位置:首页 > 运维架构

Opencv读取各种格式图片,在TBitmap上面重绘

2016-01-07 15:28 435 查看
//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;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: