From f9e06c04e2d5e666f9fdba0f4cc558829e0152de Mon Sep 17 00:00:00 2001 From: dankan1890 Date: Wed, 2 Nov 2016 09:33:18 +0100 Subject: [PATCH] fixed linux support. --- source/paint/detail/image_ico_ex.hpp | 52 ++++++++++++++-------------- source/paint/detail/image_png.hpp | 2 ++ source/paint/image.cpp | 3 +- source/paint/pixel_buffer.cpp | 4 +-- 4 files changed, 32 insertions(+), 29 deletions(-) diff --git a/source/paint/detail/image_ico_ex.hpp b/source/paint/detail/image_ico_ex.hpp index 33f1d96c..eebdd499 100644 --- a/source/paint/detail/image_ico_ex.hpp +++ b/source/paint/detail/image_ico_ex.hpp @@ -10,47 +10,47 @@ namespace detail { // in an ICO file. typedef struct { - uint8_t bWidth; // Width of the image - uint8_t bHeight; // Height of the image (times 2) - uint8_t bColorCount; // Number of colors in image (0 if >=8bpp) - uint8_t bReserved; // Reserved - uint16_t wPlanes; // Color Planes - uint16_t wBitCount; // Bits per pixel - uint32_t dwBytesInRes; // how many bytes in this resource? - uint32_t dwImageOffset; // where in the file is this image + std::uint8_t bWidth; // Width of the image + std::uint8_t bHeight; // Height of the image (times 2) + std::uint8_t bColorCount; // Number of colors in image (0 if >=8bpp) + std::uint8_t bReserved; // Reserved + std::uint16_t wPlanes; // Color Planes + std::uint16_t wBitCount; // Bits per pixel + std::uint32_t dwBytesInRes; // how many bytes in this resource? + std::uint32_t dwImageOffset; // where in the file is this image } ICONDIRENTRY, *LPICONDIRENTRY; typedef struct { - uint16_t idReserved; // Reserved - uint16_t idType; // resource type (1 for icons) - uint16_t idCount; // how many images? + std::uint16_t idReserved; // Reserved + std::uint16_t idType; // resource type (1 for icons) + std::uint16_t idCount; // how many images? //ICONDIRENTRY idEntries[1]; // the entries for each image } ICONDIR, *LPICONDIR; // size - 40 bytes typedef struct { - uint32_t biSize; - uint32_t biWidth; - uint32_t biHeight; // Icon Height (added height of XOR-Bitmap and AND-Bitmap) - uint16_t biPlanes; - uint16_t biBitCount; - uint32_t biCompression; - int32_t biSizeImage; - uint32_t biXPelsPerMeter; - uint32_t biYPelsPerMeter; - uint32_t biClrUsed; - uint32_t biClrImportant; + std::uint32_t biSize; + std::uint32_t biWidth; + std::uint32_t biHeight; // Icon Height (added height of XOR-Bitmap and AND-Bitmap) + std::uint16_t biPlanes; + std::uint16_t biBitCount; + std::uint32_t biCompression; + std::int32_t biSizeImage; + std::uint32_t biXPelsPerMeter; + std::uint32_t biYPelsPerMeter; + std::uint32_t biClrUsed; + std::uint32_t biClrImportant; } s_BITMAPINFOHEADER, *s_PBITMAPINFOHEADER; // 46 bytes typedef struct { s_BITMAPINFOHEADER icHeader; // DIB header - uint32_t icColors[1]; // Color table (short 4 bytes) //RGBQUAD - uint8_t icXOR[1]; // DIB bits for XOR mask - uint8_t icAND[1]; // DIB bits for AND mask + std::uint32_t icColors[1]; // Color table (short 4 bytes) //RGBQUAD + std::uint8_t icXOR[1]; // DIB bits for XOR mask + std::uint8_t icAND[1]; // DIB bits for AND mask } ICONIMAGE, *LPICONIMAGE; @@ -61,7 +61,7 @@ class image_ico_ex { auto width = 0; auto height = 0; - auto buffer = (unsigned char *)data; + auto buffer = (std::uint8_t *)data; auto icoDir = reinterpret_cast(buffer); int iconsCount = icoDir->idCount; if (icoDir->idReserved != 0 || icoDir->idType != 1 || iconsCount == 0 || iconsCount > 20) diff --git a/source/paint/detail/image_png.hpp b/source/paint/detail/image_png.hpp index 30ba18e5..cc147e06 100644 --- a/source/paint/detail/image_png.hpp +++ b/source/paint/detail/image_png.hpp @@ -11,6 +11,8 @@ #endif #include +#include + namespace nana { diff --git a/source/paint/image.cpp b/source/paint/image.cpp index 65ad6ba2..6875a198 100644 --- a/source/paint/image.cpp +++ b/source/paint/image.cpp @@ -363,8 +363,9 @@ namespace paint if (!ptr && bytes > 40 /* sizeof(BITMAPINFOHEADER) */ && (40 == *reinterpret_cast(data))) { ptr = std::make_shared(true); } + else #endif - else if (!ptr && bytes > 40 && (0x00010000 == *reinterpret_cast(data))) + if (!ptr && bytes > 40 && (0x00010000 == *reinterpret_cast(data))) ptr = std::make_shared(); } } diff --git a/source/paint/pixel_buffer.cpp b/source/paint/pixel_buffer.cpp index f29c4068..2f0816bd 100644 --- a/source/paint/pixel_buffer.cpp +++ b/source/paint/pixel_buffer.cpp @@ -457,7 +457,7 @@ namespace nana{ namespace paint HDC context = drawable->context; HBITMAP pixmap = drawable->pixmap; - HBITMAP orig_bmp; + HBITMAP orig_bmp = pixmap; if(need_dup) { context = ::CreateCompatibleDC(drawable->context); @@ -795,7 +795,7 @@ namespace nana{ namespace paint std::unique_ptr autoptr; auto rgb_color = clr.px_color().value; - nana::pixel_color_t rgb_imd; + nana::pixel_color_t rgb_imd = { 0 }; if(fade) { autoptr = detail::alloc_fade_table(1 - fade_rate);