summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-03-08 21:23:00 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-03-08 21:23:00 +0300
commitfc99e176ada8bb07d55929bcfcf8733f6bd95831 (patch)
tree0b7caeb6602944e7bd26931af20bc04f3a12f79f
parent64bcf1b8fd453638fd24810318fa8716c0b1c249 (diff)
IMGL_WCHAR removed, all paths are in Unicode now
-rw-r--r--include/m_imgsrvc.h10
-rw-r--r--plugins/AVS/src/image_utils.cpp6
-rw-r--r--plugins/FloatingContacts/src/bitmap_funcs.cpp2
-rw-r--r--plugins/HistoryStats/src/canvas.cpp4
-rw-r--r--plugins/Popup/src/bitmap_funcs.cpp2
-rw-r--r--plugins/TabSRMM/src/msgdlgutils.cpp8
-rw-r--r--plugins/TabSRMM/src/themes.cpp4
-rw-r--r--plugins/TipperYM/src/bitmap_func.cpp5
-rw-r--r--plugins/Toaster/src/utils.h4
-rw-r--r--protocols/FacebookRM/src/json.cpp4
-rw-r--r--src/mir_app/src/image_utils.cpp47
-rw-r--r--src/mir_core/src/bitmaps.cpp2
12 files changed, 35 insertions, 63 deletions
diff --git a/include/m_imgsrvc.h b/include/m_imgsrvc.h
index 1eed529833..df1751830d 100644
--- a/include/m_imgsrvc.h
+++ b/include/m_imgsrvc.h
@@ -48,9 +48,7 @@ by the FreeImage project (http://freeimage.sourceforge.net)
// want to do further image manipulations before converting to a Win32 bitmap
// caller MUST then free the FIBITMAP * using fii->FI_Unload() or MS_IMG_UNLOAD (see below)
-#define IMGL_WCHAR 2 // filename is wchar_t
-
-EXTERN_C MIR_APP_DLL(HBITMAP) Image_Load(const wchar_t *pwszPath, int iFlags /* one of IMGL_*/ );
+EXTERN_C MIR_APP_DLL(HBITMAP) Image_Load(const wchar_t *pwszPath, int iFlags = 0 /* one of IMGL_*/ );
/*
* control structure for loading images from memory buffers (e.g. network buffers, memory mapped files).
@@ -69,21 +67,21 @@ EXTERN_C MIR_APP_DLL(HBITMAP) Image_LoadFromMem(const void *pBuf, size_t cbLen,
* you must populate the fields as required, set the mask bits to indicate which member is valid
*/
-// flags for IMGSRVC_INFO.dwMask
+// flags for IMGSRVC_INFO::dwMask
#define IMGI_FBITMAP 1 // the dib member is valid
#define IMGI_HBITMAP 2 // the hbm member is valid
struct IMGSRVC_INFO
{
DWORD cbSize;
- MAllStrings szName;
+ const wchar_t *pwszName;
HBITMAP hbm;
FIBITMAP *dib;
DWORD dwMask;
FREE_IMAGE_FORMAT fif;
};
-EXTERN_C MIR_APP_DLL(int) Image_Save(const IMGSRVC_INFO *pInfo, int iFlags);
+EXTERN_C MIR_APP_DLL(int) Image_Save(const IMGSRVC_INFO *pInfo, int iFlags = 0);
/*
* resizer from loadavatars moved to image service plugin
diff --git a/plugins/AVS/src/image_utils.cpp b/plugins/AVS/src/image_utils.cpp
index 6ac47475b2..d89448e359 100644
--- a/plugins/AVS/src/image_utils.cpp
+++ b/plugins/AVS/src/image_utils.cpp
@@ -161,7 +161,7 @@ void SetHIMETRICtoDP(HDC hdc, SIZE* sz)
HBITMAP BmpFilterLoadBitmap(BOOL *bIsTransparent, const wchar_t *ptszFilename)
{
- FIBITMAP *dib = (FIBITMAP*)Image_Load(ptszFilename, IMGL_RETURNDIB | IMGL_WCHAR);
+ FIBITMAP *dib = (FIBITMAP*)Image_Load(ptszFilename, IMGL_RETURNDIB);
if (dib == nullptr)
return nullptr;
@@ -211,11 +211,11 @@ int BmpFilterSaveBitmap(HBITMAP hBmp, const wchar_t *ptszFile, int flags)
IMGSRVC_INFO i = { 0 };
i.cbSize = sizeof(IMGSRVC_INFO);
- i.szName.w = tszFilename;
+ i.pwszName = tszFilename;
i.hbm = hBmp;
i.dwMask = IMGI_HBITMAP;
i.fif = FIF_UNKNOWN;
- return !Image_Save(&i, MAKELONG(IMGL_WCHAR, flags));
+ return !Image_Save(&i, flags);
}
// Other utilities ////////////////////////////////////////////////////////////////////////////////
diff --git a/plugins/FloatingContacts/src/bitmap_funcs.cpp b/plugins/FloatingContacts/src/bitmap_funcs.cpp
index d81c2102ff..2c0ff762e8 100644
--- a/plugins/FloatingContacts/src/bitmap_funcs.cpp
+++ b/plugins/FloatingContacts/src/bitmap_funcs.cpp
@@ -935,7 +935,7 @@ bool MyBitmap::loadFromFile_gradient(const char *fn)
bool MyBitmap::loadFromFile_default(const char *fn, const char *fnAlpha)
{
SIZE sz;
- HBITMAP hBmpLoaded = Image_Load((const wchar_t*)fn, 0);
+ HBITMAP hBmpLoaded = Image_Load(_A2T(fn));
if (!hBmpLoaded)
return false;
diff --git a/plugins/HistoryStats/src/canvas.cpp b/plugins/HistoryStats/src/canvas.cpp
index 1639521957..b85cca45fc 100644
--- a/plugins/HistoryStats/src/canvas.cpp
+++ b/plugins/HistoryStats/src/canvas.cpp
@@ -138,6 +138,6 @@ bool Canvas::writePNG(const wchar_t* szFileName)
img.dwMask = IMGI_HBITMAP;
img.hbm = m_hBmp;
img.fif = FIF_PNG;
- img.szName.w = (wchar_t*)szFileName;
- return Image_Save(&img, IMGL_WCHAR) == 0;
+ img.pwszName = (wchar_t*)szFileName;
+ return Image_Save(&img) == 0;
}
diff --git a/plugins/Popup/src/bitmap_funcs.cpp b/plugins/Popup/src/bitmap_funcs.cpp
index 0107441a57..9f20a65aa6 100644
--- a/plugins/Popup/src/bitmap_funcs.cpp
+++ b/plugins/Popup/src/bitmap_funcs.cpp
@@ -730,7 +730,7 @@ bool MyBitmap::loadFromFile(const wchar_t *fn)
if (!wcsncmp(fn, L"gradient:", mir_wstrlen(L"gradient:")))
return loadFromFile_gradient(fn);
- HBITMAP hBmpLoaded = Image_Load(fn, IMGL_WCHAR);
+ HBITMAP hBmpLoaded = Image_Load(fn);
if (!hBmpLoaded)
return false;
diff --git a/plugins/TabSRMM/src/msgdlgutils.cpp b/plugins/TabSRMM/src/msgdlgutils.cpp
index 574a228ece..a619dffa0d 100644
--- a/plugins/TabSRMM/src/msgdlgutils.cpp
+++ b/plugins/TabSRMM/src/msgdlgutils.cpp
@@ -183,11 +183,11 @@ static void SaveAvatarToFile(CTabBaseDlg *dat, HBITMAP hbm, int isOwnPic)
IMGSRVC_INFO ii;
ii.cbSize = sizeof(ii);
- ii.szName.w = szFinalFilename;
+ ii.pwszName = szFinalFilename;
ii.hbm = hbm;
ii.dwMask = IMGI_HBITMAP;
ii.fif = FIF_UNKNOWN; // get the format from the filename extension. png is default.
- Image_Save(&ii, IMGL_WCHAR);
+ Image_Save(&ii);
}
}
@@ -1813,10 +1813,10 @@ void CTabBaseDlg::SendHBitmapAsFile(HBITMAP hbmp) const
IMGSRVC_INFO ii;
ii.cbSize = sizeof(ii);
ii.hbm = hbmp;
- ii.szName.w = filename;
+ ii.pwszName = filename;
ii.dwMask = IMGI_HBITMAP;
ii.fif = FIF_JPEG;
- Image_Save(&ii, IMGL_WCHAR);
+ Image_Save(&ii);
int totalCount = 0;
wchar_t **ppFiles = nullptr;
diff --git a/plugins/TabSRMM/src/themes.cpp b/plugins/TabSRMM/src/themes.cpp
index ec2390160a..4791b19699 100644
--- a/plugins/TabSRMM/src/themes.cpp
+++ b/plugins/TabSRMM/src/themes.cpp
@@ -1722,7 +1722,7 @@ void CSkin::setupAeroSkins()
m_dwmColorRGB = RGB((BYTE)fr, (BYTE)fg, (BYTE)fb);
- FIBITMAP *fib = (FIBITMAP *)Image_Load(tszFilename, IMGL_WCHAR | IMGL_RETURNDIB);
+ FIBITMAP *fib = (FIBITMAP *)Image_Load(tszFilename, IMGL_RETURNDIB);
HBITMAP hbm = FreeImage_CreateHBITMAPFromDIB(fib);
@@ -1764,7 +1764,7 @@ void CSkin::setupAeroSkins()
if (!PathFileExists(tszFilename))
mir_snwprintf(tszFilename, L"%stabskin_aero_glow.png", tszBasePath);
- fib = (FIBITMAP *)Image_Load(tszFilename, IMGL_WCHAR | IMGL_RETURNDIB);
+ fib = (FIBITMAP *)Image_Load(tszFilename, IMGL_RETURNDIB);
COLORREF glowColor = M.GetDword(FONTMODULE, "aeroGlow", RGB(40, 40, 255));
hbm = FreeImage_CreateHBITMAPFromDIB(fib);
diff --git a/plugins/TipperYM/src/bitmap_func.cpp b/plugins/TipperYM/src/bitmap_func.cpp
index d2f7f561b5..1bc5552107 100644
--- a/plugins/TipperYM/src/bitmap_func.cpp
+++ b/plugins/TipperYM/src/bitmap_func.cpp
@@ -154,8 +154,9 @@ void CreateFromBitmaps(bool bServiceTip)
if (tszFileName && *tszFileName != 0) {
FIBITMAP *fib = nullptr;
if (!skin.bCached) {
- FIBITMAP *fibLoad = (FIBITMAP *)Image_Load(tszFileName, IMGL_WCHAR | IMGL_RETURNDIB);
- if (!fibLoad) continue;
+ FIBITMAP *fibLoad = (FIBITMAP *)Image_Load(tszFileName, IMGL_RETURNDIB);
+ if (!fibLoad)
+ continue;
if (FreeImage_GetBPP(fibLoad) != 32)
fib = FreeImage_ConvertTo32Bits(fibLoad);
diff --git a/plugins/Toaster/src/utils.h b/plugins/Toaster/src/utils.h
index 524a96730e..97e8b8ed92 100644
--- a/plugins/Toaster/src/utils.h
+++ b/plugins/Toaster/src/utils.h
@@ -44,11 +44,11 @@ public:
if (!(GetFileAttributes(wszSavePath) < 0xFFFFFFF)) {
IMGSRVC_INFO isi = { sizeof(isi) };
- isi.szName.w = wszSavePath;
+ isi.pwszName = wszSavePath;
isi.hbm = _hBitmap;
isi.dwMask = IMGI_HBITMAP;
isi.fif = FREE_IMAGE_FORMAT::FIF_PNG;
- Image_Save(&isi, IMGL_WCHAR);
+ Image_Save(&isi);
}
return mir_wstrdup(wszSavePath);
}
diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp
index 29ca4dd2da..7d6c1c207b 100644
--- a/protocols/FacebookRM/src/json.cpp
+++ b/protocols/FacebookRM/src/json.cpp
@@ -528,11 +528,11 @@ const char* FacebookProto::ParseIcon(const std::string &url)
HBITMAP hBmp = Image_LoadFromMem(reply->pData, reply->dataLength, FIF_UNKNOWN);
if (hBmp != nullptr) {
IMGSRVC_INFO info = { sizeof(info) };
- info.szName.w = wszFileName;
+ info.pwszName = wszFileName;
info.fif = FIF_ICO;
info.dwMask = IMGI_HBITMAP;
info.hbm = hBmp;
- Image_Save(&info, IMGL_WCHAR);
+ Image_Save(&info);
}
}
}
diff --git a/src/mir_app/src/image_utils.cpp b/src/mir_app/src/image_utils.cpp
index ee4bbcf870..0e1a3632e8 100644
--- a/src/mir_app/src/image_utils.cpp
+++ b/src/mir_app/src/image_utils.cpp
@@ -139,28 +139,14 @@ MIR_APP_DLL(HBITMAP) Image_Load(const wchar_t *pwszPath, int iFlags)
if (pwszPath == nullptr)
return 0;
- FREE_IMAGE_FORMAT fif = FIF_UNKNOWN;
- if (iFlags & IMGL_WCHAR)
- fif = FreeImage_GetFileTypeU(pwszPath, 0);
- else
- fif = FreeImage_GetFileType((char*)pwszPath, 0);
-
- if (fif == FIF_UNKNOWN) {
- if (iFlags & IMGL_WCHAR)
- fif = FreeImage_GetFIFFromFilenameU(pwszPath);
- else
- fif = FreeImage_GetFIFFromFilename((char*)pwszPath);
- }
+ FREE_IMAGE_FORMAT fif = FreeImage_GetFileTypeU(pwszPath, 0);
+ if (fif == FIF_UNKNOWN)
+ fif = FreeImage_GetFIFFromFilenameU(pwszPath);
// check that the plugin has reading capabilities ...
if (fif != FIF_UNKNOWN && FreeImage_FIFSupportsReading(fif)) {
// ok, let's load the file
- FIBITMAP *dib;
- if (iFlags & IMGL_WCHAR)
- dib = FreeImage_LoadU(fif, pwszPath, 0);
- else
- dib = FreeImage_Load(fif, (char*)pwszPath, 0);
-
+ FIBITMAP *dib = FreeImage_LoadU(fif, pwszPath, 0);
if (dib == nullptr || (iFlags & IMGL_RETURNDIB))
return HBITMAP(dib);
@@ -202,19 +188,15 @@ MIR_APP_DLL(int) Image_Save(const IMGSRVC_INFO *isi, int iFlags)
return 0;
if (isi->cbSize != sizeof(IMGSRVC_INFO))
return 0;
- if (isi->szName.a == nullptr)
+ if (isi->pwszName == nullptr)
return 0;
FREE_IMAGE_FORMAT fif;
BOOL fUnload = FALSE;
FIBITMAP *dib = nullptr;
- if (isi->fif == FIF_UNKNOWN) {
- if (iFlags & IMGL_WCHAR)
- fif = FreeImage_GetFIFFromFilenameU(isi->szName.w);
- else
- fif = FreeImage_GetFIFFromFilename(isi->szName.a);
- }
+ if (isi->fif == FIF_UNKNOWN)
+ fif = FreeImage_GetFIFFromFilenameU(isi->pwszName);
else
fif = isi->fif;
@@ -233,21 +215,12 @@ MIR_APP_DLL(int) Image_Save(const IMGSRVC_INFO *isi, int iFlags)
if (dib == nullptr)
return 0;
- int flags = HIWORD(iFlags);
-
int ret = 0;
- if (fif == FIF_PNG || fif == FIF_BMP || fif == FIF_JNG) {
- if (iFlags & IMGL_WCHAR)
- ret = FreeImage_SaveU(fif, dib, isi->szName.w, flags);
- else
- ret = FreeImage_Save(fif, dib, isi->szName.a, flags);
- }
+ if (fif == FIF_PNG || fif == FIF_BMP || fif == FIF_JNG)
+ ret = FreeImage_SaveU(fif, dib, isi->pwszName, iFlags);
else {
FIBITMAP *dib_new = FreeImage_ConvertTo24Bits(dib);
- if (iFlags & IMGL_WCHAR)
- ret = FreeImage_SaveU(fif, dib_new, isi->szName.w, flags);
- else
- ret = FreeImage_Save(fif, dib_new, isi->szName.a, flags);
+ ret = FreeImage_SaveU(fif, dib_new, isi->pwszName, iFlags);
FreeImage_Unload(dib_new);
}
diff --git a/src/mir_core/src/bitmaps.cpp b/src/mir_core/src/bitmaps.cpp
index 6fca273d5c..93d5946582 100644
--- a/src/mir_core/src/bitmaps.cpp
+++ b/src/mir_core/src/bitmaps.cpp
@@ -31,7 +31,7 @@ MIR_CORE_DLL(HBITMAP) Bitmap_Load(const wchar_t *ptszFileName)
if (!PathToAbsoluteW(ptszFileName, szFilename))
wcsncpy_s(szFilename, ptszFileName, _TRUNCATE);
- return Image_Load(szFilename, IMGL_WCHAR);
+ return Image_Load(szFilename);
}
MIR_CORE_DLL(void) Bitmap_GetFilter(wchar_t *dest, size_t destLen)