From a3cb945d4e7f525fef62943ac08e6e50dfeafec8 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 28 Feb 2022 21:44:57 +0100 Subject: [PATCH] Tools: [skip ci] remove all references to CxImage --- src/3rdParty/.gitattributes | 1 - src/Doc/CMakeLists.txt | 2 - src/Tools/thumbs/FCStdExtractor.cpp | 274 +++--- src/Tools/thumbs/FCThumbs.dsw | 80 -- src/Tools/thumbs/FCThumbs.vcproj | 905 ------------------ .../thumbs/ThumbnailProvider/CMakeLists.txt | 105 +- .../ThumbnailProvider.vcproj | 583 ----------- 7 files changed, 138 insertions(+), 1812 deletions(-) delete mode 100644 src/Tools/thumbs/FCThumbs.dsw delete mode 100644 src/Tools/thumbs/FCThumbs.vcproj delete mode 100644 src/Tools/thumbs/ThumbnailProvider/ThumbnailProvider.vcproj diff --git a/src/3rdParty/.gitattributes b/src/3rdParty/.gitattributes index 731e814fef..ac0daa070f 100644 --- a/src/3rdParty/.gitattributes +++ b/src/3rdParty/.gitattributes @@ -1,6 +1,5 @@ ANN export-ignore atlas export-ignore -CxImage export-ignore CoinBinding.sln export-ignore boost.CMakeLists.txt export-ignore zlib.CMakeLists.txt export-ignore diff --git a/src/Doc/CMakeLists.txt b/src/Doc/CMakeLists.txt index 7b39633787..d27b68dbcb 100644 --- a/src/Doc/CMakeLists.txt +++ b/src/Doc/CMakeLists.txt @@ -78,9 +78,7 @@ if(DOXYGEN_FOUND) # exclude some subdirectories # src/Tools : content not relevant ? - # src/3rdParty/CxImage : Windows thumbnailer set( DOXYGEN_EXCLUDE_DIR ${CMAKE_SOURCE_DIR}/src/Tools) - list(APPEND DOXYGEN_EXCLUDE_DIR ${CMAKE_SOURCE_DIR}/src/3rdParty/CxImage) list(APPEND DOXYGEN_EXCLUDE_DIR ${CMAKE_SOURCE_DIR}/src/Doc/sphinx) # deprecated modules list(APPEND DOXYGEN_EXCLUDE_DIR ${CMAKE_SOURCE_DIR}/src/Mod/Assembly) diff --git a/src/Tools/thumbs/FCStdExtractor.cpp b/src/Tools/thumbs/FCStdExtractor.cpp index cf2b228f39..d0f9904880 100644 --- a/src/Tools/thumbs/FCStdExtractor.cpp +++ b/src/Tools/thumbs/FCStdExtractor.cpp @@ -32,132 +32,132 @@ #include #include #include -#include -#include -#pragma comment(lib, "WindowsCodecs.lib") - - // The functions - // * CreateStreamOnResource - // * LoadBitmapFromStream - // * CreateHBITMAP - // are taken from https://faithlife.codes/blog/2008/09/displaying_a_splash_screen_with_c_part_i/ - // The code is released under an MIT-style license - - // Creates a stream object initialized with the data from an executable resource. -IStream* CreateStreamOnResource(void* buffer, size_t length) -{ - // initialize return value - IStream* ipStream = NULL; - - // allocate memory to hold the resource data - HGLOBAL hgblResourceData = GlobalAlloc(GMEM_MOVEABLE, length); - if (hgblResourceData == NULL) - goto Return; - - // get a pointer to the allocated memory - LPVOID pvResourceData = GlobalLock(hgblResourceData); - if (pvResourceData == NULL) - goto FreeData; - - // copy the data from the resource to the new memory block - CopyMemory(pvResourceData, buffer, length); - GlobalUnlock(hgblResourceData); - - // create a stream on the HGLOBAL containing the data - - if (SUCCEEDED(CreateStreamOnHGlobal(hgblResourceData, TRUE, &ipStream))) - goto Return; - -FreeData: - // couldn't create stream; free the memory - - GlobalFree(hgblResourceData); - -Return: - // no need to unlock or free the resource - return ipStream; -} - -IWICBitmapSource* LoadBitmapFromStream(IStream* ipImageStream) -{ - // initialize return value - IWICBitmapSource* ipBitmap = NULL; - - // load WIC's PNG decoder - IWICBitmapDecoder* ipDecoder = NULL; - if (FAILED(CoCreateInstance(CLSID_WICPngDecoder, NULL, CLSCTX_INPROC_SERVER, __uuidof(ipDecoder), reinterpret_cast(&ipDecoder)))) - goto Return; - - // load the PNG - if (FAILED(ipDecoder->Initialize(ipImageStream, WICDecodeMetadataCacheOnLoad))) - goto ReleaseDecoder; - - // check for the presence of the first frame in the bitmap - UINT nFrameCount = 0; - if (FAILED(ipDecoder->GetFrameCount(&nFrameCount)) || nFrameCount != 1) - goto ReleaseDecoder; - - // load the first frame (i.e., the image) - IWICBitmapFrameDecode* ipFrame = NULL; - if (FAILED(ipDecoder->GetFrame(0, &ipFrame))) - goto ReleaseDecoder; - - // convert the image to 32bpp BGRA format with pre-multiplied alpha - // (it may not be stored in that format natively in the PNG resource, - // but we need this format to create the DIB to use on-screen) - WICConvertBitmapSource(GUID_WICPixelFormat32bppPBGRA, ipFrame, &ipBitmap); - ipFrame->Release(); - -ReleaseDecoder: - ipDecoder->Release(); -Return: - return ipBitmap; -} - -HBITMAP CreateHBITMAP(IWICBitmapSource* ipBitmap) -{ - // initialize return value - HBITMAP hbmp = NULL; - - // get image attributes and check for valid image - UINT width = 0; - UINT height = 0; - if (FAILED(ipBitmap->GetSize(&width, &height)) || width == 0 || height == 0) - goto Return; - - // prepare structure giving bitmap information (negative height indicates a top-down DIB) - BITMAPINFO bminfo; - ZeroMemory(&bminfo, sizeof(bminfo)); - bminfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - bminfo.bmiHeader.biWidth = width; - bminfo.bmiHeader.biHeight = -((LONG)height); - bminfo.bmiHeader.biPlanes = 1; - bminfo.bmiHeader.biBitCount = 32; - bminfo.bmiHeader.biCompression = BI_RGB; - - // create a DIB section that can hold the image - void* pvImageBits = NULL; - HDC hdcScreen = GetDC(NULL); - hbmp = CreateDIBSection(hdcScreen, &bminfo, DIB_RGB_COLORS, &pvImageBits, NULL, 0); - ReleaseDC(NULL, hdcScreen); - if (hbmp == NULL) - goto Return; - - // extract the image into the HBITMAP - - const UINT cbStride = width * 4; - const UINT cbImage = cbStride * height; - if (FAILED(ipBitmap->CopyPixels(NULL, cbStride, cbImage, static_cast(pvImageBits)))) - { - // couldn't extract image; delete HBITMAP - - DeleteObject(hbmp); - hbmp = NULL; - } - -Return: - return hbmp; -} +#include +#include +#pragma comment(lib, "WindowsCodecs.lib") + + // The functions + // * CreateStreamOnResource + // * LoadBitmapFromStream + // * CreateHBITMAP + // are taken from https://faithlife.codes/blog/2008/09/displaying_a_splash_screen_with_c_part_i/ + // The code is released under an MIT-style license + + // Creates a stream object initialized with the data from an executable resource. +IStream* CreateStreamOnResource(void* buffer, size_t length) +{ + // initialize return value + IStream* ipStream = NULL; + + // allocate memory to hold the resource data + HGLOBAL hgblResourceData = GlobalAlloc(GMEM_MOVEABLE, length); + if (hgblResourceData == NULL) + goto Return; + + // get a pointer to the allocated memory + LPVOID pvResourceData = GlobalLock(hgblResourceData); + if (pvResourceData == NULL) + goto FreeData; + + // copy the data from the resource to the new memory block + CopyMemory(pvResourceData, buffer, length); + GlobalUnlock(hgblResourceData); + + // create a stream on the HGLOBAL containing the data + + if (SUCCEEDED(CreateStreamOnHGlobal(hgblResourceData, TRUE, &ipStream))) + goto Return; + +FreeData: + // couldn't create stream; free the memory + + GlobalFree(hgblResourceData); + +Return: + // no need to unlock or free the resource + return ipStream; +} + +IWICBitmapSource* LoadBitmapFromStream(IStream* ipImageStream) +{ + // initialize return value + IWICBitmapSource* ipBitmap = NULL; + + // load WIC's PNG decoder + IWICBitmapDecoder* ipDecoder = NULL; + if (FAILED(CoCreateInstance(CLSID_WICPngDecoder, NULL, CLSCTX_INPROC_SERVER, __uuidof(ipDecoder), reinterpret_cast(&ipDecoder)))) + goto Return; + + // load the PNG + if (FAILED(ipDecoder->Initialize(ipImageStream, WICDecodeMetadataCacheOnLoad))) + goto ReleaseDecoder; + + // check for the presence of the first frame in the bitmap + UINT nFrameCount = 0; + if (FAILED(ipDecoder->GetFrameCount(&nFrameCount)) || nFrameCount != 1) + goto ReleaseDecoder; + + // load the first frame (i.e., the image) + IWICBitmapFrameDecode* ipFrame = NULL; + if (FAILED(ipDecoder->GetFrame(0, &ipFrame))) + goto ReleaseDecoder; + + // convert the image to 32bpp BGRA format with pre-multiplied alpha + // (it may not be stored in that format natively in the PNG resource, + // but we need this format to create the DIB to use on-screen) + WICConvertBitmapSource(GUID_WICPixelFormat32bppPBGRA, ipFrame, &ipBitmap); + ipFrame->Release(); + +ReleaseDecoder: + ipDecoder->Release(); +Return: + return ipBitmap; +} + +HBITMAP CreateHBITMAP(IWICBitmapSource* ipBitmap) +{ + // initialize return value + HBITMAP hbmp = NULL; + + // get image attributes and check for valid image + UINT width = 0; + UINT height = 0; + if (FAILED(ipBitmap->GetSize(&width, &height)) || width == 0 || height == 0) + goto Return; + + // prepare structure giving bitmap information (negative height indicates a top-down DIB) + BITMAPINFO bminfo; + ZeroMemory(&bminfo, sizeof(bminfo)); + bminfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + bminfo.bmiHeader.biWidth = width; + bminfo.bmiHeader.biHeight = -((LONG)height); + bminfo.bmiHeader.biPlanes = 1; + bminfo.bmiHeader.biBitCount = 32; + bminfo.bmiHeader.biCompression = BI_RGB; + + // create a DIB section that can hold the image + void* pvImageBits = NULL; + HDC hdcScreen = GetDC(NULL); + hbmp = CreateDIBSection(hdcScreen, &bminfo, DIB_RGB_COLORS, &pvImageBits, NULL, 0); + ReleaseDC(NULL, hdcScreen); + if (hbmp == NULL) + goto Return; + + // extract the image into the HBITMAP + + const UINT cbStride = width * 4; + const UINT cbImage = cbStride * height; + if (FAILED(ipBitmap->CopyPixels(NULL, cbStride, cbImage, static_cast(pvImageBits)))) + { + // couldn't extract image; delete HBITMAP + + DeleteObject(hbmp); + hbmp = NULL; + } + +Return: + return hbmp; +} CComModule _Module; @@ -270,17 +270,17 @@ HRESULT CFCStdExtractor::Extract(HBITMAP* phBmpThumbnail) content.push_back(c); } - // pass the memory buffer to CxImage library to create the bitmap handle - IStream* stream = CreateStreamOnResource(&(content[0]), content.size()); - if (stream) { - IWICBitmapSource* bmpSrc = LoadBitmapFromStream(stream); - stream->Release(); - if (bmpSrc) { - m_hPreview = CreateHBITMAP(bmpSrc); - *phBmpThumbnail = m_hPreview; - bmpSrc->Release(); - } - } + // pass the memory buffer to an IStream to create the bitmap handle + IStream* stream = CreateStreamOnResource(&(content[0]), content.size()); + if (stream) { + IWICBitmapSource* bmpSrc = LoadBitmapFromStream(stream); + stream->Release(); + if (bmpSrc) { + m_hPreview = CreateHBITMAP(bmpSrc); + *phBmpThumbnail = m_hPreview; + bmpSrc->Release(); + } + } } } catch(...) { diff --git a/src/Tools/thumbs/FCThumbs.dsw b/src/Tools/thumbs/FCThumbs.dsw deleted file mode 100644 index 7f437e4d9b..0000000000 --- a/src/Tools/thumbs/FCThumbs.dsw +++ /dev/null @@ -1,80 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "CxImage"=..\..\3rdParty\CxImage\CxImage\cximage.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name jpeg - End Project Dependency - Begin Project Dependency - Project_Dep_Name zlib - End Project Dependency -}}} - -############################################################################### - -Project: "FCThumbs"=.\FCThumbs.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name CxImage - End Project Dependency - Begin Project Dependency - Project_Dep_Name jpeg - End Project Dependency - Begin Project Dependency - Project_Dep_Name zlib - End Project Dependency -}}} - -############################################################################### - -Project: "jpeg"=..\..\3rdParty\CxImage\jpeg\Jpeg.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "zlib"=..\..\3rdParty\CxImage\zlib\zlib.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/src/Tools/thumbs/FCThumbs.vcproj b/src/Tools/thumbs/FCThumbs.vcproj deleted file mode 100644 index 0d8bd35163..0000000000 --- a/src/Tools/thumbs/FCThumbs.vcproj +++ /dev/null @@ -1,905 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Tools/thumbs/ThumbnailProvider/CMakeLists.txt b/src/Tools/thumbs/ThumbnailProvider/CMakeLists.txt index 1fb3e771a2..a37fda146e 100644 --- a/src/Tools/thumbs/ThumbnailProvider/CMakeLists.txt +++ b/src/Tools/thumbs/ThumbnailProvider/CMakeLists.txt @@ -4,110 +4,11 @@ cmake_minimum_required(VERSION 2.6.0 FATAL_ERROR) add_definitions(-D_UNICODE -D_CRT_SECURE_NO_WARNINGS) -set(ROOT_DIR ../../../3rdParty/CxImage) - #================================================= # zlib #================================================= -set(zlib_DIR ${ROOT_DIR}/zlib) -SET(zlib_SRCS - ${zlib_DIR}/adler32.c - ${zlib_DIR}/compress.c - ${zlib_DIR}/crc32.c - ${zlib_DIR}/crc32.h - ${zlib_DIR}/deflate.c - ${zlib_DIR}/deflate.h - ${zlib_DIR}/gzio.c - ${zlib_DIR}/infback.c - ${zlib_DIR}/inffast.c - ${zlib_DIR}/inffast.h - ${zlib_DIR}/inffixed.h - ${zlib_DIR}/inflate.c - ${zlib_DIR}/inflate.h - ${zlib_DIR}/inftrees.c - ${zlib_DIR}/inftrees.h - ${zlib_DIR}/trees.c - ${zlib_DIR}/trees.h - ${zlib_DIR}/uncompr.c - ${zlib_DIR}/zconf.h - ${zlib_DIR}/zconf.in.h - ${zlib_DIR}/zlib.h - ${zlib_DIR}/zutil.c - ${zlib_DIR}/zutil.h -) - -set(ZLIB_INCLUDE_DIR ${zlib_DIR}) -set(ZLIB_LIBRARIES zlib) - -add_library(zlib STATIC ${zlib_SRCS}) -target_link_libraries(zlib) - - -#================================================= -# png -#================================================= - -set(png_DIR ${ROOT_DIR}/png) -SET(png_SRCS - ${png_DIR}/png.c - ${png_DIR}/png.h - ${png_DIR}/pngconf.h - ${png_DIR}/pngerror.c - ${png_DIR}/pngget.c - ${png_DIR}/pngmem.c - ${png_DIR}/pngpread.c - ${png_DIR}/pngread.c - ${png_DIR}/pngrio.c - ${png_DIR}/pngrtran.c - ${png_DIR}/pngrutil.c - ${png_DIR}/pngset.c - ${png_DIR}/pngtrans.c - ${png_DIR}/pngvcrd.c - ${png_DIR}/pngwio.c - ${png_DIR}/pngwrite.c - ${png_DIR}/pngwtran.c - ${png_DIR}/pngwutil.c -) - -set(PNG_INCLUDE_DIRS ${png_DIR}) -set(PNG_LIBRARIES png) - -add_library(png STATIC ${png_SRCS}) -target_link_libraries(png) - - -#================================================= -# CxImage -#================================================= - -set(cximage_DIR ${ROOT_DIR}/CxImage) -SET(cximage_SRCS - ${cximage_DIR}/ximage.cpp - ${cximage_DIR}/ximage.h - ${cximage_DIR}/ximapng.cpp - ${cximage_DIR}/ximapng.h - ${cximage_DIR}/xmemfile.cpp - ${cximage_DIR}/xmemfile.h - ${cximage_DIR}/ximainfo.cpp - ${cximage_DIR}/ximaenc.cpp - ${cximage_DIR}/ximapal.cpp - ${cximage_DIR}/ximalpha.cpp - ${cximage_DIR}/ximawnd.cpp - ${cximage_DIR}/ximasel.cpp - ${cximage_DIR}/ximatran.cpp - ${cximage_DIR}/ximalyr.cpp - ${cximage_DIR}/ximaint.cpp - ${cximage_DIR}/ximath.cpp - ${cximage_DIR}/ximadsp.cpp -) - -set(CXIMAGE_INCLUDE_DIRS ${ROOT_DIR}) -set(CXIMAGE_LIBRARIES CxImage) - -add_library(CxImage STATIC ${cximage_SRCS}) -target_link_libraries(CxImage) - +find_package(ZLIB REQUIRED) #================================================= # FCStdThumbnail @@ -117,16 +18,12 @@ target_link_libraries(CxImage) include_directories( . ../../../ - ${PNG_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR} - ${CXIMAGE_INCLUDE_DIRS} ) set(THUMBS_LIBS Shlwapi.lib - ${PNG_LIBRARIES} ${ZLIB_LIBRARIES} - ${CXIMAGE_LIBRARIES} ) set(zipios_DIR ../../..) diff --git a/src/Tools/thumbs/ThumbnailProvider/ThumbnailProvider.vcproj b/src/Tools/thumbs/ThumbnailProvider/ThumbnailProvider.vcproj deleted file mode 100644 index 393940d921..0000000000 --- a/src/Tools/thumbs/ThumbnailProvider/ThumbnailProvider.vcproj +++ /dev/null @@ -1,583 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -