1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
|
setup() function:
{
jclass bitmapConfig = (*env)-> FindClass(env,"android/graphics/Bitmap$Config");
jfieldID rgba8888FieldID = (*env)->GetStaticFieldID(env,bitmapConfig, "ARGB_8888", "Landroid/graphics/Bitmap$Config;");
jobject rgba8888Obj = (*env)->GetStaticObjectField(env,bitmapConfig, rgba8888FieldID);
jclass mediadataret = (*env) -> FindClass(env,"android/media/MediaMetadataRetriever");
jmethodID medID = (*env)->GetMethodID(env,mediadataret,"<init>","()V");
jstring str1 = (*env)->NewStringUTF (env, "/storage/emulated/0/deneme1/MOV_0270.mp4" ) ;
(*env)->CallVoidMethod(env,mediadatart,medID2,str1);
jclass classbitmap = (*env)->FindClass(env,"android/graphics/Bitmap");
jmethodID createBitmapMethodID = (*env)()-> GetStaticMethodID(env,classbitmap,"createBitmap",
(IILandroid/graphics/Bitmap$Config;)
Landroid/graphics/Bitmap;");
jobject bitmap1= (*env)->CallStaticObjectMethod(env,classbitmap, createBitmapMethodID, _width,_height, rgba8888Obj);
jmethodID medID3 = (*env)->GetMethodID(env,mediadataret,"getFrameAtTime","(J)Landroid/graphics/Bitmap;");
bitmap1 = (*env)->CallObjectMethod(env,mediadatart,medID3,framenum);
jmethodID metID4 = (*env)->GetMethodID(env,classbitmap,"getPixels","([IIIIIII)V");
jmethodID widthget = (*env)->GetMethodID(env,classbitmap,"getWidth","()I");
jmethodID heightget = (*env)->GetMethodID(env,classbitmap,"getHeight","()I");
jlong framenum=7*1000;
jint offset=0;
jint stride=1;
jint x=0;
jint y=0;
jint width= (*env)->CallIntMethod(env,bitmap1,widthget);
jint height = (*env)->CallIntMethod(env,bitmap1,heightget);
jintArray pixels = (*env)->NewIntArray(env,width * height*4);
(*env)-> CallVoidMethod(env, bitmap1,metID4,pixels,offset,width,x,y,width,height);
int* pixelsp = new int[width*height*4];
(*env)->GetIntArrayRegion(env,pixels,0,width*height,pixelsp);
bitmap = new unsigned char[width*height*4];
for (int y=0; y<height; y++) {
for (int x=0; x<width; x++) {
int index = 4 * ( x + width * y );
unsigned char red = pixelsp[index]>>16 ;
unsigned char green = pixelsp[index+1 ]>>8;
unsigned char blue = pixelsp[index+2];
unsigned char alpha = pixelsp[index+3] >> 24;
bitmap[index]=red;
bitmap[index+1]=green;
bitmap[index+2]=blue;
bitmap[index+3]=alpha;
}
}
image1.setFromPixels(bitmap, width, height, ofImageType::OF_IMAGE_COLOR_ALPHA,true);
ofBackground(255,255,255);
width__=width;
height__=height;
}
draw() function:
{
ofSetColor( 255, 255, 255 );
image1.draw(50,50,width__,height__);
|