Ask Your Question

Revision history [back]

What you actually have to do is convert your image to the bitmap format then push it inside the CImage by assignment. This topic tells you more about the bitmap conversion.

However I suggest using the C++ interface Mat instead of the C interface IplImage. Because that element has a to bitmap functionality provided.

An example in Android I quickly grabbed of the net, but what will work if you take the corresponding C++ functions is showed here:

Bitmap bmp = null;
Mat tmp = new Mat (height, width, CvType.CV_8U, new Scalar(4));
try {
    Imgproc.cvtColor(original_image, tmp, Imgproc.COLOR_GRAY2RGBA, 4);
    bmp = Bitmap.createBitmap(tmp.cols(), tmp.rows(), Bitmap.Config.ARGB_8888);
    Utils.matToBitmap(tmp, bmp);
}
catch (CvException e){Log.d("Exception",e.getMessage());}