Opencv matrix to image Conversion

Source: Internet
Author: User
[Reprinted] opencv creates an image based on the data matrix

Source: http://my.csdn.net/c4501srsy/code/detail/21397

C ++ code

  data=newBYTE[300*200*3];memset(data,128,300*200*3);// Prepare the color matrix  IplImage* img;  CvSize size;size.width =300;size.height=200;img=cvCreateImage(size,IPL_DEPTH_8U,3);// Create an image. Note: ipl_depth_8u is a byte type and 3 is the number of channels.  memcpy(img->imageData,data,300*200*3); // Load the data matrix into the image img  CRect rect;                            // Display the following imagesrect.left=0;rect.top=0;rect.right=img->width;rect.bottom=img->height;  CvvImage cimg;cimg.CopyOf(img);cimg.DrawToHDC(dc.GetSafeHdc(),&rect);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.