From e7620ecaeb16c16fe62cad2c9bbece945cefb908 Mon Sep 17 00:00:00 2001 From: beru Date: Mon, 20 Jun 2016 14:17:59 +0900 Subject: [PATCH 1/2] an update for image::open method : loading icon memory data --- source/paint/image.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/paint/image.cpp b/source/paint/image.cpp index a1e2c889..800a9aab 100644 --- a/source/paint/image.cpp +++ b/source/paint/image.cpp @@ -100,7 +100,8 @@ namespace paint { close(); #if defined(NANA_WINDOWS) - HICON handle = ::CreateIconFromResource((PBYTE)data, static_cast(bytes), TRUE, 0x00030000); + // use actual resource size, stopped using CreateIconFromResource since it loads blurry image + HICON handle = ::CreateIconFromResourceEx((PBYTE)data, static_cast(bytes), TRUE, 0x00030000, 0, 0, LR_DEFAULTCOLOR); if(handle) { ICONINFO info; @@ -357,6 +358,10 @@ namespace paint else if (bytes > 9 && (0x66697845 == *reinterpret_cast(reinterpret_cast(data)+5))) //Exif ptr = std::make_shared(); #endif + // suppose icon data is bitmap data + if (!ptr && bytes > 40 /* sizeof(BITMAPINFOHEADER) */ && (40 == *reinterpret_cast(data))) { + ptr = std::make_shared(true); + } } } From 7fcbcc1ff2d4aa366e733428451ca2de723d85f4 Mon Sep 17 00:00:00 2001 From: beru Date: Mon, 20 Jun 2016 14:24:15 +0900 Subject: [PATCH 2/2] support loading an icon from memory only on Windows (for now) --- source/paint/image.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/paint/image.cpp b/source/paint/image.cpp index 800a9aab..1f6a8563 100644 --- a/source/paint/image.cpp +++ b/source/paint/image.cpp @@ -358,10 +358,13 @@ namespace paint else if (bytes > 9 && (0x66697845 == *reinterpret_cast(reinterpret_cast(data)+5))) //Exif ptr = std::make_shared(); #endif + +#if defined(NANA_WINDOWS) // suppose icon data is bitmap data if (!ptr && bytes > 40 /* sizeof(BITMAPINFOHEADER) */ && (40 == *reinterpret_cast(data))) { ptr = std::make_shared(true); } +#endif } }