Changeset 722


Ignore:
Timestamp:
Mar 4, 2011, 5:03:57 PM (10 years ago)
Author:
sam
Message:

android: use assets instead of resources. They're almost the same.

Location:
trunk/monsterz/android
Files:
1 added
1 edited
26 moved

Legend:

Unmodified
Added
Removed
  • trunk/monsterz/android/src/org/zoy/LolEngine/LolActivity.java

    r720 r722  
    1717import android.content.Context;
    1818import android.content.pm.ActivityInfo;
     19import android.content.res.AssetManager; /* getAssets() */
    1920import android.content.res.Resources; /* getResources() */
    2021import android.graphics.Bitmap;
     
    7071    public Bitmap openImage(String name)
    7172    {
    72         BitmapFactory.Options opts = new BitmapFactory.Options();
    73         opts.inScaled = false;
    74         /* Get rid of both the path and the extension */
    75         name = name.replaceAll("(^.*/|[.][^.]*$)", "");
    76         int id = getResources().getIdentifier(name, "raw", "org.zoy.LolEngine");
    77         return BitmapFactory.decodeResource(getResources(), id, opts);
     73        /* Get rid of the path for now */
     74        name = name.replaceAll("^.*/", "");
     75        try
     76        {
     77            return BitmapFactory.decodeStream(getAssets().open(name));
     78        }
     79        catch (Exception e) { }
     80        return null;
    7881    }
    7982
Note: See TracChangeset for help on using the changeset viewer.