0

How to create texture directly from expansion files. We get InputStream, now how to use this Input Stream. If I convert in bitmap and then use it start giving outofmemory.

I have tried

ZipResourceFile expansionFile = APKExpansionSupport.getAPKExpansionZipFile(appContext,
    mainVersion, patchVersion);

InputStream fileStream = expansionFile.getInputStream(pathToFileInsideZip);
voidRy
  • 674
  • 9
  • 20

1 Answers1

0

You can create as follows:

File imageFile = new File(imagePath);
BitmapTextureAtlas mBitmapTextureAtlas = new BitmapTextureAtlas(
            activity.getTextureManager(), 1024, 1024, TextureOptions.BILINEAR);
IBitmapTextureAtlasSource fileTextureSource = FileBitmapTextureAtlasSource
                    .create(imageFile);
ITextureRegion textureRegion = BitmapTextureAtlasTextureRegionFactory
            .createFromSource(mBitmapTextureAtlas, fileTextureSource, 0, 0);

Memory management:

  1. Give the texture Atlas size relative to your image size. For Example if your image size is 200X200 then give as 256 X 256 otherwise giving texture more makes wastage of memory.
  2. And also unload the textures when ever these are not needed.
Rama
  • 1,156
  • 1
  • 7
  • 13