You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

66 lines
1.5 KiB

  1. //
  2. // Lol Engine
  3. //
  4. // Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net>
  5. // This program is free software; you can redistribute it and/or
  6. // modify it under the terms of the Do What The Fuck You Want To
  7. // Public License, Version 2, as published by Sam Hocevar. See
  8. // http://www.wtfpl.net/ for more details.
  9. //
  10. package net.lolengine;
  11. import android.app.NativeActivity;
  12. import android.content.res.AssetManager; /* getAssets() */
  13. import android.graphics.Bitmap;
  14. import android.graphics.BitmapFactory;
  15. public class LolActivity extends NativeActivity
  16. {
  17. static
  18. {
  19. /* Need to preload libstlport_shared.so somewhere; also need to
  20. * preload lib@PROGRAM@.so otherwise nativeInit() can’t be found. */
  21. System.loadLibrary("stlport_shared");
  22. System.loadLibrary("@PROGRAM@");
  23. }
  24. public LolActivity()
  25. {
  26. nativeInit();
  27. }
  28. private native void nativeInit();
  29. /*
  30. * Bitmap loading helpers
  31. */
  32. public Bitmap openImage(String name)
  33. {
  34. try
  35. {
  36. return BitmapFactory.decodeStream(getAssets().open(name));
  37. }
  38. catch (Exception e) { }
  39. return null;
  40. }
  41. public int getWidth(Bitmap bmp) { return bmp.getWidth(); }
  42. public int getHeight(Bitmap bmp) { return bmp.getHeight(); }
  43. public void getPixels(Bitmap bmp, int[] pixels)
  44. {
  45. int w = bmp.getWidth();
  46. int h = bmp.getHeight();
  47. bmp.getPixels(pixels, 0, w, 0, 0, w, h);
  48. }
  49. public void closeImage(Bitmap bmp)
  50. {
  51. bmp.recycle();
  52. }
  53. }