size_t bytesPerLine;
uint32_t curColor = UINT32_MAX;
-void initAnimation(size_t w, size_t h)
+void setAnimationSize(size_t w, size_t h)
{
width = w;
height = h;
bytesPerLine = width * sizeof(uint32_t);
+
+ if (buffer != NULL) freeAnimation();
buffer = (uint32_t*)calloc(bytesPerLine * height, sizeof(uint32_t));
}
-void setAnimation(char* path, size_t w, size_t h)
+void setAnimation(char* path, size_t* w, size_t* h)
{
anim = Animation::loadFromFile(path);
+ anim->size(*w, *h);
+ setAnimationSize(*w, *h);
}
uint32_t* renderRLottieAnimation(uint32_t frameNum)
#pragma once
#include <stdint.h>
-void setAnimation(char* path, size_t w, size_t h);
-void initAnimation(size_t w, size_t h);
+void setAnimation(char* path, size_t* w, size_t* h);
+void setAnimationSize(size_t w, size_t h);
uint32_t* renderRLottieAnimation(uint32_t frameNum);
size_t getTotalFrame();
bool isAnimNULL();
UINT curFrame = 0;
RlottieBitmap anim; // rendered Animation Bitmap
RECT animRect, backRect;
+size_t animWidth, animHeight;
Gdiplus::Color backColor(255, 255, 255, 255);
Gdiplus::Color borderColor(255, 0, 0, 0);
bool isBackgroundChanged = false;
case WM_CREATE:
{
initUIControl(hWnd);
- initAnimation(BMP_MAX_LEN, BMP_MAX_LEN);
break;
}
case WM_TIMER:
USES_CONVERSION;
LPSTR path = W2A(ofn.lpstrFile);
- setAnimation(path, BMP_MAX_LEN, BMP_MAX_LEN);
+ setAnimation(path, &animWidth, &animHeight);
// init play slider
SendMessage(hSliderPlay, TBM_SETRANGE, FALSE, MAKELPARAM(0, getTotalFrame()));
SendMessage(hSliderPlay, TBM_SETPOS, TRUE, 0);
memset(&Info, 0, sizeof(Info));
Info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- Info.bmiHeader.biWidth = 500;
- Info.bmiHeader.biHeight = 500;
+ Info.bmiHeader.biWidth = width;
+ Info.bmiHeader.biHeight = height;
Info.bmiHeader.biPlanes = 1;
Info.bmiHeader.biBitCount = 32;
Info.bmiHeader.biCompression = BI_RGB;
// render
UINT* resRender = renderRLottieAnimation(curFrame);
- anim.image = CreateBitmap(resRender, BMP_MAX_LEN, BMP_MAX_LEN);
+ anim.image = CreateBitmap(resRender, animWidth, animHeight);
anim.image->RotateFlip(RotateNoneFlipY);
// call WM_PAINT message
InvalidateRect(mainWindow, &animRect, FALSE);