- Home /
Breaking a big Texture2D into smallers
Hello all, I have a image with dimensions of 320 x 320 with some smaller images and I want to get these images of 64 x 64
I found some topics about creating an atlas, but the explanations were using smaller images and generating the bigger. [edit] Example:
I have this image (100 x 100):

I want to break it in 4 textures of 50x50 (on the lines).
Like: Tex1 = circle; Tex2 = red rectangle; ...
What can I do? Thanks in advance and sorry my bad english.
Your question is confusing. You need more detail about what you are trying to do. A texture atlas can have images of any size. I've used a 4$$anonymous$$ x 4$$anonymous$$ atlas for a dedicated iPad 3 app that had a mixture of both big and small images. If you are talking about just resizing images down, that is best done in a image editing program like Photoshop.
It is clearer. Do you want to do this at edit time or runtime? Do you need to break it apart into separate textures or is it good enough to display each quadrant on a separate game object? It would help to know what you are trying to do with them? In a way a texture atlas does what you are asking. It takes an atlas of several images and uses part of that atlas in display a game object.
I'm trying to make one image with all my icons and display only the one that I need using GUI.Label. So I think that I can break it on script start
Answer by robertbu · Jul 08, 2013 at 08:25 PM
Breaking an image apart at runtime is a bit ugly and you may increase your texture usage (i.e. have the 'atlas' plus the new textures plus any overhead associated with having a texture read/write enabled). There is an example of how create a new image from a rectangle in the reference page for Texture2D.GetPixels(). If you do implement this way, you will need to mark your texture as read/write enabled. Also I recommend you use Texture2D.GetPixels32() rather than GetPixels().
A potential alternate solution is to use Graphics.DrawTexture(). Based on the reference page, it should do the job of displaying a portion of a texture, but I've not verified that it will work the way you want.
A better solution (from a performance and memory usage standpoint) would be use place your image on a plane. Then you could use material settings or modify the UV coordinates in the mesh to display part of the image.
Your answer