How do I find out size of a frame in an image?

Started by
0 comments, last by Evil Steve 15 years, 3 months ago
I'm new to programming, I am going to use some freeware art from the web. My goal is to make a 2D player that walks around the screen. All the frames are on one image, it appears the artist have lined them up in a grid, but how do i get the width/height of them?
Advertisement
Quote:Original post by DrinkMoreWater
I'm new to programming, I am going to use some freeware art from the web.
My goal is to make a 2D player that walks around the screen. All the frames are on one image, it appears the artist have lined them up in a grid, but how do i get the width/height of them?
Offline, you can just manually count the number of pixels from one frame to the next.

If you want to do it at runtime, you have a couple of options:
1. Hard code the number of columns of frames, and when you load the image you can tell grid_size = image_width / num_colums;
2. Give each grid cell a magenta or other "obvious" coloured border, then read the pixels from the frame up until you hit magenta.

This topic is closed to new replies.

Advertisement