Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

LolActivity.java 1.8 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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; /* NativeActivity */
  12. import android.os.Bundle; /* Bundle */
  13. import android.content.res.AssetManager; /* getAssets() */
  14. import android.graphics.Bitmap;
  15. import android.graphics.BitmapFactory;
  16. public class LolActivity extends NativeActivity
  17. {
  18. static
  19. {
  20. /* Need to preload libstlport_shared.so somewhere; also need to
  21. * preload lib@PROGRAM@.so otherwise nativeInit() can’t be found. */
  22. System.loadLibrary("stlport_shared");
  23. System.loadLibrary("@PROGRAM@");
  24. }
  25. @Override
  26. protected void onCreate(Bundle saved_instance)
  27. {
  28. super.onCreate(saved_instance);
  29. m_assets = getAssets();
  30. nativeInit(m_assets);
  31. }
  32. private native void nativeInit(AssetManager assets);
  33. private AssetManager m_assets;
  34. /*
  35. * Bitmap loading helpers
  36. */
  37. public Bitmap openImage(String name)
  38. {
  39. try
  40. {
  41. return BitmapFactory.decodeStream(m_assets.open(name));
  42. }
  43. catch (Exception e) { }
  44. return null;
  45. }
  46. public int getWidth(Bitmap bmp) { return bmp.getWidth(); }
  47. public int getHeight(Bitmap bmp) { return bmp.getHeight(); }
  48. public void getPixels(Bitmap bmp, int[] pixels)
  49. {
  50. int w = bmp.getWidth();
  51. int h = bmp.getHeight();
  52. bmp.getPixels(pixels, 0, w, 0, 0, w, h);
  53. }
  54. public void closeImage(Bitmap bmp)
  55. {
  56. bmp.recycle();
  57. }
  58. }