public static class LuanDrawable {
}
<<<<<<< HEAD
// ***** ***** ***** ***** ***** LuanFont
public static class LuanFont {
private LuanGraphics g;
public LuanImage img;
public float w_space = 0f; // TODO: set from letter 'a' ?
public float font_h = 0f; // TODO: set from letter 'a' ? probably just the height of the whole image
public float line_h = 1f; ///< Gets the line height. This will be the value previously set by Font:setLineHeight, or 1.0 by default.
public class GlyphInfo {
public float w;
public float movex;
public float u0;
public float v0;
public float u1;
public float v1;
public GlyphInfo(float w,float movex,float u0,float u1) {
this.w = w;
this.movex = movex;
this.u0 = u0;
this.v0 = 0f;
this.u1 = u1;
this.v1 = 1f;
}
};
public HashMap mGlyphInfos = new HashMap();
public GlyphInfo getGlyphInfo (char c) { return (GlyphInfo)mGlyphInfos.get(c); }
public enum AlignMode {
CENTER, LEFT, RIGHT
};
public static AlignMode Text2Align (String s) {
if (s == "center") return AlignMode.CENTER;
if (s == "right") return AlignMode.RIGHT;
return AlignMode.LEFT;
}
public static String Align2Text (AlignMode a) {
if (a == AlignMode.CENTER) return "center";
if (a == AlignMode.RIGHT) return "right";
return "left";
}
/// ttf font
public LuanFont (LuanGraphics g,String ttf_filename,int iSize) { this.g = g; g.vm.NotImplemented("font:ttf"); }
/// ttf font, default ttf_filename to verdana sans
public LuanFont (LuanGraphics g,int iSize) { this.g = g; g.vm.NotImplemented("font:ttf"); }
/// imageFont
public LuanFont (LuanGraphics g,String filename,String glyphs) throws FileNotFoundException { this(g,new LuanImage(g,filename),glyphs); }
public static int getColAtPos (LuanImage img,int x,int y) { return 0; }
/// imageFont
public LuanFont (LuanGraphics g,LuanImage img,String glyphs) {
this.g = g;
/*
The imagefont file is an image file in a format that L�ve can load. It can contain transparent pixels, so a PNG file is preferable, and it also needs to contain spacer color that will separate the different font glyphs.
}
} else {
The upper left pixel of the image file is always taken to be the spacer color. All columns that have this color as their uppermost pixel are interpreted as separators of font glyphs. The areas between these separators are interpreted as the actual font glyphs.
The width of the separator areas affect the spacing of the font glyphs. It is possible to have more areas in the image than are required for the font in the love.graphics.newImageFont() call. The extra areas are ignored.
*/
int col = getColAtPos(img,0,0);
int x = 0;
int imgw = (int)img.mWidth;
while (getColAtPos(img,x,0) == col && x < imgw) ++x; // skip first separator column
for (int i=0;i> sd card
//~ von ressource : InputStream input = getResources().openRawResource(R.raw.androids);
//~ von sd laden : InputStreamODERSO input = openFileInput("lala.lua");
//~ GLUtils.texImage2D : http://gamedev.stackexchange.com/questions/10829/loading-png-textures-for-use-in-android-opengl-es1 (see also comments/answers)
//~ static Drawable Drawable.createFromStream(InputStream is, String srcName)
Log.i("LuanImage","constructor:"+filepath);
// TODO : throw lua error if file not found ?
InputStream input = g.vm.getStorage().getFileStreamFromSdCard(filepath);
//g.getActivity().openFileInput(filepath);
//~ Drawable d = Drawable.createFromStream(input,filepath);
Log.i("LuanImage","InputStream ok");
BitmapDrawable bmd = new BitmapDrawable(g.vm.getResources(),input); // ressources needed for "density" / dpi etc ? no idea
Log.i("LuanImage","BitmapDrawable ok");
Bitmap bm = bmd.getBitmap();
Log.i("LuanImage","Bitmap ok w="+bm.getWidth()+",h="+bm.getHeight());
mWidth = bm.getWidth();
mHeight = bm.getHeight();
// TODO : auto-scale to 2^n resolution ? naaaah.
// bitmap loaded into ram
// load into texture
LoadFromBitmap(bm);
Log.i("LuanImage","LoadFromBitmap done.");
// release bitmap ram
bm.recycle();
Log.i("LuanImage","constructor done.");
}
}
=======
>>>>>>> 2aa8599dac3a9f0fc64c74037dde329e9f96d20c
}
|