VTM how to get texture item from atlas

49 views
Skip to first unread message

szan...@gmail.com

unread,
Jul 8, 2017, 11:08:12 AM7/8/17
to mapsforge-dev
Hi,

I want one texture from textureatlas, but I get all. The atlas file is ok, it contains my images
I do this:


private Bitmap getBitmap(int resId){
Drawable d = mContext.getResources().getDrawable(resId);
Bitmap bmp = drawableToBitmap(d);
return bmp;
}

// Create Atlas from Bitmaps
java.util.Map<Object, Bitmap> inputMap = new LinkedHashMap<>();
java.util.Map<Object, TextureRegion> regionsMap = new LinkedHashMap<>();
List<TextureAtlas> atlasList = new ArrayList<>();

inputMap.put("101", getBitmap(R.drawable.ic_traditional));
inputMap.put("102", getBitmap(R.drawable.ic_multi));

TextureAtlasUtils.createTextureRegions(inputMap, regionsMap, atlasList, true, false);


I want the "101" element:
TextureItem t = mRegionsMap.get("101").texture;

The result is the full atlas image not just the "101". It is ok?

What is the correct way to get texture from atlas?

Best regards,
Laszlo

Emux

unread,
Jul 8, 2017, 12:10:07 PM7/8/17
to mapsfo...@googlegroups.com, szan...@gmail.com
Texture atlas purpose is to have all images packed in one texture, seen as one unit by OpenGL.

So a TextureRegion contains a reference to atlas texture and the coordinates for the bitmap's region located in the texture.

e.g. in AtlasMarkerOverlayActivity the MarkerSymbol(s) are created with a TextureRegion as parameter

Then internally those are processed and worked to visualize the relevant bitmap.

Do you mean to extract the Bitmap as separate image from the atlas?

--
Emux

szan...@gmail.com

unread,
Jul 8, 2017, 2:34:20 PM7/8/17
to mapsforge-dev, szan...@gmail.com
Yes, it is what I want.

Emux

unread,
Jul 8, 2017, 2:47:48 PM7/8/17
to mapsfo...@googlegroups.com, szan...@gmail.com
Storing a bitmap in a texture atlas implies that you first have read it.

So why not using it directly?

--
Emux

szan...@gmail.com

unread,
Jul 8, 2017, 3:34:21 PM7/8/17
to mapsforge-dev, szan...@gmail.com
I just tried to work or not,   Now Í use a Map<K,V> that contains bitmaps instead of textureatlas, because this is enough for me.
Reply all
Reply to author
Forward
0 new messages