diff --git a/src/animation.c b/src/animation.c index 8ec6bd5..efd18a5 100644 --- a/src/animation.c +++ b/src/animation.c @@ -12,6 +12,7 @@ static Animation first, last; typedef struct _HeliTexture { const char *key; unsigned int id; + int w, h; int own; int refcount; } HeliTexture; @@ -369,6 +370,8 @@ static HeliTexture* loadTexture(const char *key) { unsigned char *pixels = NULL; if (imageLoad(key+3, &w, &h, &pixels)) { texture->id = imageToGLTextureEx(w, h, pixels, key[1] == 'W', key[2] == 'W', key[0] == 'L', TRUE); + texture->w = w; + texture->h = h; free(pixels); } } @@ -518,6 +521,25 @@ Animation animationCloneEx(Animation animation, int from, int to) { Animation animationClone(Animation animation) { return animationCloneEx(animation, 0, animationGetFramesCount(animation)); } +int animationGetFrameOrigWidth(Animation animation, int frame) { + int count = animationGetFramesCount(animation); + if (frame < 0 || frame >= count) return 0; + HeliTexture *texture = (HeliTexture*)animation->frames.items[frame].value; + return texture->w; +} + +int animationGetFrameOrigHeight(Animation animation, int frame) { + int count = animationGetFramesCount(animation); + if (frame < 0 || frame >= count) return 0; + HeliTexture *texture = (HeliTexture*)animation->frames.items[frame].value; + return texture->h; +} + +int animationGetOrigWidth(Animation animation) + { return animationGetFrameOrigWidth(animation, animationGetFrame(animation)); } +int animationGetOrigHeight(Animation animation) + { return animationGetFrameOrigHeight(animation, animationGetFrame(animation)); } + unsigned int animationGetFrameGLTexId(Animation animation, int frame) { int count = animationGetFramesCount(animation); if (frame < 0 || frame >= count) return 0; diff --git a/src/animation.h b/src/animation.h index 8f9a401..53aa80f 100644 --- a/src/animation.h +++ b/src/animation.h @@ -39,6 +39,11 @@ void animationDestroy(Animation animation); Animation animationClone(Animation animation); Animation animationCloneEx(Animation animation, int start, int count); +int animationGetOrigWidth(Animation animation); +int animationGetOrigHeight(Animation animation); +int animationGetFrameOrigWidth(Animation animation, int frame); +int animationGetFrameOrigHeight(Animation animation, int frame); + unsigned int animationGetGLTexId(Animation animation); unsigned int animationGetFrameGLTexId(Animation animation, int frame); void animationGLTexIdSetOwnership(unsigned int texid, int own);