Thank you! That finally works correctly with my testcase!
What I'm using this for:
Basically the voxel rendering works as following:
(1) A batch of voxel sides (that look into one direction on the same plane) are converted into a polygon.
(2) The polygon is converted into triangles. Each triangle can contain different colors (because it might span more than one voxel). Now we need to find or create a texture that can be used for this triangle.
(3) Complex algorithm determines whether there is an available triangle. If there is not, a new texture is created. It might be beneficial to reorganize textures (this is done with idle capacity). For this reorganization I was estimating the size of the texture by using the dimensions, but that wasn't very accurate. Much cleaner to get the real size (this will even be accurate if you ever update the internal structure of the Texture object).
Why do I even bother with this? Well, if voxel contain only a single color it's no problem at all. But they can also be textured and in that case you run out of memory faster than you can say "Texture".