How to crop blank rows in the middle of an image in XNA?

97 views Asked by At

Let's say I have a Texture2D containing a single strip of a character's animation. The bottom line of that strip has dots in a certain color, a color which is not used anywhere else in the strip, at the start and end of each sprite (meaning, there's a dot at the bottom of the blank row before and after each sprite).

I want to crop all the blank rows in between each sprite, thus making the end of one sprite overlap the start of the other one (meaning, get the ending dot of one sprite to be the starting dot of the next). Is there any way to do this automatically with XNA?

Basically, go from this: http://i41.tinypic.com/2wdx53l.jpg (There's a blank space between each and every sprite.)

To this: http://i40.tinypic.com/10ydjde.jpg (The start of each sprite overlaps the end of the former sprite.)

(The red dots are supposed to be in the middle between every pair of blue dots, but you get the point.)

Additional information:

A. There's an int[] containing the X values of the start and end of each strip (lines), and a List<int>[] containing the X value of the start and end of each sprite for each strip (rows, individual for each strip).

B. There's another dot at the middle between the start and end of each sprite, which do not appear in the blank rows.

C. Each strip needs to be exported as a .png file (using a Texture2D array containing each strip). So far, I can export the frames (cropped) well enough, but if there's any way to staple them back together to a strip, that'd be great.

Thanks in advance, and please excuse the complicated phrasing...

1

There are 1 answers

2
pinckerman On

I don't know why you need these dots between your sprites, but if you know the width of each sprite then you only need to have a Rectangle that you move in sequence on your spritesheet (that I think you already have), and add the sprite width minus the width of that dot.
In this way you should have the ending dot of one sprite to be the starting dot of the next, as you asked.