[Java] view plaincopyprint? # Include "stdafx. h "# include <opencv/highgui. h> # include <opencv/cv. h> int main (int argc, char ** argv) {int nWidth = 256*2-1; int nHeight = 400; IplImage * pImg = cvCreateImage (cvSize (nWidth, nHeight), IPL_DEPTH_8U, 3); for (int I = 0; I <pImg-> height; I ++) {uchar * data = (uchar *) pImg-> imageData + pImg-> widthStep * I; for (int j = 0; j <pImg-> width; j ++) {int nColor; if (j <= 255) {nColor = 255-j;} else {nColor = j-255 ;} data [3 * j] = data [3 * j + 1] = data [3 * j + 2] = nColor;} cvShowImage ("benben", pImg ); cvSaveImage ("C: \ Users \ benben_wsx \ Desktop \ 1320.2.jpg", pImg); cvWaitKey (0); return 0 ;}# include" stdafx. h "# include <opencv/highgui. h> # include <opencv/cv. h> int main (int argc, char ** argv) {int nWidth = 256*2-1; int nHeight = 400; IplImage * pImg = cvCreateImage (cvSize (nWidth, nHeight), IPL_DEPTH_8U, 3); for (int I = 0; I <pImg-> height; I ++) {uchar * data = (uchar *) pImg-> imageData + pImg-> widthStep * I; for (int j = 0; j <pImg-> width; j ++) {int nColor; if (j <= 255) {nColor = 255-j;} else {nColor = j-255 ;} data [3 * j] = data [3 * j + 1] = data [3 * j + 2] = nColor;} cvShowImage ("benben", pImg ); cvSaveImage ("C: \ Users \ benben_wsx \ Desktop \ 1320.2.jpg", pImg); cvWaitKey (0); return 0 ;}