Getting and displaying a bitmap from movie using JNI and ofImage

I am trying to return a bitmap/frame from movies using mediametadataretriever of Android api using JNI.Then ofImage will show the returned bitmap.So I am using “setFromPixels” function of ofImage class.It displays the bitmap without problem except that it is in black & white.Changing OF_IMAGE_GRAYSCALE to OF_IMAGE_COLOR or OF_IMAGE_COLOR_ALPHA doesn’t make it colurful, still it displays in b&w.

I hope someone helps me.Here is the code I am using;

ofapp.h:

ofImage image1;
unsigned char* bitmap;

ofappcpp
setup function:

jclass bitmapConfig = ofGetJNIEnv()->FindClass(“android/graphics/Bitmap$Config”);

jfieldID rgba8888FieldID = ofGetJNIEnv()->GetStaticFieldID(bitmapConfig, “ARGB_8888”, “Landroid/graphics/Bitmap$Config;”);

jobject rgba8888Obj = ofGetJNIEnv()->GetStaticObjectField(bitmapConfig, rgba8888FieldID);

jclass mediadataret = ofGetJNIEnv()->FindClass(“android/media/MediaMetadataRetriever”);

jmethodID medID = ofGetJNIEnv()->GetMethodID(mediadataret,"","()V");

jobject mediadatart = ofGetJNIEnv()->NewObject(mediadataret,medID);

jmethodID medID2 = ofGetJNIEnv()->GetMethodID(mediadataret,“setDataSource”,"(Ljava/lang/String;)
V");

jstring str1 = ofGetJNIEnv()->NewStringUTF("/storage/emulated/0/try/movie.mp4");

jlong framenum=7*1000;
jint height=100;
jint width=100;
long width
=100;
long height
= 100;

ofGetJNIEnv()->CallVoidMethod(mediadatart,medID2,str1);

jclass classbitmap = ofGetJNIEnv()->FindClass(“android/graphics/Bitmap”);

jmethodID createBitmapMethodID = ofGetJNIEnv()->GetStaticMethodID(classbitmap,“createBitmap”,
“(IILandroid/graphics/Bitmap$Config;)Landroid/graphics/Bitmap;”);

jobject bitmap1= ofGetJNIEnv()->CallStaticObjectMethod(classbitmap, createBitmapMethodID,
_width,_height, rgba8888Obj);

jmethodID medID3 = ofGetJNIEnv()->GetMethodID(mediadataret,“getFrameAtTime”,"(J)
Landroid/graphics/Bitmap;");

bitmap1 = ofGetJNIEnv()-> CallObjectMethod( mediadatart, medID3, framenum);

jmethodID metID4 = ofGetJNIEnv() >GetMethodID(classbitmap,“getPixels”,"([IIIIIII)V");

jmethodID takewidth = ofGetJNIEnv()->GetMethodID(classbitmap,“getWidth”,"()I");

jmethodID takeheight = ofGetJNIEnv()->GetMethodID(classbitmap,“getHeight”,"()I");

width= ofGetJNIEnv()->CallIntMethod(bitmap1,takewidth);
height = ofGetJNIEnv()->CallIntMethod(bitmap1,takeheight);

jintArray pixels = ofGetJNIEnv()->NewIntArray(width * height);

ofGetJNIEnv()->CallVoidMethod(bitmap1,metID4,pixels,offset,width,x,y,width,height);

jint* pointer1 = ofGetJNIEnv()->GetIntArrayElements(pixels,0);
int* pixelsp = pointer1;

bitmap = new unsigned char[width*height];
for (long i = 0; i < width * height; i++)
{
bitmap[i]= pointer1[i];
}

image1.setFromPixels(bitmap,width,height,ofImageType::OF_IMAGE_GRAYSCALE,false);
ofBackground(255,255,255);

draw function:
ofSetColor( 0, 0, 255 );
image1.draw(50,50,96,96);