skia project run in Android.4.2, Does there exists difference define in Android 4.2 and Android 2.2?

I try to display YUV video on the Andorid In Android 2.2 version, it is OK however in Android 4.2 the screen is total black

In the project, I use JAVA to display the content of image and use jni to read YUV and return the YUV data back to JAVA

The following is my jni code #include "SkiaDemoJni.h" #include "mylog.h"

#include "GraphicsJNI.h"
#include "SkPaint.h"
#include "SkCanvas.h"

#include <wchar.h>
#include <android\log.h> 
#include <android\bitmap.h>

#define two_pi (6.283)

unsigned char cur_image_y[101376];
unsigned char cur_image_u[101376];
unsigned char cur_image_v[101376];

inline int32_t color(int32_t pColorY,int32_t pColorU,int32_t pColorV) {
int32_t pColorR;
int32_t pColorG;
 int32_t pColorB;
 pColorR = pColorY+1.4075*(pColorV-128);
 pColorG = pColorY-0.3455*(pColorU-128)-0.7169*(pColorV-128);
 pColorB = pColorY+1.7790*(pColorU-128);


 return 0xFF000000 | ((pColorB << 16) & 0x00FF0000) | ((pColorG << 8) & 0x0000FF00) |       
 ((pColorR) & 0x000000FF);
  void Java_com_whtr_example_skiademo_SkiaView_renderHello(JNIEnv *env, jobject thizz,     
  jobject canvas, jint FrameNum,jobject rect)
  jclass bitmapConfig = env->FindClass("android/graphics/Bitmap$Config");
  jfieldID rgb565FieldID = env->GetStaticFieldID(bitmapConfig, "ARGB_8888",   
  jobject rgb565Obj = env->GetStaticObjectField(bitmapConfig, rgb565FieldID); 

  jclass bitmapClass = env->FindClass("android/graphics/Bitmap");
  jmethodID createBitmapMethodID = env->GetStaticMethodID(bitmapClass,"createBitmap", 
  jobject bitmapObj = env->CallStaticObjectMethod(bitmapClass, createBitmapMethodID,  
  352, 288, rgb565Obj);//width,height 
  int a[101376]={0};
  AndroidBitmapInfo   info;   
  int*                pixels;
  int                ret;    
  ret = AndroidBitmap_getInfo(env, bitmapObj, &info);    
  ret = AndroidBitmap_lockPixels(env, bitmapObj, (void**)&pixels);       
  int                width=(int)info.width;  
  int                height=(int)info.height;
  SkBitmap bmp = SkBitmap();  
  SkCanvas background(bmp);
  SkCanvas* canv = GraphicsJNI::getNativeCanvas(env, canvas);
  if (!canv)
   systemPara sys;   

  sys.width = 352;

  sys.height = 288;
  sys.frameNO = 1;
  sys.startFrm = 0;
  sys.inFileName = new char[strlen("/mnt/sdcard/out_352x288_P420_final.yuv")+1];
  strcpy(sys.inFileName, "/mnt/sdcard/out_352x288_P420_final.yuv");
  for(int i=0;i<sys.frameNO;i++){
   //sys.startFrm = i;
   YUV_play_read(cur_image_y, cur_image_u, cur_image_v, sys.inFileName, sys.width, sys.height, FrameNum);
   for(int x=0;x<sys.width;x++){
    for(int y=0;y<sys.height;y++){
        a[x + y * 352] = color(cur_image_y[x + y * 352], cur_image_u[x + y * 352], cur_image_v[x + y *   352]);
  pixels = a;
  AndroidBitmap_unlockPixels(env, bitmapObj);
  canv->drawBitmap(bmp, 0, 0, NULL);



You need to make sure your are not using hardware rendering, by:

  1. call view.setLayerType(LAYER_TYPE_SOFTWARE, null); or set android:hardwareAccelerated="false" in your application section of your AndroidManifest.xml

  2. Go to the developer options, and uncheck "force GPU rendering"

Need Your Help

UpdatePanel - Show errors from server-side into client side div

c# updatepanel

I have an updatePanel with asp:button inside it. Now on the button click, I am doing validations and wants to print the message to the screen. I want to show the message in the client side &lt;div&...

popup not showing in jquery code


I have a piece of code of jquery but I can't make it run in a HTML page.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.