# Revision history [back]

You can do like this for example: Mat yourMatrix = new Mat(new Size(screenWidth,screenHeight),CvType.CV_8U);

for(int i = 0 ; i < screenHeight ; i++) for(int j = 0 ; j < W; j++) yourMatrix.row(i).col(j).setTo(new Scalar(i + j));

Warning!

If your matrix big, iterate through all the pixels, take you a long long time.

My advice, if your matrix is big (my matrix size was 1920x1080) work with native c++ with android.

You can do like this for example: example:

Mat yourMatrix =  new Mat(new Size(screenWidth,screenHeight),CvType.CV_8U);Size(screenWidth,screenHeight),CvType.CV_8U);
for(int i = 0 ; i < screenHeight ; i++)
for(int j = 0 ; j < W; j++)
yourMatrix.row(i).col(j).setTo(new Scalar(i + j));j));


Warning!

If your matrix big, iterate through all the pixels, take you a long long time.

My advice, if your matrix is big (my matrix size was 1920x1080) work with native c++ with android.