rename directory rlottiePlayer to win32Player
authorstart1a <start3a@gmail.com>
Tue, 6 Oct 2020 06:21:16 +0000 (15:21 +0900)
committerJongmin Lee <jm105.lee@samsung.com>
Sun, 11 Oct 2020 21:09:32 +0000 (06:09 +0900)
32 files changed:
example/rlottiePlayer/Source.cpp [deleted file]
example/rlottiePlayer/animation.h [deleted file]
example/rlottiePlayer/framework.h [deleted file]
example/rlottiePlayer/resource.h [deleted file]
example/rlottiePlayer/rlottie.dll [deleted file]
example/rlottiePlayer/rlottie.lib [deleted file]
example/rlottiePlayer/rlottiePlayer.cpp [deleted file]
example/rlottiePlayer/rlottiePlayer.h [deleted file]
example/rlottiePlayer/rlottiePlayer.ico [deleted file]
example/rlottiePlayer/rlottiePlayer.rc [deleted file]
example/rlottiePlayer/rlottiePlayer.sln [deleted file]
example/rlottiePlayer/rlottiePlayer.vcxproj [deleted file]
example/rlottiePlayer/rlottiePlayer.vcxproj.filters [deleted file]
example/rlottiePlayer/rlottiePlayer.vcxproj.user [deleted file]
example/rlottiePlayer/small.ico [deleted file]
example/rlottiePlayer/targetver.h [deleted file]
example/win32Player/Source.cpp [new file with mode: 0644]
example/win32Player/animation.h [new file with mode: 0644]
example/win32Player/framework.h [new file with mode: 0644]
example/win32Player/resource.h [new file with mode: 0644]
example/win32Player/rlottie.dll [new file with mode: 0644]
example/win32Player/rlottie.lib [new file with mode: 0644]
example/win32Player/rlottiePlayer.cpp [new file with mode: 0644]
example/win32Player/rlottiePlayer.h [new file with mode: 0644]
example/win32Player/rlottiePlayer.ico [new file with mode: 0644]
example/win32Player/rlottiePlayer.rc [new file with mode: 0644]
example/win32Player/rlottiePlayer.sln [new file with mode: 0644]
example/win32Player/rlottiePlayer.vcxproj [new file with mode: 0644]
example/win32Player/rlottiePlayer.vcxproj.filters [new file with mode: 0644]
example/win32Player/rlottiePlayer.vcxproj.user [new file with mode: 0644]
example/win32Player/small.ico [new file with mode: 0644]
example/win32Player/targetver.h [new file with mode: 0644]

