diff --git a/Lib/Image.HC b/Lib/Image.HC index 0146938..1904c62 100644 --- a/Lib/Image.HC +++ b/Lib/Image.HC @@ -1,9 +1,12 @@ class CAnimation { CDC **frame; - I32 **delays; + CSprite **sprite; + I64 *delays; I64 total_frames; I64 current_frame; I64 ticks; + CDocEntry *de; + CTask *task; }; class @animation { @@ -45,11 +48,11 @@ I64 @cbgr24_to_4_bit(CBGR24 *ptr, Bool dither_probability) { } else { if (SqrI64(ptr->r) + SqrI64(ptr->g) + SqrI64(ptr->b) >= SqrI64(0x80)) { res = 8; - if (ptr->r >= 0xC0) + if (ptr->r >= 0x80) res |= RED; - if (ptr->g >= 0xC0) + if (ptr->g >= 0x80) res |= GREEN; - if (ptr->b >= 0xC0) + if (ptr->b >= 0x80) res |= BLUE; } else { res = 0; @@ -123,7 +126,7 @@ U8 *@stbi_load_from_memory(U8 *buffer, I64 len, I64 *x, I64 *y, return *HOLYC_RES(U64 *); } -U8 *@tgl_load_gif_from_memory(U8 *buffer, I64 len, I64 **delays, I64 *x, I64 *y, +U8 *@tgl_load_gif_from_memory(U8 *buffer, I64 len, U64 delays, I64 *x, I64 *y, I64 *z) { *GCC_FUNC_ADDR(U64 *) = Animation.func_addr[0]; *HOLYC_ARG1(U64 *) = buffer; @@ -209,6 +212,7 @@ CDC *@image_from_buffer(U8 *buffer, I64 len) { return dc; } +/* CAnimation *@animation_load(U8 *filename) { if (!filename || !FileFind(filename)) { PrintErr("Animation file not found.\n"); @@ -221,7 +225,7 @@ CAnimation *@animation_load(U8 *filename) { I32 z; I64 cnt = 0; I32 comp; - I32 **delays; + U64 delays; U8 *buffer = FileRead(filename, &len); I32 code = @stbi_info_from_memory(buffer, len, &x, &y, &comp); if (code != 1 || MemCmp(buffer, "GIF89a", 6)) { @@ -230,7 +234,7 @@ CAnimation *@animation_load(U8 *filename) { return NULL; } CAnimation *anim = CAlloc(sizeof(CAnimation)); - U8 *pixels = @tgl_load_gif_from_memory(buffer, len, delays, &x, &y, &z); + U8 *pixels = @tgl_load_gif_from_memory(buffer, len, &delays, &x, &y, &z); Free(buffer); CDC *sheet = @image_generate_dc_from_pixels(pixels, x, y * z); Free(pixels); @@ -245,6 +249,7 @@ CAnimation *@animation_load(U8 *filename) { DCDel(sheet); return anim; } +*/ CAnimation *@animation_from_buffer(U8 *buffer, I64 len) { I64 i; @@ -253,7 +258,6 @@ CAnimation *@animation_from_buffer(U8 *buffer, I64 len) { I32 z; I64 cnt = 0; I32 comp; - I32 **delays; I32 code = @stbi_info_from_memory(buffer, len, &x, &y, &comp); if (code != 1 || MemCmp(buffer, "GIF89a", 6)) { PrintErr("Animation type not supported.\n"); @@ -261,16 +265,17 @@ CAnimation *@animation_from_buffer(U8 *buffer, I64 len) { return NULL; } CAnimation *anim = CAlloc(sizeof(CAnimation)); - U8 *pixels = @tgl_load_gif_from_memory(buffer, len, delays, &x, &y, &z); - Free(buffer); + U8 *pixels = @tgl_load_gif_from_memory(buffer, len, NULL, &x, &y, &z); CDC *sheet = @image_generate_dc_from_pixels(pixels, x, y * z); Free(pixels); anim->total_frames = z; anim->frame = CAlloc(sizeof(CDC *) * anim->total_frames); - anim->delays = delays; + anim->sprite = CAlloc(sizeof(CSprite *) * anim->total_frames); + anim->delays = CAlloc(sizeof(I64) * anim->total_frames); for (i = 0; i < anim->total_frames; i++) { anim->frame[i] = DCNew(x, y); GrBlot(anim->frame[i], 0, -(cnt), sheet); + anim->sprite[i] = DC2Sprite(anim->frame[i]); cnt += y; } DCDel(sheet); @@ -278,6 +283,6 @@ CAnimation *@animation_from_buffer(U8 *buffer, I64 len) { } Animation.FromBuffer = &@animation_from_buffer; -Animation.Load = &@animation_load; +// Animation.Load = &@animation_load; Image.FromBuffer = &@image_from_buffer; Image.Load = &@image_load;