Advertisement
Caiwan

Untitled

Oct 22nd, 2011
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. JNIEXPORT int JNICALL Java_com_csnc_CSNC_render(JNIEnv * env, jobject obj, jobject bitmap){
  2. mainloop();
  3.  
  4. AndroidBitmapInfo info;
  5. void* pixels;
  6. int ret;
  7. //lock pixels
  8.  
  9. if ((ret = AndroidBitmap_getInfo(env, bitmap, &info)) < 0) {
  10. return 0;
  11. }
  12.  
  13. if (info.format != ANDROID_BITMAP_FORMAT_RGBA_8888) {
  14. return 0;
  15. }
  16.  
  17. if ((ret = AndroidBitmap_lockPixels(env, bitmap, &pixels)) < 0) {
  18. return 0;
  19. }
  20.  
  21. //copy vram
  22. uint32_t *cvram = (uint32_t*) pixels;
  23.  
  24. for (register int i=0; i<SCREEN_WIDTH*SCREEN_HEIGHT; i++){
  25. color_t col = palette[vram[i]];
  26. cvram[i] = (uint32_t) (
  27. col.r |
  28. col.g << 8 |
  29. col.b << 16 |
  30. 0xFF000000 );
  31. }
  32.  
  33. //unlock pixels
  34. AndroidBitmap_unlockPixels(env, bitmap);
  35.  
  36. return 1;
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement