You have to specify width and height of the image/Mat and channels depth.
Mat mat = new Mat(width, height, CvType.CV_8UC3);
mat.put(0, 0, data);
Make sure you are using correct type of Mat. Maybe your data is not in 3 bytes RGB format and you should use another type e.g. CvType.CV_8UC1.
Good luck!