Subversion Repositories AndroidProjects

Rev

Rev 187 | Blame | Compare with Previous | Last modification | View Log | RSS feed

package com.gebauz.Bauzoid.graphics.texture;

import java.io.IOException;

import android.content.res.Resources;
import android.graphics.Bitmap;

import com.gebauz.Bauzoid.file.File;
import com.gebauz.Bauzoid.file.FileUtil;
import com.gebauz.Bauzoid.graphics.Graphics;

/** Texture utilities for loading, etc. */
public class TextureUtil
{
        private TextureUtil() {}
       
        public static Texture2D loadTextureFromAsset(Graphics graphics, String asset) throws IOException
        {
                File file = FileUtil.loadFileFromAsset(graphics.getResources(), asset);
                Texture2D texture = null;
               
                try
                {
                        Bitmap bitmap = file.readBitmap();
                        texture = new Texture2D(graphics);
                        texture.loadTexture(bitmap);
                }
                finally
                {
                        file.close();
                }
               
                return texture;
        }
       
        public static Texture2D loadTextureFromResource(Graphics graphics, int id) throws IOException
        {
                File file = FileUtil.loadFileFromResource(graphics.getResources(), id);
                Texture2D texture = null;
               
                try
                {
                        Bitmap bitmap = file.readBitmap();
                        texture = new Texture2D(graphics);
                        texture.loadTexture(bitmap);
                }
                finally
                {
                        file.close();
                }
               
                return texture;
        }

       
}