Tileset BitmapData

Hello and thanks for the great haxe tools (openfl, lime, starling and others)

I am now trying to use tile (tilemap) as an option instead of Starling Haxe to support canvas,
when webgl is not available. And for using texture atlases from Texture Packer for Tiles,
i use an excellent implementation of (Sparrow Format) https://github.com/loudoweb/openfl-atlas Loudo (thank you for it). It would be great if OpenFL had the opportunity to get bitmapdata from Tile. In addition to the Assets.getBitmapData version, there was also a tileset.getBitmapData (id) version. It is not possible to use now, since class TileData is private (to access __bitmapData in TileData). What would give the option to download and use instead of a variety of images, one large format textural atlas.

Hello, and thanks for the feedback!

I am trying to understand, do you propose that tileset.getBitmapData(id) return a new BitmapData cut from the larget tileset, or do you mean that we make changes to the renderer to allow you to use a BitmapData which actually represents a sub-rectangle of a larger texture?

Thanks :slight_smile:

Access to BitmapData from Tileset. Not new, but just a link using the tile identifier.
Sub-texture from a large texture. How the code will look if class TileData is public available:

// return tile bitmapdata, use tile id
public function getBitmapData (id:Int):BitmapData
{
return this.__data[id].__bitmapData;
}

this. is Tileset, __data is Array from Tileset, __bitmapData is public var __bitmapData:BitmapData from TileData

I’m sorry for bad english :slightly_smiling_face: Thanks for trying to understand me !

So given this scenario:

var bitmapData = new BitmapData (200, 100);
var tileset = new Tileset (bitmapData, [ new Rectangle (0, 0, 100, 100), new Rectangle (100, 0, 100, 100) ]);
...

What would tileset.getBitmapData (1) return?

  1. A 100x100 BitmapData
  2. A 100x100 virtual BitmapData of the larger 100x200 surface

Would it be compatible with Bitmap and other APIs that use BitmapData, or only Tilemap?

I’m sorry, I did not carefully look at the source files from the Tileset and TileData class.
__bitmapData: BitmapData in TileData used only for Flash Target, UV coordinates are stored for other targets. It turns out that you can return only a copy of bitmapdata (sub-texture) for all other targets.

On the scenario issue:
a copy of bitmapdata from the second rectangle (id = 1) must be returned, otherwise it is null.
Only for Tilemap.

In fact, it is necessary, if used in conjunction with https://github.com/loudoweb/openfl-atlas.
Which may not be the best option.
Only if you add support TextureAtlas (use https://www.codeandweb.com/texturepacker) in Asset class, if someone else will need it.

Here is a similar request https://github.com/openfl/openfl/issues/1722

The basic idea was to load several large textures for use in tiles (tilemap), without manually specifying rectangles for tile sets, such as Starling TextureAtlas, and additionally extract some images from these large textures if necessary (Texture Atlas)

This question can be closed :slightly_smiling_face:

Thanks.