android - What is the best way to load files from an expansion file in the NDK -
i wrote native android app use opengl es , apk expansion file because it's greater 50mb. textures in .obb file , load in java (with apkexpansionsupport).
here method load image expansion
public static bitmap getimagewithname(string a_path) { bitmap t_image = null; try { inputstream t_inputstream = expansionfile.getinputstream(a_path); t_image = bitmapfactory.decodestream(t_inputstream); t_inputstream.close(); } catch (exception e) { log.e(log_tag, e.getmessage()); } return t_image; }
and here jni method image :
bimage * wfileloader::getimage(const bstring& a_path, filelocation a_location) { ... jmethodid javamethod = env->getstaticmethodid(cls, "getimagewithname","(ljava/lang/string;i)landroid/graphics/bitmap;"); if( javamethod ) { jobject t_bitmap = env->callstaticobjectmethod(cls, javamethod, t_path, t_location); if(t_bitmap) { jclass t_bitmapclass = env->findclass("android/graphics/bitmap"); jmethodid t_getwidthmethod = env->getmethodid(t_bitmapclass, "getwidth", "()i"); jmethodid t_getheightmethod =env->getmethodid(t_bitmapclass, "getheight", "()i"); jint t_width = env->callintmethod(t_bitmap,t_getwidthmethod); jint t_height = env->callintmethod(t_bitmap,t_getheightmethod); jmethodid t_getpixelsmethod = env->getmethodid(t_bitmapclass, "getpixels", "([iiiiiii)v"); jintarray t_intbuffer = env->newintarray(t_width*t_height); jint t_offset = 0; jint t_stride = t_width; jint t_x = 0; jint t_y=0; env->callvoidmethod(t_bitmap,t_getpixelsmethod,t_intbuffer,t_offset,t_stride,t_x,t_y,t_width,t_height); .... } } ... }
the texture loading long , takes 30% of cpu time (bitmapfactory.decodestream takes larger part). has better solution load ?
i'm trying use zzip solve problem.
Comments
Post a Comment