Auto Clipping from images

I can currently clip images from a large bitmap but it’s going to get bit boring if I have to specify each images x,y cords for every images (items, armors, NPcs) possibly thousands of images. Is there a way to auto detect and or auto clip, cull these images from each large image file. An stop at the end of the image.

Not looking for you to do the work for me just a general idea or point me in the right direction would be helpful :slight_smile: using C++ forgot to mention. Have a great day folks!

Where are the images coming from? If it’s from separate individual images, something like TexturePacker will combine them into one big one and output a JSON file that says where they are etc

If you are drawing them directly on one big image and they’re all the same size you can just slice it up in your program. If they’re different sizes then yeah, you’ve got some manual work ahead of you. Would be better to make them as individual images and combine them with TexturePacker or whip up your own tool using something like stb_rect_pack.

stb_rect_pack Is exactly what I’m looking for thanks! Have you used this with SDL2? I’m doing a bit of research.

Yes, it’s graphics API neutral.

I would recommend baking all your images to one (or a few) texture atlases when your game is built and saving where they are, clipping information, etc., to a file (I use JSON for Modern C++ ) and then just shipping the atlases and info file, rather than building it at runtime in your game.