Sign in to follow this  
DrinkMoreWater

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

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this