diff --git a/example/rlottiePlayer/Source.cpp b/example/rlottiePlayer/Source.cpp
deleted file mode 100644 (file)
index 99ea876..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-#include "rlottie.h"
-#include "animation.h"
-using namespace rlottie;
-
-std::unique_ptr<Animation> anim;
-uint32_t *buffer;
-size_t width, height;
-size_t bytesPerLine;
-uint32_t curColor = UINT32_MAX;
-
-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)
-{
-       anim = Animation::loadFromFile(path);
-    anim->size(*w, *h);
-    setAnimationSize(*w, *h);
-}
-
-uint32_t* renderRLottieAnimation(uint32_t frameNum)
-{
-       Surface surface = Surface(buffer, width, height, bytesPerLine);
-       anim->renderSync(frameNum, surface);
-       // background color
-       for (int i = 0; i < height; i++)
-        for (int j = 0; j < width; ++j)
-               {
-                       uint32_t* v = buffer + i * width + j;
-                       if (*v == 0) *v = curColor;
-               }
-       return buffer;
-}
-
-void setAnimationColor(int r, int g, int b)
-{
-       curColor = ((255 << 16) * r) + ((255 << 8) * g) + 255 * b;
-}
-
-size_t getTotalFrame()
-{
-       return anim->totalFrame();
-}
-
-bool isAnimNULL()
-{
-       return anim == NULL;
-}
-
-void freeAnimation()
-{
-    free(buffer);
-}
\ No newline at end of file
diff --git a/example/rlottiePlayer/animation.h b/example/rlottiePlayer/animation.h
deleted file mode 100644 (file)
index 483cb3f..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#pragma once
-#include <stdint.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();
-void      setAnimationColor(int r, int g, int b);
-void      freeAnimation();
\ No newline at end of file
diff --git a/example/rlottiePlayer/framework.h b/example/rlottiePlayer/framework.h
deleted file mode 100644 (file)
index 33a6be6..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-// header.h : include file for standard system include files,
-// or project specific include files
-//
-
-#pragma once
-
-#include "targetver.h"
-#define WIN32_LEAN_AND_MEAN             // Exclude rarely-used stuff from Windows headers
-// Windows Header Files
-#include <windows.h>
-// C RunTime Header Files
-#include <stdlib.h>
-#include <malloc.h>
-#include <memory.h>
-#include <tchar.h>
diff --git a/example/rlottiePlayer/resource.h b/example/rlottiePlayer/resource.h
deleted file mode 100644 (file)
index ac46939..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-//{{NO_DEPENDENCIES}}
-// This is an include file generated by Microsoft Visual C++.
-// It is being used in rlottiePlayer.rc.
-//
-#define IDC_MYICON                      2
-#define IDD_RLOTTIEPLAYER_DIALOG        102
-#define IDS_APP_TITLE                   103
-#define IDD_ABOUTBOX                    103
-#define IDM_ABOUT                       104
-#define IDM_EXIT                        105
-#define IDI_RLOTTIEPLAYER               107
-#define IDI_SMALL                       108
-#define IDC_RLOTTIEPLAYER               109
-#define IDR_MAINFRAME                   128
-#define MAIN_WINDOW                     130
-#define BTN_BROWSE                      1004
-#define BTN_WHITE                       1005
-#define BTN_BLACK                       1006
-#define BTN_RED                         1007
-#define BTN_GREEN                       1008
-#define BTN_BLUE                        1009
-#define SLIDER_CANVAS_RESIZE                   1010
-#define BTN_PLAY                        1011
-#define SLIDER_PLAY                     1012
-#define TEXT_FILENAME                   1013
-#define PICCTRL_RLOTTIE                 1014
-#define TIMER_PLAY_ANIM                                1015
-#define IDC_STATIC                      -1
-
-// Next default values for new objects
-// 
-#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NO_MFC                     1
-#define _APS_NEXT_RESOURCE_VALUE        131
-#define _APS_NEXT_COMMAND_VALUE         32771
-#define _APS_NEXT_CONTROL_VALUE         1017
-#define _APS_NEXT_SYMED_VALUE           110
-#endif
-#endif
diff --git a/example/rlottiePlayer/rlottie.dll b/example/rlottiePlayer/rlottie.dll
deleted file mode 100644 (file)
index 296f70a..0000000
Binary files a/example/rlottiePlayer/rlottie.dll and /dev/null differ
diff --git a/example/rlottiePlayer/rlottie.lib b/example/rlottiePlayer/rlottie.lib
deleted file mode 100644 (file)
index 2625916..0000000
Binary files a/example/rlottiePlayer/rlottie.lib and /dev/null differ
diff --git a/example/rlottiePlayer/rlottiePlayer.cpp b/example/rlottiePlayer/rlottiePlayer.cpp
deleted file mode 100644 (file)
index b2d0431..0000000
+++ /dev/null
@@ -1,521 +0,0 @@
-// rlottiePlayer.cpp : Defines the entry point for the application.
-//
-
-
-#include "framework.h"
-#include "rlottiePlayer.h"
-using namespace Gdiplus;
-
-#define MAX_LOADSTRING 100
-
-// Global Variables:
-HINSTANCE hInst;                                        // current instance
-WCHAR szTitle[MAX_LOADSTRING];                  // The title bar text
-WCHAR szWindowClass[MAX_LOADSTRING];            // the main window class name
-HWND mainWindow;                                    // Main Window Instance
-HWND hTextFileToBeOpened;                               // openDialog file path
-HWND hBtnPlay;
-HWND hSliderPlay, hSliderCanvasResize;
-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 isViewChanged = false;
-
-// Forward declarations of functions included in this code module:
-ATOM                MyRegisterClass(HINSTANCE hInstance);
-BOOL                InitInstance(HINSTANCE, int);
-LRESULT CALLBACK    WndProc(HWND, UINT, WPARAM, LPARAM);
-INT_PTR CALLBACK    About(HWND, UINT, WPARAM, LPARAM);
-void openJSONFileDialog(HWND);
-void initUIControl(HWND);
-void dlgUICommand(HWND, WPARAM);
-void resizeCanvas(HWND, int);
-void changeBackgroundColor(int r, int g, int b);
-
-// Animation Rendering Functions
-void draw(HDC);
-Bitmap* CreateBitmap(void* data, unsigned int width, unsigned int height);
-void renderAnimation(UINT);
-
-int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
-    _In_opt_ HINSTANCE hPrevInstance,
-    _In_ LPWSTR    lpCmdLine,
-    _In_ int       nCmdShow)
-{
-    UNREFERENCED_PARAMETER(hPrevInstance);
-    UNREFERENCED_PARAMETER(lpCmdLine);
-
-    // initialize Gdiplus
-    Gdiplus::GdiplusStartupInput gdiplusStartUpInput;
-    ULONG_PTR gdiplustoken;
-    Gdiplus::GdiplusStartup(&gdiplustoken, &gdiplusStartUpInput, nullptr);
-
-    // Initialize global strings
-    LoadStringW(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
-    LoadStringW(hInstance, IDC_RLOTTIEPLAYER, szWindowClass, MAX_LOADSTRING);
-    MyRegisterClass(hInstance);
-
-    // Perform application initialization:
-    if (!InitInstance(hInstance, nCmdShow))
-    {
-        return FALSE;
-    }
-
-    HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_RLOTTIEPLAYER));
-
-    MSG msg;
-
-    // Main message loop:
-    while (GetMessage(&msg, nullptr, 0, 0))
-    {
-        if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
-        {
-            TranslateMessage(&msg);
-            DispatchMessage(&msg);
-        }
-    }
-
-    Gdiplus::GdiplusShutdown(gdiplustoken);
-    return (int)msg.wParam;
-}
-
-
-
-//
-//  FUNCTION: MyRegisterClass()
-//
-//  PURPOSE: Registers the window class.
-//
-ATOM MyRegisterClass(HINSTANCE hInstance)
-{
-    WNDCLASSEXW wcex;
-
-    wcex.cbSize = sizeof(WNDCLASSEX);
-
-    wcex.style = CS_HREDRAW | CS_VREDRAW;
-    wcex.lpfnWndProc = WndProc;
-    wcex.cbClsExtra = 0;
-    wcex.cbWndExtra = 0;
-    wcex.hInstance = hInstance;
-    wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_RLOTTIEPLAYER));
-    wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
-    wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
-    wcex.lpszMenuName = MAKEINTRESOURCEW(IDC_RLOTTIEPLAYER);
-    wcex.lpszClassName = szWindowClass;
-    wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
-
-    return RegisterClassExW(&wcex);
-}
-
-//
-//   FUNCTION: InitInstance(HINSTANCE, int)
-//
-//   PURPOSE: Saves instance handle and creates main window
-//
-//   COMMENTS:
-//
-//        In this function, we save the instance handle in a global variable and
-//        create and display the main program window.
-//
-BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
-{
-    hInst = hInstance; // Store instance handle in our global variable
-
-    DWORD dwStyle = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX;
-    mainWindow = CreateWindowEx(0, szWindowClass, szTitle, dwStyle,
-        CW_USEDEFAULT, CW_USEDEFAULT, WND_WIDTH, WND_HEIGHT, nullptr, nullptr, hInstance, nullptr);
-
-    if (!mainWindow)
-    {
-        return FALSE;
-    }
-
-    ShowWindow(mainWindow, nCmdShow);
-    UpdateWindow(mainWindow);
-    SetMenu(mainWindow, NULL);
-
-    return TRUE;
-}
-
-//
-//  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
-//
-//  PURPOSE: Processes messages for the main window.
-//
-//  WM_COMMAND  - process the application menu
-//  WM_PAINT    - Paint the main window
-//  WM_DESTROY  - post a quit message and return
-//
-//
-LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
-{
-    static bool isplay = false;
-    int wmId = LOWORD(wParam);
-
-    switch (message)
-    {
-    case WM_CREATE:
-    {
-        initUIControl(hWnd);
-        break;
-    }
-    case WM_TIMER:
-    {
-        switch (wmId)
-        {
-        case TIMER_PLAY_ANIM:
-        {
-            renderAnimation(curFrame + 1);
-            SendMessage(hSliderPlay, TBM_SETPOS, TRUE, curFrame);
-            break;
-        }
-        default:
-            break;
-        }
-        break;
-    }
-    case WM_COMMAND:
-    {
-        // Parse the menu selections:
-        switch (wmId)
-        {
-        case IDM_ABOUT:
-            DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
-            break;
-
-        case IDM_EXIT:
-            DestroyWindow(hWnd);
-            break;
-
-        case BTN_BROWSE:
-            openJSONFileDialog(hWnd);
-            break;
-
-        case BTN_PLAY:
-        {
-            LPWSTR textBtnPlay;
-            USES_CONVERSION;
-            if (isplay)
-            {
-                isplay = false;
-                textBtnPlay = A2W("Play");
-                KillTimer(hWnd, TIMER_PLAY_ANIM);
-            }
-            else
-            {
-                isplay = true;
-                textBtnPlay = A2W("Pause");
-                SetTimer(hWnd, TIMER_PLAY_ANIM, 10, NULL);
-            }
-            SetWindowText(hBtnPlay, textBtnPlay);
-            break;
-        }
-
-        case WM_DROPFILES:
-            break;
-        case BTN_WHITE:
-            changeBackgroundColor(1, 1, 1);
-            break;
-        case BTN_BLACK:
-            changeBackgroundColor(0, 0, 0);
-            break;
-        case BTN_RED:
-            changeBackgroundColor(1, 0, 0);
-            break;
-        case BTN_GREEN:
-            changeBackgroundColor(0, 1, 0);
-            break;
-        case BTN_BLUE:
-            changeBackgroundColor(0, 0, 1);
-            break;
-
-        default:
-            return DefWindowProc(hWnd, message, wParam, lParam);
-        }
-    }
-    break;
-
-    case WM_HSCROLL:
-    {
-        if ((lParam != 0) && (reinterpret_cast<HWND>(lParam) == hSliderPlay))
-        {
-            UINT frameNum = SendDlgItemMessage(hWnd, SLIDER_PLAY, TBM_GETPOS, 0, 0);
-            renderAnimation(frameNum);
-        }
-        else if ((lParam != 0) && (reinterpret_cast<HWND>(lParam) == hSliderCanvasResize))
-        {
-            static int curSize = anim.width / RESIZE_LENGTH;
-            int newSize = SendDlgItemMessage(hWnd, SLIDER_CANVAS_RESIZE, TBM_GETPOS, 0, 0);
-            resizeCanvas(hWnd, (curSize - newSize) * RESIZE_LENGTH);
-            curSize = newSize;
-        }
-        break;
-    }
-
-    case WM_PAINT:
-    {
-        PAINTSTRUCT ps;
-        HDC hdc = BeginPaint(hWnd, &ps);
-        draw(hdc);
-        EndPaint(hWnd, &ps);
-    }
-    break;
-    case WM_CTLCOLORSTATIC:
-    {
-        static HBRUSH hBrushEdit = CreateSolidBrush(RGB(255, 255, 255));
-        return (LRESULT)hBrushEdit;
-    }
-
-    case WM_DESTROY:
-        freeAnimation();
-        PostQuitMessage(0);
-        break;
-
-    default:
-        return DefWindowProc(hWnd, message, wParam, lParam);
-    }
-    return 0;
-}
-
-// Message handler for about box.
-INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
-{
-    UNREFERENCED_PARAMETER(lParam);
-    switch (message)
-    {
-    case WM_INITDIALOG:
-        return (INT_PTR)TRUE;
-
-    case WM_COMMAND:
-        if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
-        {
-            EndDialog(hDlg, LOWORD(wParam));
-            return (INT_PTR)TRUE;
-        }
-        break;
-    }
-    return (INT_PTR)FALSE;
-}
-
-void openJSONFileDialog(HWND hDlg)
-{
-    OPENFILENAME ofn;       // common dialog box structure
-    TCHAR szFile[260] = { 0 };       // if using TCHAR macros
-
-    // Initialize OPENFILENAME
-    ZeroMemory(&ofn, sizeof(ofn));
-    ofn.lStructSize = sizeof(ofn);
-    ofn.hwndOwner = hDlg;
-    ofn.lpstrFile = szFile;
-    ofn.nMaxFile = sizeof(szFile);
-    ofn.lpstrFilter = _T("JSON\0*.json\0");
-    ofn.nFilterIndex = 1;
-    ofn.lpstrFileTitle = NULL;
-    ofn.nMaxFileTitle = 0;
-    ofn.lpstrInitialDir = NULL;
-    ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
-
-    isViewChanged = true;
-    if (GetOpenFileName(&ofn))
-    {
-        isViewChanged = true;
-        SetWindowText(hTextFileToBeOpened, ofn.lpstrFile);
-        // LPWSTR(w_char*) -> LPSTR(char*)
-        USES_CONVERSION;
-        LPSTR path = W2A(ofn.lpstrFile);
-
-        setAnimation(path, &animWidth, &animHeight);
-        // init play slider
-        SendMessage(hSliderPlay, TBM_SETRANGE, FALSE, MAKELPARAM(0, getTotalFrame()));
-        SendMessage(hSliderPlay, TBM_SETPOS, TRUE, 0);
-        renderAnimation(0);
-    }
-}
-
-void draw(HDC hdc)
-{
-    Graphics gf(hdc);
-    int half_interval = UI_INTERVAL / 2;
-
-    // background
-    SolidBrush brush(backColor);
-    int back_y = half_interval + BTN_HEIGHT;
-    int back_height = back_y + BMP_MAX_LEN + UI_INTERVAL;
-    if (isViewChanged)
-    {
-        isViewChanged = false;
-        gf.FillRectangle(&brush, 0, back_y, WND_WIDTH, back_height);
-    }
-
-    // image borderline
-    Pen pen(borderColor);
-    gf.DrawRectangle(&pen, anim.x - half_interval, anim.y - half_interval, anim.width + half_interval * 2, anim.height + half_interval * 2);
-
-    // image
-    if (anim.image != NULL)
-    {
-        gf.DrawImage(anim.image, anim.x, anim.y, anim.width, anim.height);
-    }
-}
-
-Bitmap* CreateBitmap(void* data, unsigned int width, unsigned int height)
-{
-    BITMAPINFO Info;
-    memset(&Info, 0, sizeof(Info));
-
-    Info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
-    Info.bmiHeader.biWidth = width;
-    Info.bmiHeader.biHeight = height;
-    Info.bmiHeader.biPlanes = 1;
-    Info.bmiHeader.biBitCount = 32;
-    Info.bmiHeader.biCompression = BI_RGB;
-    Info.bmiHeader.biSizeImage = 0;  //(((32 * width + 31) & ~31) / 8) * height;
-
-    return new Gdiplus::Bitmap(&Info, data);
-}
-
-void renderAnimation(UINT frameNum)
-{
-    if (isAnimNULL()) return;
-    if (anim.image != NULL) delete anim.image;
-
-    curFrame = frameNum % getTotalFrame();
-
-    // render
-    UINT* resRender = renderRLottieAnimation(curFrame);
-    anim.image = CreateBitmap(resRender, animWidth, animHeight);
-    anim.image->RotateFlip(RotateNoneFlipY);
-    // call WM_PAINT message
-    InvalidateRect(mainWindow, &animRect, FALSE);
-}
-
-void initUIControl(HWND hWnd)
-{
-    int half_ui_interval = UI_INTERVAL / 2;
-
-    // button browse
-    int browse_x = UI_INTERVAL;
-    int browse_y = half_ui_interval;
-    CreateWindow(L"button", L"Browse", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
-        browse_x, browse_y, BTN_WIDTH, BTN_HEIGHT, hWnd, (HMENU)BTN_BROWSE, hInst, NULL);
-
-    // textbox FilePath
-    int textFile_x = browse_x + BTN_WIDTH + UI_INTERVAL;
-    int textFile_y = browse_y;
-    hTextFileToBeOpened = CreateWindowEx(0, L"static", L"No file selected.", WS_CHILD | WS_VISIBLE | ES_LEFT,
-        textFile_x, textFile_y, WND_WIDTH * 0.6, TEXT_HEIGHT, hWnd, (HMENU)TEXT_FILENAME, hInst, 0);
-
-    // image
-    anim.x = WND_WIDTH / 4;
-    anim.y = browse_y + BTN_HEIGHT + UI_INTERVAL * 2;
-    anim.width = BMP_MAX_LEN;
-    anim.height = anim.width;
-
-    // animating range
-    SetRect(&animRect, 
-        anim.x - UI_INTERVAL, 
-        anim.y - UI_INTERVAL,
-        anim.x + anim.width + UI_INTERVAL * 2,
-        anim.y + anim.height + UI_INTERVAL * 2
-    );
-
-    // background range
-    SetRect(&backRect,
-        0,
-        anim.y - UI_INTERVAL,
-        WND_WIDTH,
-        anim.y + anim.height + UI_INTERVAL * 2
-    );
-
-    // text Background Color
-    int textBC_x = WND_WIDTH / 20;
-    int textBC_y = anim.y + anim.height + UI_INTERVAL * 2;
-    CreateWindowEx(0, L"static", L"Background Color", WS_CHILD | WS_VISIBLE | ES_LEFT,
-        textBC_x, textBC_y, 120, TEXT_HEIGHT, hWnd, (HMENU)TEXT_FILENAME, hInst, 0);
-
-    // radio button
-    // white
-    int white_x = WND_WIDTH / 20;
-    int white_y = textBC_y + TEXT_HEIGHT + half_ui_interval;
-    CreateWindowEx(0, L"button", L"White", WS_VISIBLE | WS_CHILD | BS_AUTORADIOBUTTON,
-        white_x, white_y, RDOBTN_WIDTH, RDOBTN_HEIGHT, hWnd, (HMENU)BTN_WHITE, hInst, NULL);
-
-    // black
-    int black_x = white_x + RDOBTN_WIDTH + half_ui_interval;
-    int black_y = white_y;
-    CreateWindowEx(0, L"button", L"Black", WS_VISIBLE | WS_CHILD | BS_AUTORADIOBUTTON,
-        black_x, black_y, RDOBTN_WIDTH, RDOBTN_HEIGHT, hWnd, (HMENU)BTN_BLACK, hInst, NULL);
-
-    // red
-    int red_x = black_x + RDOBTN_WIDTH + half_ui_interval;
-    int red_y = white_y;
-    CreateWindowEx(0, L"button", L"Red", WS_VISIBLE | WS_CHILD | BS_AUTORADIOBUTTON,
-        red_x, red_y, RDOBTN_WIDTH, RDOBTN_HEIGHT, hWnd, (HMENU)BTN_RED, hInst, NULL);
-
-    // green
-    int green_x = red_x + RDOBTN_WIDTH + half_ui_interval;
-    int green_y = white_y;
-    CreateWindowEx(0, L"button", L"Green", WS_VISIBLE | WS_CHILD | BS_AUTORADIOBUTTON,
-        green_x, green_y, RDOBTN_WIDTH, RDOBTN_HEIGHT, hWnd, (HMENU)BTN_GREEN, hInst, NULL);
-
-    // blue
-    int blue_x = green_x + RDOBTN_WIDTH + half_ui_interval;
-    int blue_y = white_y;
-    CreateWindowEx(0, L"button", L"Blue", WS_VISIBLE | WS_CHILD | BS_AUTORADIOBUTTON,
-        blue_x, blue_y, RDOBTN_WIDTH, RDOBTN_HEIGHT, hWnd, (HMENU)BTN_BLUE, hInst, NULL);
-
-    CheckRadioButton(hWnd, BTN_WHITE, BTN_BLUE, BTN_WHITE);
-
-    // text Canvas Resize
-    int textCR_x = WND_WIDTH / 2;
-    int textCR_y = textBC_y;
-    CreateWindowEx(0, L"static", L"Canvas Resize", WS_CHILD | WS_VISIBLE | ES_LEFT,
-        textCR_x, textCR_y, 120, TEXT_HEIGHT, hWnd, (HMENU)TEXT_FILENAME, hInst, 0);
-
-    // slider Canvas Resize
-    int sliderCR_x = textCR_x;
-    int sliderCR_y = textCR_y + TEXT_HEIGHT + half_ui_interval;
-    hSliderCanvasResize = CreateWindowExW(0, TRACKBAR_CLASSW, NULL, WS_CHILD | WS_VISIBLE | TBS_FIXEDLENGTH | TBS_NOTICKS,
-        sliderCR_x, sliderCR_y, WND_WIDTH * 0.2, SLIDER_HEIGHT, hWnd, (HMENU)SLIDER_CANVAS_RESIZE, hInst, NULL);
-
-    // init resize slider
-    UINT sizeSlider = anim.width / RESIZE_LENGTH;
-    SendMessage(hSliderCanvasResize, TBM_SETRANGE, FALSE, MAKELPARAM(0, sizeSlider));
-    SendMessage(hSliderCanvasResize, TBM_SETPOS, TRUE, sizeSlider);
-
-    // button play
-    int btnPlay_x = WND_WIDTH / 10;
-    int btnPlay_y = red_y + RDOBTN_HEIGHT + UI_INTERVAL * 2;
-    hBtnPlay = CreateWindow(L"button", L"Play", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
-        btnPlay_x, btnPlay_y, BTN_WIDTH, BTN_HEIGHT, hWnd, (HMENU)BTN_PLAY, hInst, NULL);
-
-    // slider play
-    int sliderPlay_x = btnPlay_x + BTN_WIDTH + UI_INTERVAL;
-    int sliderPlay_y = btnPlay_y;
-    hSliderPlay = CreateWindowExW(0, TRACKBAR_CLASSW, NULL, WS_CHILD | WS_VISIBLE | TBS_FIXEDLENGTH | TBS_NOTICKS,
-        sliderPlay_x, sliderPlay_y, WND_WIDTH * 0.6, SLIDER_HEIGHT, hWnd, (HMENU)SLIDER_PLAY, hInst, NULL);
-}
-
-void resizeCanvas(HWND hWnd, int resizeValue)
-{
-    isViewChanged = true;
-    anim.x += resizeValue / 2;
-    anim.y += resizeValue / 2;
-    anim.width -= resizeValue;
-    anim.height -= resizeValue;
-    InvalidateRect(hWnd, &animRect, TRUE);
-}
-
-void changeBackgroundColor(int r, int g, int b)
-{
-    isViewChanged = true;
-    backColor = Gdiplus::Color(r * 255, g * 255, b * 255);
-    if (r + g + b == 0) borderColor = Gdiplus::Color(255, 255, 255);
-    else borderColor = Gdiplus::Color(0, 0, 0);
-    setAnimationColor(r, g, b);
-    renderAnimation(curFrame);
-    InvalidateRect(mainWindow, &backRect, FALSE);
-}
\ No newline at end of file
diff --git a/example/rlottiePlayer/rlottiePlayer.h b/example/rlottiePlayer/rlottiePlayer.h
deleted file mode 100644 (file)
index 07e5fd2..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-#pragma once
-
-#include "resource.h"
-#include "animation.h"
-#include <Commdlg.h>                    // OPENFILENAME
-#include "atlconv.h"                    // String cast. (ex. LPWSTR <-> LPSTR)
-#include <gdiplus.h>
-#include <CommCtrl.h>                    // slider handle
-
-// interval
-#define UI_INTERVAL 20
-
-// length
-#define WND_WIDTH 1000
-#define WND_HEIGHT 800
-#define BMP_MAX_LEN    500
-#define BTN_WIDTH 100
-#define BTN_HEIGHT 30
-#define TEXT_HEIGHT 20
-#define SLIDER_HEIGHT 25
-#define RDOBTN_WIDTH 60
-#define RDOBTN_HEIGHT 20
-#define RESIZE_LENGTH 10
-
-typedef struct RlottieBitmap
-{
-       Gdiplus::Bitmap* image = NULL;
-       int x = 0;
-       int y = 0;
-       unsigned int width = 0;
-       unsigned int height = 0;
-}RlottieBitmap;
\ No newline at end of file
diff --git a/example/rlottiePlayer/rlottiePlayer.ico b/example/rlottiePlayer/rlottiePlayer.ico
deleted file mode 100644 (file)
index b3ec03b..0000000
Binary files a/example/rlottiePlayer/rlottiePlayer.ico and /dev/null differ
diff --git a/example/rlottiePlayer/rlottiePlayer.rc b/example/rlottiePlayer/rlottiePlayer.rc
deleted file mode 100644 (file)
index 0c7935f..0000000
Binary files a/example/rlottiePlayer/rlottiePlayer.rc and /dev/null differ
diff --git a/example/rlottiePlayer/rlottiePlayer.sln b/example/rlottiePlayer/rlottiePlayer.sln
deleted file mode 100644 (file)
index d1c8f0d..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 16
-VisualStudioVersion = 16.0.30503.244
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rlottiePlayer", "rlottiePlayer.vcxproj", "{CC7AD634-4D29-4D8E-997D-9727DABB44EE}"
-EndProject
-Global
-       GlobalSection(SolutionConfigurationPlatforms) = preSolution
-               Debug|x64 = Debug|x64
-               Debug|x86 = Debug|x86
-               Release|x64 = Release|x64
-               Release|x86 = Release|x86
-       EndGlobalSection
-       GlobalSection(ProjectConfigurationPlatforms) = postSolution
-               {CC7AD634-4D29-4D8E-997D-9727DABB44EE}.Debug|x64.ActiveCfg = Debug|x64
-               {CC7AD634-4D29-4D8E-997D-9727DABB44EE}.Debug|x64.Build.0 = Debug|x64
-               {CC7AD634-4D29-4D8E-997D-9727DABB44EE}.Debug|x86.ActiveCfg = Debug|Win32
-               {CC7AD634-4D29-4D8E-997D-9727DABB44EE}.Debug|x86.Build.0 = Debug|Win32
-               {CC7AD634-4D29-4D8E-997D-9727DABB44EE}.Release|x64.ActiveCfg = Release|x64
-               {CC7AD634-4D29-4D8E-997D-9727DABB44EE}.Release|x64.Build.0 = Release|x64
-               {CC7AD634-4D29-4D8E-997D-9727DABB44EE}.Release|x86.ActiveCfg = Release|Win32
-               {CC7AD634-4D29-4D8E-997D-9727DABB44EE}.Release|x86.Build.0 = Release|Win32
-       EndGlobalSection
-       GlobalSection(SolutionProperties) = preSolution
-               HideSolutionNode = FALSE
-       EndGlobalSection
-       GlobalSection(ExtensibilityGlobals) = postSolution
-               SolutionGuid = {57EEA15F-28FB-4C19-96B4-7B62BFA0CFE5}
-       EndGlobalSection
-EndGlobal
diff --git a/example/rlottiePlayer/rlottiePlayer.vcxproj b/example/rlottiePlayer/rlottiePlayer.vcxproj
deleted file mode 100644 (file)
index 18e6533..0000000
+++ /dev/null
@@ -1,164 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <ItemGroup Label="ProjectConfigurations">
-    <ProjectConfiguration Include="Debug|Win32">
-      <Configuration>Debug</Configuration>
-      <Platform>Win32</Platform>
-    </ProjectConfiguration>
-    <ProjectConfiguration Include="Release|Win32">
-      <Configuration>Release</Configuration>
-      <Platform>Win32</Platform>
-    </ProjectConfiguration>
-    <ProjectConfiguration Include="Debug|x64">
-      <Configuration>Debug</Configuration>
-      <Platform>x64</Platform>
-    </ProjectConfiguration>
-    <ProjectConfiguration Include="Release|x64">
-      <Configuration>Release</Configuration>
-      <Platform>x64</Platform>
-    </ProjectConfiguration>
-  </ItemGroup>
-  <PropertyGroup Label="Globals">
-    <VCProjectVersion>16.0</VCProjectVersion>
-    <Keyword>Win32Proj</Keyword>
-    <ProjectGuid>{cc7ad634-4d29-4d8e-997d-9727dabb44ee}</ProjectGuid>
-    <RootNamespace>rlottiePlayer</RootNamespace>
-    <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
-  </PropertyGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
-    <ConfigurationType>Application</ConfigurationType>
-    <UseDebugLibraries>true</UseDebugLibraries>
-    <PlatformToolset>v142</PlatformToolset>
-    <CharacterSet>Unicode</CharacterSet>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
-    <ConfigurationType>Application</ConfigurationType>
-    <UseDebugLibraries>false</UseDebugLibraries>
-    <PlatformToolset>v142</PlatformToolset>
-    <WholeProgramOptimization>true</WholeProgramOptimization>
-    <CharacterSet>Unicode</CharacterSet>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
-    <ConfigurationType>Application</ConfigurationType>
-    <UseDebugLibraries>true</UseDebugLibraries>
-    <PlatformToolset>v142</PlatformToolset>
-    <CharacterSet>Unicode</CharacterSet>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
-    <ConfigurationType>Application</ConfigurationType>
-    <UseDebugLibraries>false</UseDebugLibraries>
-    <PlatformToolset>v142</PlatformToolset>
-    <WholeProgramOptimization>true</WholeProgramOptimization>
-    <CharacterSet>Unicode</CharacterSet>
-  </PropertyGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
-  <ImportGroup Label="ExtensionSettings">
-  </ImportGroup>
-  <ImportGroup Label="Shared">
-  </ImportGroup>
-  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
-  </ImportGroup>
-  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
-  </ImportGroup>
-  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
-  </ImportGroup>
-  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
-  </ImportGroup>
-  <PropertyGroup Label="UserMacros" />
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <LinkIncremental>true</LinkIncremental>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <LinkIncremental>false</LinkIncremental>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
-    <LinkIncremental>true</LinkIncremental>
-    <IncludePath>..\..\inc;$(IncludePath)</IncludePath>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
-    <LinkIncremental>false</LinkIncremental>
-  </PropertyGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <ClCompile>
-      <WarningLevel>Level3</WarningLevel>
-      <SDLCheck>true</SDLCheck>
-      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <ConformanceMode>true</ConformanceMode>
-    </ClCompile>
-    <Link>
-      <SubSystem>Windows</SubSystem>
-      <GenerateDebugInformation>true</GenerateDebugInformation>
-    </Link>
-  </ItemDefinitionGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <ClCompile>
-      <WarningLevel>Level3</WarningLevel>
-      <FunctionLevelLinking>true</FunctionLevelLinking>
-      <IntrinsicFunctions>true</IntrinsicFunctions>
-      <SDLCheck>true</SDLCheck>
-      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <ConformanceMode>true</ConformanceMode>
-    </ClCompile>
-    <Link>
-      <SubSystem>Windows</SubSystem>
-      <EnableCOMDATFolding>true</EnableCOMDATFolding>
-      <OptimizeReferences>true</OptimizeReferences>
-      <GenerateDebugInformation>true</GenerateDebugInformation>
-    </Link>
-  </ItemDefinitionGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
-    <ClCompile>
-      <WarningLevel>Level3</WarningLevel>
-      <SDLCheck>true</SDLCheck>
-      <PreprocessorDefinitions>_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <ConformanceMode>true</ConformanceMode>
-    </ClCompile>
-    <Link>
-      <SubSystem>Windows</SubSystem>
-      <GenerateDebugInformation>true</GenerateDebugInformation>
-      <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;rlottie.lib;gdiplus.lib;%(AdditionalDependencies)</AdditionalDependencies>
-    </Link>
-  </ItemDefinitionGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
-    <ClCompile>
-      <WarningLevel>Level3</WarningLevel>
-      <FunctionLevelLinking>true</FunctionLevelLinking>
-      <IntrinsicFunctions>true</IntrinsicFunctions>
-      <SDLCheck>true</SDLCheck>
-      <PreprocessorDefinitions>NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <ConformanceMode>true</ConformanceMode>
-    </ClCompile>
-    <Link>
-      <SubSystem>Windows</SubSystem>
-      <EnableCOMDATFolding>true</EnableCOMDATFolding>
-      <OptimizeReferences>true</OptimizeReferences>
-      <GenerateDebugInformation>true</GenerateDebugInformation>
-    </Link>
-  </ItemDefinitionGroup>
-  <ItemGroup>
-    <ClInclude Include="animation.h" />
-    <ClInclude Include="framework.h" />
-    <ClInclude Include="Resource.h" />
-    <ClInclude Include="rlottiePlayer.h" />
-    <ClInclude Include="targetver.h" />
-  </ItemGroup>
-  <ItemGroup>
-    <ClCompile Include="rlottiePlayer.cpp" />
-    <ClCompile Include="Source.cpp" />
-  </ItemGroup>
-  <ItemGroup>
-    <ResourceCompile Include="rlottiePlayer.rc" />
-  </ItemGroup>
-  <ItemGroup>
-    <Image Include="rlottiePlayer.ico" />
-    <Image Include="small.ico" />
-  </ItemGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
-  <ImportGroup Label="ExtensionTargets">
-  </ImportGroup>
-</Project>
\ No newline at end of file
diff --git a/example/rlottiePlayer/rlottiePlayer.vcxproj.filters b/example/rlottiePlayer/rlottiePlayer.vcxproj.filters
deleted file mode 100644 (file)
index c8cf65b..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <ItemGroup>
-    <Filter Include="Source Files">
-      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
-      <Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
-    </Filter>
-    <Filter Include="Header Files">
-      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
-      <Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
-    </Filter>
-    <Filter Include="Resource Files">
-      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
-      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
-    </Filter>
-  </ItemGroup>
-  <ItemGroup>
-    <ClInclude Include="framework.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="targetver.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="Resource.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="rlottiePlayer.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="animation.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-  </ItemGroup>
-  <ItemGroup>
-    <ClCompile Include="rlottiePlayer.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="Source.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-  </ItemGroup>
-  <ItemGroup>
-    <ResourceCompile Include="rlottiePlayer.rc">
-      <Filter>Resource Files</Filter>
-    </ResourceCompile>
-  </ItemGroup>
-  <ItemGroup>
-    <Image Include="small.ico">
-      <Filter>Resource Files</Filter>
-    </Image>
-    <Image Include="rlottiePlayer.ico">
-      <Filter>Resource Files</Filter>
-    </Image>
-  </ItemGroup>
-</Project>
\ No newline at end of file
diff --git a/example/rlottiePlayer/rlottiePlayer.vcxproj.user b/example/rlottiePlayer/rlottiePlayer.vcxproj.user
deleted file mode 100644 (file)
index 88a5509..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <PropertyGroup />
-</Project>
\ No newline at end of file
diff --git a/example/rlottiePlayer/small.ico b/example/rlottiePlayer/small.ico
deleted file mode 100644 (file)
index b3ec03b..0000000
Binary files a/example/rlottiePlayer/small.ico and /dev/null differ
diff --git a/example/rlottiePlayer/targetver.h b/example/rlottiePlayer/targetver.h
deleted file mode 100644 (file)
index bf75e08..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#pragma once
-
-// // Including SDKDDKVer.h defines the highest available Windows platform.
-// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
-// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
-#include <SDKDDKVer.h>
diff --git a/example/win32Player/Source.cpp b/example/win32Player/Source.cpp
new file mode 100644 (file)
index 0000000..99ea876
--- /dev/null
@@ -0,0 +1,60 @@
+#include "rlottie.h"
+#include "animation.h"
+using namespace rlottie;
+
+std::unique_ptr<Animation> anim;
+uint32_t *buffer;
+size_t width, height;
+size_t bytesPerLine;
+uint32_t curColor = UINT32_MAX;
+
+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)
+{
+       anim = Animation::loadFromFile(path);
+    anim->size(*w, *h);
+    setAnimationSize(*w, *h);
+}
+
+uint32_t* renderRLottieAnimation(uint32_t frameNum)
+{
+       Surface surface = Surface(buffer, width, height, bytesPerLine);
+       anim->renderSync(frameNum, surface);
+       // background color
+       for (int i = 0; i < height; i++)
+        for (int j = 0; j < width; ++j)
+               {
+                       uint32_t* v = buffer + i * width + j;
+                       if (*v == 0) *v = curColor;
+               }
+       return buffer;
+}
+
+void setAnimationColor(int r, int g, int b)
+{
+       curColor = ((255 << 16) * r) + ((255 << 8) * g) + 255 * b;
+}
+
+size_t getTotalFrame()
+{
+       return anim->totalFrame();
+}
+
+bool isAnimNULL()
+{
+       return anim == NULL;
+}
+
+void freeAnimation()
+{
+    free(buffer);
+}
\ No newline at end of file
diff --git a/example/win32Player/animation.h b/example/win32Player/animation.h
new file mode 100644 (file)
index 0000000..483cb3f
--- /dev/null
@@ -0,0 +1,10 @@
+#pragma once
+#include <stdint.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();
+void      setAnimationColor(int r, int g, int b);
+void      freeAnimation();
\ No newline at end of file
diff --git a/example/win32Player/framework.h b/example/win32Player/framework.h
new file mode 100644 (file)
index 0000000..33a6be6
--- /dev/null
@@ -0,0 +1,15 @@
+// header.h : include file for standard system include files,
+// or project specific include files
+//
+
+#pragma once
+
+#include "targetver.h"
+#define WIN32_LEAN_AND_MEAN             // Exclude rarely-used stuff from Windows headers
+// Windows Header Files
+#include <windows.h>
+// C RunTime Header Files
+#include <stdlib.h>
+#include <malloc.h>
+#include <memory.h>
+#include <tchar.h>
diff --git a/example/win32Player/resource.h b/example/win32Player/resource.h
new file mode 100644 (file)
index 0000000..ac46939
--- /dev/null
@@ -0,0 +1,40 @@
+//{{NO_DEPENDENCIES}}
+// This is an include file generated by Microsoft Visual C++.
+// It is being used in rlottiePlayer.rc.
+//
+#define IDC_MYICON                      2
+#define IDD_RLOTTIEPLAYER_DIALOG        102
+#define IDS_APP_TITLE                   103
+#define IDD_ABOUTBOX                    103
+#define IDM_ABOUT                       104
+#define IDM_EXIT                        105
+#define IDI_RLOTTIEPLAYER               107
+#define IDI_SMALL                       108
+#define IDC_RLOTTIEPLAYER               109
+#define IDR_MAINFRAME                   128
+#define MAIN_WINDOW                     130
+#define BTN_BROWSE                      1004
+#define BTN_WHITE                       1005
+#define BTN_BLACK                       1006
+#define BTN_RED                         1007
+#define BTN_GREEN                       1008
+#define BTN_BLUE                        1009
+#define SLIDER_CANVAS_RESIZE                   1010
+#define BTN_PLAY                        1011
+#define SLIDER_PLAY                     1012
+#define TEXT_FILENAME                   1013
+#define PICCTRL_RLOTTIE                 1014
+#define TIMER_PLAY_ANIM                                1015
+#define IDC_STATIC                      -1
+
+// Next default values for new objects
+// 
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NO_MFC                     1
+#define _APS_NEXT_RESOURCE_VALUE        131
+#define _APS_NEXT_COMMAND_VALUE         32771
+#define _APS_NEXT_CONTROL_VALUE         1017
+#define _APS_NEXT_SYMED_VALUE           110
+#endif
+#endif
diff --git a/example/win32Player/rlottie.dll b/example/win32Player/rlottie.dll
new file mode 100644 (file)
index 0000000..296f70a
Binary files /dev/null and b/example/win32Player/rlottie.dll differ
diff --git a/example/win32Player/rlottie.lib b/example/win32Player/rlottie.lib
new file mode 100644 (file)
index 0000000..2625916
Binary files /dev/null and b/example/win32Player/rlottie.lib differ
diff --git a/example/win32Player/rlottiePlayer.cpp b/example/win32Player/rlottiePlayer.cpp
new file mode 100644 (file)
index 0000000..b2d0431
--- /dev/null
@@ -0,0 +1,521 @@
+// rlottiePlayer.cpp : Defines the entry point for the application.
+//
+
+
+#include "framework.h"
+#include "rlottiePlayer.h"
+using namespace Gdiplus;
+
+#define MAX_LOADSTRING 100
+
+// Global Variables:
+HINSTANCE hInst;                                        // current instance
+WCHAR szTitle[MAX_LOADSTRING];                  // The title bar text
+WCHAR szWindowClass[MAX_LOADSTRING];            // the main window class name
+HWND mainWindow;                                    // Main Window Instance
+HWND hTextFileToBeOpened;                               // openDialog file path
+HWND hBtnPlay;
+HWND hSliderPlay, hSliderCanvasResize;
+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 isViewChanged = false;
+
+// Forward declarations of functions included in this code module:
+ATOM                MyRegisterClass(HINSTANCE hInstance);
+BOOL                InitInstance(HINSTANCE, int);
+LRESULT CALLBACK    WndProc(HWND, UINT, WPARAM, LPARAM);
+INT_PTR CALLBACK    About(HWND, UINT, WPARAM, LPARAM);
+void openJSONFileDialog(HWND);
+void initUIControl(HWND);
+void dlgUICommand(HWND, WPARAM);
+void resizeCanvas(HWND, int);
+void changeBackgroundColor(int r, int g, int b);
+
+// Animation Rendering Functions
+void draw(HDC);
+Bitmap* CreateBitmap(void* data, unsigned int width, unsigned int height);
+void renderAnimation(UINT);
+
+int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
+    _In_opt_ HINSTANCE hPrevInstance,
+    _In_ LPWSTR    lpCmdLine,
+    _In_ int       nCmdShow)
+{
+    UNREFERENCED_PARAMETER(hPrevInstance);
+    UNREFERENCED_PARAMETER(lpCmdLine);
+
+    // initialize Gdiplus
+    Gdiplus::GdiplusStartupInput gdiplusStartUpInput;
+    ULONG_PTR gdiplustoken;
+    Gdiplus::GdiplusStartup(&gdiplustoken, &gdiplusStartUpInput, nullptr);
+
+    // Initialize global strings
+    LoadStringW(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
+    LoadStringW(hInstance, IDC_RLOTTIEPLAYER, szWindowClass, MAX_LOADSTRING);
+    MyRegisterClass(hInstance);
+
+    // Perform application initialization:
+    if (!InitInstance(hInstance, nCmdShow))
+    {
+        return FALSE;
+    }
+
+    HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_RLOTTIEPLAYER));
+
+    MSG msg;
+
+    // Main message loop:
+    while (GetMessage(&msg, nullptr, 0, 0))
+    {
+        if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
+        {
+            TranslateMessage(&msg);
+            DispatchMessage(&msg);
+        }
+    }
+
+    Gdiplus::GdiplusShutdown(gdiplustoken);
+    return (int)msg.wParam;
+}
+
+
+
+//
+//  FUNCTION: MyRegisterClass()
+//
+//  PURPOSE: Registers the window class.
+//
+ATOM MyRegisterClass(HINSTANCE hInstance)
+{
+    WNDCLASSEXW wcex;
+
+    wcex.cbSize = sizeof(WNDCLASSEX);
+
+    wcex.style = CS_HREDRAW | CS_VREDRAW;
+    wcex.lpfnWndProc = WndProc;
+    wcex.cbClsExtra = 0;
+    wcex.cbWndExtra = 0;
+    wcex.hInstance = hInstance;
+    wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_RLOTTIEPLAYER));
+    wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
+    wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
+    wcex.lpszMenuName = MAKEINTRESOURCEW(IDC_RLOTTIEPLAYER);
+    wcex.lpszClassName = szWindowClass;
+    wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
+
+    return RegisterClassExW(&wcex);
+}
+
+//
+//   FUNCTION: InitInstance(HINSTANCE, int)
+//
+//   PURPOSE: Saves instance handle and creates main window
+//
+//   COMMENTS:
+//
+//        In this function, we save the instance handle in a global variable and
+//        create and display the main program window.
+//
+BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
+{
+    hInst = hInstance; // Store instance handle in our global variable
+
+    DWORD dwStyle = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX;
+    mainWindow = CreateWindowEx(0, szWindowClass, szTitle, dwStyle,
+        CW_USEDEFAULT, CW_USEDEFAULT, WND_WIDTH, WND_HEIGHT, nullptr, nullptr, hInstance, nullptr);
+
+    if (!mainWindow)
+    {
+        return FALSE;
+    }
+
+    ShowWindow(mainWindow, nCmdShow);
+    UpdateWindow(mainWindow);
+    SetMenu(mainWindow, NULL);
+
+    return TRUE;
+}
+
+//
+//  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
+//
+//  PURPOSE: Processes messages for the main window.
+//
+//  WM_COMMAND  - process the application menu
+//  WM_PAINT    - Paint the main window
+//  WM_DESTROY  - post a quit message and return
+//
+//
+LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+    static bool isplay = false;
+    int wmId = LOWORD(wParam);
+
+    switch (message)
+    {
+    case WM_CREATE:
+    {
+        initUIControl(hWnd);
+        break;
+    }
+    case WM_TIMER:
+    {
+        switch (wmId)
+        {
+        case TIMER_PLAY_ANIM:
+        {
+            renderAnimation(curFrame + 1);
+            SendMessage(hSliderPlay, TBM_SETPOS, TRUE, curFrame);
+            break;
+        }
+        default:
+            break;
+        }
+        break;
+    }
+    case WM_COMMAND:
+    {
+        // Parse the menu selections:
+        switch (wmId)
+        {
+        case IDM_ABOUT:
+            DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
+            break;
+
+        case IDM_EXIT:
+            DestroyWindow(hWnd);
+            break;
+
+        case BTN_BROWSE:
+            openJSONFileDialog(hWnd);
+            break;
+
+        case BTN_PLAY:
+        {
+            LPWSTR textBtnPlay;
+            USES_CONVERSION;
+            if (isplay)
+            {
+                isplay = false;
+                textBtnPlay = A2W("Play");
+                KillTimer(hWnd, TIMER_PLAY_ANIM);
+            }
+            else
+            {
+                isplay = true;
+                textBtnPlay = A2W("Pause");
+                SetTimer(hWnd, TIMER_PLAY_ANIM, 10, NULL);
+            }
+            SetWindowText(hBtnPlay, textBtnPlay);
+            break;
+        }
+
+        case WM_DROPFILES:
+            break;
+        case BTN_WHITE:
+            changeBackgroundColor(1, 1, 1);
+            break;
+        case BTN_BLACK:
+            changeBackgroundColor(0, 0, 0);
+            break;
+        case BTN_RED:
+            changeBackgroundColor(1, 0, 0);
+            break;
+        case BTN_GREEN:
+            changeBackgroundColor(0, 1, 0);
+            break;
+        case BTN_BLUE:
+            changeBackgroundColor(0, 0, 1);
+            break;
+
+        default:
+            return DefWindowProc(hWnd, message, wParam, lParam);
+        }
+    }
+    break;
+
+    case WM_HSCROLL:
+    {
+        if ((lParam != 0) && (reinterpret_cast<HWND>(lParam) == hSliderPlay))
+        {
+            UINT frameNum = SendDlgItemMessage(hWnd, SLIDER_PLAY, TBM_GETPOS, 0, 0);
+            renderAnimation(frameNum);
+        }
+        else if ((lParam != 0) && (reinterpret_cast<HWND>(lParam) == hSliderCanvasResize))
+        {
+            static int curSize = anim.width / RESIZE_LENGTH;
+            int newSize = SendDlgItemMessage(hWnd, SLIDER_CANVAS_RESIZE, TBM_GETPOS, 0, 0);
+            resizeCanvas(hWnd, (curSize - newSize) * RESIZE_LENGTH);
+            curSize = newSize;
+        }
+        break;
+    }
+
+    case WM_PAINT:
+    {
+        PAINTSTRUCT ps;
+        HDC hdc = BeginPaint(hWnd, &ps);
+        draw(hdc);
+        EndPaint(hWnd, &ps);
+    }
+    break;
+    case WM_CTLCOLORSTATIC:
+    {
+        static HBRUSH hBrushEdit = CreateSolidBrush(RGB(255, 255, 255));
+        return (LRESULT)hBrushEdit;
+    }
+
+    case WM_DESTROY:
+        freeAnimation();
+        PostQuitMessage(0);
+        break;
+
+    default:
+        return DefWindowProc(hWnd, message, wParam, lParam);
+    }
+    return 0;
+}
+
+// Message handler for about box.
+INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
+{
+    UNREFERENCED_PARAMETER(lParam);
+    switch (message)
+    {
+    case WM_INITDIALOG:
+        return (INT_PTR)TRUE;
+
+    case WM_COMMAND:
+        if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
+        {
+            EndDialog(hDlg, LOWORD(wParam));
+            return (INT_PTR)TRUE;
+        }
+        break;
+    }
+    return (INT_PTR)FALSE;
+}
+
+void openJSONFileDialog(HWND hDlg)
+{
+    OPENFILENAME ofn;       // common dialog box structure
+    TCHAR szFile[260] = { 0 };       // if using TCHAR macros
+
+    // Initialize OPENFILENAME
+    ZeroMemory(&ofn, sizeof(ofn));
+    ofn.lStructSize = sizeof(ofn);
+    ofn.hwndOwner = hDlg;
+    ofn.lpstrFile = szFile;
+    ofn.nMaxFile = sizeof(szFile);
+    ofn.lpstrFilter = _T("JSON\0*.json\0");
+    ofn.nFilterIndex = 1;
+    ofn.lpstrFileTitle = NULL;
+    ofn.nMaxFileTitle = 0;
+    ofn.lpstrInitialDir = NULL;
+    ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
+
+    isViewChanged = true;
+    if (GetOpenFileName(&ofn))
+    {
+        isViewChanged = true;
+        SetWindowText(hTextFileToBeOpened, ofn.lpstrFile);
+        // LPWSTR(w_char*) -> LPSTR(char*)
+        USES_CONVERSION;
+        LPSTR path = W2A(ofn.lpstrFile);
+
+        setAnimation(path, &animWidth, &animHeight);
+        // init play slider
+        SendMessage(hSliderPlay, TBM_SETRANGE, FALSE, MAKELPARAM(0, getTotalFrame()));
+        SendMessage(hSliderPlay, TBM_SETPOS, TRUE, 0);
+        renderAnimation(0);
+    }
+}
+
+void draw(HDC hdc)
+{
+    Graphics gf(hdc);
+    int half_interval = UI_INTERVAL / 2;
+
+    // background
+    SolidBrush brush(backColor);
+    int back_y = half_interval + BTN_HEIGHT;
+    int back_height = back_y + BMP_MAX_LEN + UI_INTERVAL;
+    if (isViewChanged)
+    {
+        isViewChanged = false;
+        gf.FillRectangle(&brush, 0, back_y, WND_WIDTH, back_height);
+    }
+
+    // image borderline
+    Pen pen(borderColor);
+    gf.DrawRectangle(&pen, anim.x - half_interval, anim.y - half_interval, anim.width + half_interval * 2, anim.height + half_interval * 2);
+
+    // image
+    if (anim.image != NULL)
+    {
+        gf.DrawImage(anim.image, anim.x, anim.y, anim.width, anim.height);
+    }
+}
+
+Bitmap* CreateBitmap(void* data, unsigned int width, unsigned int height)
+{
+    BITMAPINFO Info;
+    memset(&Info, 0, sizeof(Info));
+
+    Info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+    Info.bmiHeader.biWidth = width;
+    Info.bmiHeader.biHeight = height;
+    Info.bmiHeader.biPlanes = 1;
+    Info.bmiHeader.biBitCount = 32;
+    Info.bmiHeader.biCompression = BI_RGB;
+    Info.bmiHeader.biSizeImage = 0;  //(((32 * width + 31) & ~31) / 8) * height;
+
+    return new Gdiplus::Bitmap(&Info, data);
+}
+
+void renderAnimation(UINT frameNum)
+{
+    if (isAnimNULL()) return;
+    if (anim.image != NULL) delete anim.image;
+
+    curFrame = frameNum % getTotalFrame();
+
+    // render
+    UINT* resRender = renderRLottieAnimation(curFrame);
+    anim.image = CreateBitmap(resRender, animWidth, animHeight);
+    anim.image->RotateFlip(RotateNoneFlipY);
+    // call WM_PAINT message
+    InvalidateRect(mainWindow, &animRect, FALSE);
+}
+
+void initUIControl(HWND hWnd)
+{
+    int half_ui_interval = UI_INTERVAL / 2;
+
+    // button browse
+    int browse_x = UI_INTERVAL;
+    int browse_y = half_ui_interval;
+    CreateWindow(L"button", L"Browse", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
+        browse_x, browse_y, BTN_WIDTH, BTN_HEIGHT, hWnd, (HMENU)BTN_BROWSE, hInst, NULL);
+
+    // textbox FilePath
+    int textFile_x = browse_x + BTN_WIDTH + UI_INTERVAL;
+    int textFile_y = browse_y;
+    hTextFileToBeOpened = CreateWindowEx(0, L"static", L"No file selected.", WS_CHILD | WS_VISIBLE | ES_LEFT,
+        textFile_x, textFile_y, WND_WIDTH * 0.6, TEXT_HEIGHT, hWnd, (HMENU)TEXT_FILENAME, hInst, 0);
+
+    // image
+    anim.x = WND_WIDTH / 4;
+    anim.y = browse_y + BTN_HEIGHT + UI_INTERVAL * 2;
+    anim.width = BMP_MAX_LEN;
+    anim.height = anim.width;
+
+    // animating range
+    SetRect(&animRect, 
+        anim.x - UI_INTERVAL, 
+        anim.y - UI_INTERVAL,
+        anim.x + anim.width + UI_INTERVAL * 2,
+        anim.y + anim.height + UI_INTERVAL * 2
+    );
+
+    // background range
+    SetRect(&backRect,
+        0,
+        anim.y - UI_INTERVAL,
+        WND_WIDTH,
+        anim.y + anim.height + UI_INTERVAL * 2
+    );
+
+    // text Background Color
+    int textBC_x = WND_WIDTH / 20;
+    int textBC_y = anim.y + anim.height + UI_INTERVAL * 2;
+    CreateWindowEx(0, L"static", L"Background Color", WS_CHILD | WS_VISIBLE | ES_LEFT,
+        textBC_x, textBC_y, 120, TEXT_HEIGHT, hWnd, (HMENU)TEXT_FILENAME, hInst, 0);
+
+    // radio button
+    // white
+    int white_x = WND_WIDTH / 20;
+    int white_y = textBC_y + TEXT_HEIGHT + half_ui_interval;
+    CreateWindowEx(0, L"button", L"White", WS_VISIBLE | WS_CHILD | BS_AUTORADIOBUTTON,
+        white_x, white_y, RDOBTN_WIDTH, RDOBTN_HEIGHT, hWnd, (HMENU)BTN_WHITE, hInst, NULL);
+
+    // black
+    int black_x = white_x + RDOBTN_WIDTH + half_ui_interval;
+    int black_y = white_y;
+    CreateWindowEx(0, L"button", L"Black", WS_VISIBLE | WS_CHILD | BS_AUTORADIOBUTTON,
+        black_x, black_y, RDOBTN_WIDTH, RDOBTN_HEIGHT, hWnd, (HMENU)BTN_BLACK, hInst, NULL);
+
+    // red
+    int red_x = black_x + RDOBTN_WIDTH + half_ui_interval;
+    int red_y = white_y;
+    CreateWindowEx(0, L"button", L"Red", WS_VISIBLE | WS_CHILD | BS_AUTORADIOBUTTON,
+        red_x, red_y, RDOBTN_WIDTH, RDOBTN_HEIGHT, hWnd, (HMENU)BTN_RED, hInst, NULL);
+
+    // green
+    int green_x = red_x + RDOBTN_WIDTH + half_ui_interval;
+    int green_y = white_y;
+    CreateWindowEx(0, L"button", L"Green", WS_VISIBLE | WS_CHILD | BS_AUTORADIOBUTTON,
+        green_x, green_y, RDOBTN_WIDTH, RDOBTN_HEIGHT, hWnd, (HMENU)BTN_GREEN, hInst, NULL);
+
+    // blue
+    int blue_x = green_x + RDOBTN_WIDTH + half_ui_interval;
+    int blue_y = white_y;
+    CreateWindowEx(0, L"button", L"Blue", WS_VISIBLE | WS_CHILD | BS_AUTORADIOBUTTON,
+        blue_x, blue_y, RDOBTN_WIDTH, RDOBTN_HEIGHT, hWnd, (HMENU)BTN_BLUE, hInst, NULL);
+
+    CheckRadioButton(hWnd, BTN_WHITE, BTN_BLUE, BTN_WHITE);
+
+    // text Canvas Resize
+    int textCR_x = WND_WIDTH / 2;
+    int textCR_y = textBC_y;
+    CreateWindowEx(0, L"static", L"Canvas Resize", WS_CHILD | WS_VISIBLE | ES_LEFT,
+        textCR_x, textCR_y, 120, TEXT_HEIGHT, hWnd, (HMENU)TEXT_FILENAME, hInst, 0);
+
+    // slider Canvas Resize
+    int sliderCR_x = textCR_x;
+    int sliderCR_y = textCR_y + TEXT_HEIGHT + half_ui_interval;
+    hSliderCanvasResize = CreateWindowExW(0, TRACKBAR_CLASSW, NULL, WS_CHILD | WS_VISIBLE | TBS_FIXEDLENGTH | TBS_NOTICKS,
+        sliderCR_x, sliderCR_y, WND_WIDTH * 0.2, SLIDER_HEIGHT, hWnd, (HMENU)SLIDER_CANVAS_RESIZE, hInst, NULL);
+
+    // init resize slider
+    UINT sizeSlider = anim.width / RESIZE_LENGTH;
+    SendMessage(hSliderCanvasResize, TBM_SETRANGE, FALSE, MAKELPARAM(0, sizeSlider));
+    SendMessage(hSliderCanvasResize, TBM_SETPOS, TRUE, sizeSlider);
+
+    // button play
+    int btnPlay_x = WND_WIDTH / 10;
+    int btnPlay_y = red_y + RDOBTN_HEIGHT + UI_INTERVAL * 2;
+    hBtnPlay = CreateWindow(L"button", L"Play", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
+        btnPlay_x, btnPlay_y, BTN_WIDTH, BTN_HEIGHT, hWnd, (HMENU)BTN_PLAY, hInst, NULL);
+
+    // slider play
+    int sliderPlay_x = btnPlay_x + BTN_WIDTH + UI_INTERVAL;
+    int sliderPlay_y = btnPlay_y;
+    hSliderPlay = CreateWindowExW(0, TRACKBAR_CLASSW, NULL, WS_CHILD | WS_VISIBLE | TBS_FIXEDLENGTH | TBS_NOTICKS,
+        sliderPlay_x, sliderPlay_y, WND_WIDTH * 0.6, SLIDER_HEIGHT, hWnd, (HMENU)SLIDER_PLAY, hInst, NULL);
+}
+
+void resizeCanvas(HWND hWnd, int resizeValue)
+{
+    isViewChanged = true;
+    anim.x += resizeValue / 2;
+    anim.y += resizeValue / 2;
+    anim.width -= resizeValue;
+    anim.height -= resizeValue;
+    InvalidateRect(hWnd, &animRect, TRUE);
+}
+
+void changeBackgroundColor(int r, int g, int b)
+{
+    isViewChanged = true;
+    backColor = Gdiplus::Color(r * 255, g * 255, b * 255);
+    if (r + g + b == 0) borderColor = Gdiplus::Color(255, 255, 255);
+    else borderColor = Gdiplus::Color(0, 0, 0);
+    setAnimationColor(r, g, b);
+    renderAnimation(curFrame);
+    InvalidateRect(mainWindow, &backRect, FALSE);
+}
\ No newline at end of file
diff --git a/example/win32Player/rlottiePlayer.h b/example/win32Player/rlottiePlayer.h
new file mode 100644 (file)
index 0000000..07e5fd2
--- /dev/null
@@ -0,0 +1,32 @@
+#pragma once
+
+#include "resource.h"
+#include "animation.h"
+#include <Commdlg.h>                    // OPENFILENAME
+#include "atlconv.h"                    // String cast. (ex. LPWSTR <-> LPSTR)
+#include <gdiplus.h>
+#include <CommCtrl.h>                    // slider handle
+
+// interval
+#define UI_INTERVAL 20
+
+// length
+#define WND_WIDTH 1000
+#define WND_HEIGHT 800
+#define BMP_MAX_LEN    500
+#define BTN_WIDTH 100
+#define BTN_HEIGHT 30
+#define TEXT_HEIGHT 20
+#define SLIDER_HEIGHT 25
+#define RDOBTN_WIDTH 60
+#define RDOBTN_HEIGHT 20
+#define RESIZE_LENGTH 10
+
+typedef struct RlottieBitmap
+{
+       Gdiplus::Bitmap* image = NULL;
+       int x = 0;
+       int y = 0;
+       unsigned int width = 0;
+       unsigned int height = 0;
+}RlottieBitmap;
\ No newline at end of file
diff --git a/example/win32Player/rlottiePlayer.ico b/example/win32Player/rlottiePlayer.ico
new file mode 100644 (file)
index 0000000..b3ec03b
Binary files /dev/null and b/example/win32Player/rlottiePlayer.ico differ
diff --git a/example/win32Player/rlottiePlayer.rc b/example/win32Player/rlottiePlayer.rc
new file mode 100644 (file)
index 0000000..0c7935f
Binary files /dev/null and b/example/win32Player/rlottiePlayer.rc differ
diff --git a/example/win32Player/rlottiePlayer.sln b/example/win32Player/rlottiePlayer.sln
new file mode 100644 (file)
index 0000000..d1c8f0d
--- /dev/null
@@ -0,0 +1,31 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.30503.244
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rlottiePlayer", "rlottiePlayer.vcxproj", "{CC7AD634-4D29-4D8E-997D-9727DABB44EE}"
+EndProject
+Global
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution
+               Debug|x64 = Debug|x64
+               Debug|x86 = Debug|x86
+               Release|x64 = Release|x64
+               Release|x86 = Release|x86
+       EndGlobalSection
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution
+               {CC7AD634-4D29-4D8E-997D-9727DABB44EE}.Debug|x64.ActiveCfg = Debug|x64
+               {CC7AD634-4D29-4D8E-997D-9727DABB44EE}.Debug|x64.Build.0 = Debug|x64
+               {CC7AD634-4D29-4D8E-997D-9727DABB44EE}.Debug|x86.ActiveCfg = Debug|Win32
+               {CC7AD634-4D29-4D8E-997D-9727DABB44EE}.Debug|x86.Build.0 = Debug|Win32
+               {CC7AD634-4D29-4D8E-997D-9727DABB44EE}.Release|x64.ActiveCfg = Release|x64
+               {CC7AD634-4D29-4D8E-997D-9727DABB44EE}.Release|x64.Build.0 = Release|x64
+               {CC7AD634-4D29-4D8E-997D-9727DABB44EE}.Release|x86.ActiveCfg = Release|Win32
+               {CC7AD634-4D29-4D8E-997D-9727DABB44EE}.Release|x86.Build.0 = Release|Win32
+       EndGlobalSection
+       GlobalSection(SolutionProperties) = preSolution
+               HideSolutionNode = FALSE
+       EndGlobalSection
+       GlobalSection(ExtensibilityGlobals) = postSolution
+               SolutionGuid = {57EEA15F-28FB-4C19-96B4-7B62BFA0CFE5}
+       EndGlobalSection
+EndGlobal
diff --git a/example/win32Player/rlottiePlayer.vcxproj b/example/win32Player/rlottiePlayer.vcxproj
new file mode 100644 (file)
index 0000000..18e6533
--- /dev/null
@@ -0,0 +1,164 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup Label="ProjectConfigurations">
+    <ProjectConfiguration Include="Debug|Win32">
+      <Configuration>Debug</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|Win32">
+      <Configuration>Release</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Debug|x64">
+      <Configuration>Debug</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|x64">
+      <Configuration>Release</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+  </ItemGroup>
+  <PropertyGroup Label="Globals">
+    <VCProjectVersion>16.0</VCProjectVersion>
+    <Keyword>Win32Proj</Keyword>
+    <ProjectGuid>{cc7ad634-4d29-4d8e-997d-9727dabb44ee}</ProjectGuid>
+    <RootNamespace>rlottiePlayer</RootNamespace>
+    <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <PlatformToolset>v142</PlatformToolset>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <PlatformToolset>v142</PlatformToolset>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <PlatformToolset>v142</PlatformToolset>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <PlatformToolset>v142</PlatformToolset>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+  <ImportGroup Label="ExtensionSettings">
+  </ImportGroup>
+  <ImportGroup Label="Shared">
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <PropertyGroup Label="UserMacros" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <LinkIncremental>true</LinkIncremental>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <LinkIncremental>false</LinkIncremental>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <LinkIncremental>true</LinkIncremental>
+    <IncludePath>..\..\inc;$(IncludePath)</IncludePath>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <LinkIncremental>false</LinkIncremental>
+  </PropertyGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <SDLCheck>true</SDLCheck>
+      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <ConformanceMode>true</ConformanceMode>
+    </ClCompile>
+    <Link>
+      <SubSystem>Windows</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <SDLCheck>true</SDLCheck>
+      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <ConformanceMode>true</ConformanceMode>
+    </ClCompile>
+    <Link>
+      <SubSystem>Windows</SubSystem>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <SDLCheck>true</SDLCheck>
+      <PreprocessorDefinitions>_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <ConformanceMode>true</ConformanceMode>
+    </ClCompile>
+    <Link>
+      <SubSystem>Windows</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;rlottie.lib;gdiplus.lib;%(AdditionalDependencies)</AdditionalDependencies>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <SDLCheck>true</SDLCheck>
+      <PreprocessorDefinitions>NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <ConformanceMode>true</ConformanceMode>
+    </ClCompile>
+    <Link>
+      <SubSystem>Windows</SubSystem>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemGroup>
+    <ClInclude Include="animation.h" />
+    <ClInclude Include="framework.h" />
+    <ClInclude Include="Resource.h" />
+    <ClInclude Include="rlottiePlayer.h" />
+    <ClInclude Include="targetver.h" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="rlottiePlayer.cpp" />
+    <ClCompile Include="Source.cpp" />
+  </ItemGroup>
+  <ItemGroup>
+    <ResourceCompile Include="rlottiePlayer.rc" />
+  </ItemGroup>
+  <ItemGroup>
+    <Image Include="rlottiePlayer.ico" />
+    <Image Include="small.ico" />
+  </ItemGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+  <ImportGroup Label="ExtensionTargets">
+  </ImportGroup>
+</Project>
\ No newline at end of file
diff --git a/example/win32Player/rlottiePlayer.vcxproj.filters b/example/win32Player/rlottiePlayer.vcxproj.filters
new file mode 100644 (file)
index 0000000..c8cf65b
--- /dev/null
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup>
+    <Filter Include="Source Files">
+      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+      <Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+    </Filter>
+    <Filter Include="Header Files">
+      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+      <Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
+    </Filter>
+    <Filter Include="Resource Files">
+      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
+      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
+    </Filter>
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="framework.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="targetver.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Resource.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="rlottiePlayer.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="animation.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="rlottiePlayer.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+  </ItemGroup>
+  <ItemGroup>
+    <ResourceCompile Include="rlottiePlayer.rc">
+      <Filter>Resource Files</Filter>
+    </ResourceCompile>
+  </ItemGroup>
+  <ItemGroup>
+    <Image Include="small.ico">
+      <Filter>Resource Files</Filter>
+    </Image>
+    <Image Include="rlottiePlayer.ico">
+      <Filter>Resource Files</Filter>
+    </Image>
+  </ItemGroup>
+</Project>
\ No newline at end of file
diff --git a/example/win32Player/rlottiePlayer.vcxproj.user b/example/win32Player/rlottiePlayer.vcxproj.user
new file mode 100644 (file)
index 0000000..88a5509
--- /dev/null
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup />
+</Project>
\ No newline at end of file
diff --git a/example/win32Player/small.ico b/example/win32Player/small.ico
new file mode 100644 (file)
index 0000000..b3ec03b
Binary files /dev/null and b/example/win32Player/small.ico differ
diff --git a/example/win32Player/targetver.h b/example/win32Player/targetver.h
new file mode 100644 (file)
index 0000000..bf75e08
--- /dev/null
@@ -0,0 +1,6 @@
+#pragma once
+
+// // Including SDKDDKVer.h defines the highest available Windows platform.
+// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
+// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
+#include <SDKDDKVer.h>