// TestApp1.cpp : Defines the entry point for the application. // #ifdef _WIN32 #include "Win32/stdafx.h" #endif #include class TestApp1 : public DKApplication { DKObject window; public: void OnInitialize(void) override { DKLogD("%s", DKGL_FUNCTION_NAME); DKObject image = DKImage::Create("C:\\Users\\hong\\Desktop\\test\\1.png"); DKObject data = image->EncodeData("png", NULL); data->WriteToFile("C:\\Users\\hong\\Desktop\\test\\2.png", true); Terminate(0); } void OnTerminate(void) override { DKLogD("%s", DKGL_FUNCTION_NAME); DKLogI("Memory Pool Statistics"); size_t numBuckets = DKMemoryPoolNumberOfBuckets(); DKMemoryPoolBucketStatus* buckets = new DKMemoryPoolBucketStatus[numBuckets]; DKMemoryPoolQueryAllocationStatus(buckets, numBuckets); size_t usedBytes = 0; for (int i = 0; i < numBuckets; ++i) { if (buckets[i].totalChunks > 0) { DKLogI("--> %lu: allocated:%lu, reserved:%.1fKB. (usage:%.1f%%)", buckets[i].chunkSize, buckets[i].chunkSize * buckets[i].usedChunks, double(buckets[i].chunkSize * (buckets[i].totalChunks - buckets[i].usedChunks)) / 1024.0, double(buckets[i].usedChunks) / double(buckets[i].totalChunks) * 100.0); usedBytes += buckets[i].chunkSize * buckets[i].usedChunks; } } DKLogI("MemoryPool Usage: %.1fMB / %.1fMB", double(usedBytes) / (1024 * 1024), double(DKMemoryPoolSize()) / (1024 * 1024)); delete[] buckets; } }; #ifdef _WIN32 int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, _In_ int nCmdShow) #else int main(int argc, const char * argv[]) #endif { TestApp1 app; DKPropertySet::SystemConfig().SetValue("AppDelegate", "AppDelegate"); return app.Run(); }