summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/delphi/m_imgsrvc.inc115
-rw-r--r--include/m_imgsrvc.h76
-rw-r--r--libs/win32/mir_app.libbin129562 -> 130394 bytes
-rw-r--r--libs/win64/mir_app.libbin125170 -> 125918 bytes
-rw-r--r--plugins/AVS/src/image_utils.cpp7
-rw-r--r--plugins/AVS/src/services.cpp24
-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.cpp13
-rw-r--r--plugins/TipperYM/src/bitmap_func.cpp2
-rw-r--r--plugins/TipperYM/src/options.cpp8
-rw-r--r--plugins/TipperYM/src/popwin.cpp9
-rw-r--r--plugins/Toaster/src/utils.h28
-rw-r--r--plugins/Utils.pas/mirutils.pas12
-rw-r--r--plugins/Watrack/popup/pop_vars.inc1
-rw-r--r--plugins/Watrack/popup/popups.pas9
-rw-r--r--protocols/FacebookRM/src/captcha.cpp7
-rw-r--r--protocols/FacebookRM/src/json.cpp11
-rw-r--r--protocols/Gadu-Gadu/src/image.cpp15
-rw-r--r--protocols/Gadu-Gadu/src/token.cpp10
-rw-r--r--protocols/JabberG/src/jabber_captcha.cpp7
-rw-r--r--protocols/VKontakte/src/vk_captcha.cpp6
-rw-r--r--src/mir_app/src/image_utils.cpp130
-rw-r--r--src/mir_app/src/mir_app.def4
-rw-r--r--src/mir_app/src/mir_app64.def4
-rw-r--r--src/mir_app/src/utils.cpp3
-rw-r--r--src/mir_core/src/bitmaps.cpp5
29 files changed, 133 insertions, 389 deletions
diff --git a/include/delphi/m_imgsrvc.inc b/include/delphi/m_imgsrvc.inc
index 473740829a..ef770733f2 100644
--- a/include/delphi/m_imgsrvc.inc
+++ b/include/delphi/m_imgsrvc.inc
@@ -47,7 +47,8 @@ by the FreeImage project (http://freeimage.sourceforge.net)
returns a valid HBITMAP or 0 if image cannot be loaded
if IMGL_RETURNDIB is set, it returns a pointer to a freeimage bitmap (FIBITMAP *)
}
- MS_IMG_LOAD:PAnsiChar = 'IMG/Load';
+
+function Image_Load(fileName:PWideChar; flags:int): HBITMAP; stdcall; external AppDll;
{
control structure for loading images from memory buffers (e.g. network buffers,
@@ -96,17 +97,6 @@ const
FIF_PICT = 33;
FIF_RAW = 34;
-type
- TIMGSRVC_MEMIO = record
- iLen:cardinal; // length of the buffer
- pBuf:pointer; // the buffer itself (you are responsible for allocating and free'ing it)
- fif:integer; // FREE_IMAGE_FORMAT,-1 to detect the format or one of the FIF_* image
- // format constant. Make sure to provide the right one.
- flags:dword; // flags to pass to FreeImage_LoadFromMem() (see freeimage docs)
- end;
- _tagIMGSRVC_MEMIO = TIMGSRVC_MEMIO;
-
-const
{
load an image from a memory buffer
wParam = IMGSRVC_MEMIO *
@@ -114,106 +104,7 @@ const
you must popupate iLen (buffer length) and pBuf (pointer to memory buffer)
you must also specify the format in IMGSRVC_MEMIO.fif using one of the FIF_* constants
}
- MS_IMG_LOADFROMMEM:PAnsiChar = 'IMG/LoadFromMem';
-
-// flags for IMGSRVC_INFO.dwMask
-
- IMGI_FBITMAP = 1; // the dib member is valid
- IMGI_HBITMAP = 2; // the hbm member is valid
-
-{
- generic structure for various img functions
- you must populate the fields as required, set the mask bits to indicate which member is valid
-}
-
-type
-//!!
-{
- FIBITMAP = record
- data : pointer;
- end;
- PFIBITMAP = ^FIBITMAP;
-}
- TIMGSRVC_INFO = record
- cbSize:dword;
- szName:TChar;
- hbm:HBITMAP;
- dib:pointer; // PFIBITMAP
- dwMask:dword;
- fif:integer; // FREE_IMAGE_FORMAT
- end;
- _tagIMGSRVC_INFO = TIMGSRVC_INFO;
-
-const
-{
- save image to disk
- wParam = pointer to IMGSRVC_INFO (szName/wszName, hbm OR dib, cbSize, dwMask
- mandatory. fif optional, if FIF_UNKNOWN is given it will be determined
- from the filename).
- lParam = low word: IMG_* flags (IMGL_WCHAR is the only valid - filename will be assumed
- to be wchar_t and wszName must be used)
- high word: FreeImage_Save flags
- set IMGSRVC_INFO.dwMask to indicate whether the HBITMAP of FIBITMAP member is valid
-}
- MS_IMG_SAVE:PAnsiChar = 'IMG/Save';
-
-{
- unload a FIFBITMAP
- wParam = FIFBITMAP *
- lParam = 0;
- this service is useful when you have loaded a bitmap with IMGL_RETURNDIB in
- which case you do not get a HBITMAP but instead a FBITMAP * which describes
- the freeimage-internal representation of a bitmap.
-}
- MS_IMG_UNLOAD:PAnsiChar = 'IMG/Unload';
-
-{
- resizer from loadavatars moved to image service plugin
-}
-
- RESIZEBITMAP_STRETCH = 0; // Distort bitmap to size in (max_width, max_height)
- RESIZEBITMAP_KEEP_PROPORTIONS = 1; // Keep bitmap proportions (probabily only
- // one of the max_width/max_height will be
- // respected, and the other will be smaller)
- RESIZEBITMAP_CROP = 2; // Keep bitmap proportions but crop it to
- // fix exactly in (max_width, max_height)
- // Some image info outside will be lost
- RESIZEBITMAP_MAKE_SQUARE = 3; // Image will be allways square. Image will
- // be croped and the size returned will be
- // min(max_width, max_height)
- RESIZEBITMAP_FLAG_DONT_GROW = $1000; // If set, the image will not grow. Else,
- // it will grow to fit the max width/height
-
-type
- TResizeBitmap = record
- size :size_t; // sizeof(ResizeBitmap);
- hBmp :HBITMAP;
- max_width :int;
- max_height:int;
- fit :int; // One of RESIZEBITMAP_* with an OR with RESIZEBITMAP_FLAG_DONT_GROW if needed
- end;
-
-const
-{
- Returns a copy of the bitmap with the size especified or the original bitmap
- if nothing has to be changed
- wParam = ResizeBitmap *
- lParam = NULL
- return NULL on error, ResizeBitmap->hBmp if don't need to resize or a new HBITMAP if resized
- You are responsible for calling DestroyObject() on the original HBITMAP
-}
- MS_IMG_RESIZE:PAnsiChar = 'IMG/ResizeBitmap';
-
-{
- * format conversion helpers
- *
- * these helper macros allow converting HBITMAP to FIBITMAP * format and vice vera. In any case,
- * the caller is responsible for freeing or deleting the original object.
- * These macros wrap around the FI_CreateHBITMAPFromDib() and FI_CreateDIBFromHBITMAP() interface
- * functions.
-}
-//#define FI_HBM2DIB(x) (FI_CreateDIBFromHBITMAP((x)))
-//#define FI_DIB2HBM(x) (FI_CreateHBITMAPFromDIB((x)))
+function Image_LoadFromMem(pData:pointer; cbLen:cardinal; format:int): HBITMAP; stdcall; external AppDll;
{$ENDIF}
diff --git a/include/m_imgsrvc.h b/include/m_imgsrvc.h
index 883b3a99f6..1eed529833 100644
--- a/include/m_imgsrvc.h
+++ b/include/m_imgsrvc.h
@@ -38,9 +38,9 @@ by the FreeImage project (http://freeimage.sourceforge.net)
#include "../libs/freeimage/src/FreeImage.h"
+#include <m_core.h>
+
// load an image from disk
-// wParam = full path and filename to the image
-// lParam = IMGL_* flags
// returns a valid HBITMAP or 0 if image cannot be loaded
// if IMGL_RETURNDIB is set, it returns a pointer to a freeimage bitmap (FIBITMAP *)
@@ -50,65 +50,49 @@ by the FreeImage project (http://freeimage.sourceforge.net)
#define IMGL_WCHAR 2 // filename is wchar_t
-#define MS_IMG_LOAD "IMG/Load"
+EXTERN_C MIR_APP_DLL(HBITMAP) Image_Load(const wchar_t *pwszPath, int iFlags /* one of IMGL_*/ );
/*
* control structure for loading images from memory buffers (e.g. network buffers, memory mapped files).
*/
-struct IMGSRVC_MEMIO
-{
- long iLen; // length of the buffer
- void *pBuf; // the buffer itself (you are responsible for allocating and free'ing it)
- FREE_IMAGE_FORMAT fif; // -1 to detect the format or one of the FIF_* image format constants
- UINT flags; // flags to pass to FreeImage_LoadFromMemory() (see freeimage docs)
-};
-
// load an image from a memory buffer
// wParam = IMGSRVC_MEMIO *
// lParam = flags (see IMG/Load), valid are IMGL_RETURNDIB
// you must popupate iLen (buffer length) and pBuf (pointer to memory buffer)
// you must also specify the format in IMGSRVC_MEMIO.fif using one of the FIF_* constants defined in m_freeimage.h
-#define MS_IMG_LOADFROMMEM "IMG/LoadFromMem"
-
-// flags for IMGSRVC_INFO.dwMask
-
-#define IMGI_FBITMAP 1 // the dib member is valid
-#define IMGI_HBITMAP 2 // the hbm member is valid
+EXTERN_C MIR_APP_DLL(HBITMAP) Image_LoadFromMem(const void *pBuf, size_t cbLen, FREE_IMAGE_FORMAT fif);
/*
* generic structure for various img functions
* you must populate the fields as required, set the mask bits to indicate which member is valid
*/
+// 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;
- union {
- char *szName;
- wchar_t *wszName;
- wchar_t *tszName;
- };
+ MAllStrings szName;
HBITMAP hbm;
FIBITMAP *dib;
DWORD dwMask;
FREE_IMAGE_FORMAT fif;
};
-// save image to disk
-// wParam = IMGSRVC_INFO * (szName/wszName, hbm OR dib, cbSize, dwMask mandatory. fif optional, if FIF_UNKNOWN is given
-// it will be determined from the filename).
-// lParam = low word: IMG_* flags (IMGL_WCHAR is the only valid - filename will be assumed to be wchar_t and wszName must be used)
-// high word: FreeImage_Save flags
-// set IMGSRVC_INFO.dwMask to indicate whether the HBITMAP of FIBITMAP member is valid
-
-#define MS_IMG_SAVE "IMG/Save"
+EXTERN_C MIR_APP_DLL(int) Image_Save(const IMGSRVC_INFO *pInfo, int iFlags);
/*
* resizer from loadavatars moved to image service plugin
*/
+// Returns a copy of the bitmap with the size especified or the original bitmap if nothing has to be changed
+// returns NULL on error, hBmp if don't need to resize or a new HBITMAP if resized
+// You are responsible for calling DestroyObject() on the original HBITMAP
+
#define RESIZEBITMAP_STRETCH 0 // Distort bitmap to size in (max_width, max_height)
#define RESIZEBITMAP_KEEP_PROPORTIONS 1 // Keep bitmap proportions (probabily only one of the
// max_width/max_height will be respected, and the other will be
@@ -120,36 +104,6 @@ struct IMGSRVC_INFO
#define RESIZEBITMAP_FLAG_DONT_GROW 0x1000 // If set, the image will not grow. Else, it will grow to fit the max width/height
-typedef struct {
- size_t size; // sizeof(ResizeBitmap);
-
- HBITMAP hBmp;
-
- int max_width;
- int max_height;
-
- int fit; // One of RESIZEBITMAP_* with an OR with RESIZEBITMAP_FLAG_DONT_GROW if needed
-} ResizeBitmap;
-
-// Returns a copy of the bitmap with the size especified or the original bitmap if nothing has to be changed
-// wParam = ResizeBitmap *
-// lParam = NULL
-// return NULL on error, ResizeBitmap->hBmp if don't need to resize or a new HBITMAP if resized
-// You are responsible for calling DestroyObject() on the original HBITMAP
-
-#define MS_IMG_RESIZE "IMG/ResizeBitmap"
-
-
-/*
- * format conversion helpers
- *
- * these helper macros allow converting HBITMAP to FIBITMAP * format and vice vera. In any case,
- * the caller is responsible for freeing or deleting the original object.
- * These macros wrap around the FI_CreateHBITMAPFromDib() and FI_CreateDIBFromHBITMAP() interface
- * functions.
- */
-
-//#define FI_HBM2DIB(x) (FI_CreateDIBFromHBITMAP((x)))
-//#define FI_DIB2HBM(x) (FI_CreateHBITMAPFromDIB((x)))
+EXTERN_C MIR_APP_DLL(HBITMAP) Image_Resize(HBITMAP hBmp, int fit /* RESIZEBITMAP_*/, int max_width, int max_height);
#endif // __M_IMGSRVC_H
diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib
index 258fb23bd0..952858edd8 100644
--- a/libs/win32/mir_app.lib
+++ b/libs/win32/mir_app.lib
Binary files differ
diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib
index 8f45bbccef..993d1bf4ab 100644
--- a/libs/win64/mir_app.lib
+++ b/libs/win64/mir_app.lib
Binary files differ
diff --git a/plugins/AVS/src/image_utils.cpp b/plugins/AVS/src/image_utils.cpp
index c34a998aa3..6ac47475b2 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*)CallService(MS_IMG_LOAD, (WPARAM)ptszFilename, IMGL_RETURNDIB | IMGL_WCHAR);
+ FIBITMAP *dib = (FIBITMAP*)Image_Load(ptszFilename, IMGL_RETURNDIB | IMGL_WCHAR);
if (dib == nullptr)
return nullptr;
@@ -211,12 +211,11 @@ int BmpFilterSaveBitmap(HBITMAP hBmp, const wchar_t *ptszFile, int flags)
IMGSRVC_INFO i = { 0 };
i.cbSize = sizeof(IMGSRVC_INFO);
- i.wszName = tszFilename;
+ i.szName.w = tszFilename;
i.hbm = hBmp;
i.dwMask = IMGI_HBITMAP;
i.fif = FIF_UNKNOWN;
-
- return !CallService(MS_IMG_SAVE, (WPARAM)&i, MAKELONG(IMGL_WCHAR, flags));
+ return !Image_Save(&i, MAKELONG(IMGL_WCHAR, flags));
}
// Other utilities ////////////////////////////////////////////////////////////////////////////////
diff --git a/plugins/AVS/src/services.cpp b/plugins/AVS/src/services.cpp
index a0b445057a..691b84ee10 100644
--- a/plugins/AVS/src/services.cpp
+++ b/plugins/AVS/src/services.cpp
@@ -397,15 +397,8 @@ static int SetProtoMyAvatar(char *protocol, HBITMAP hBmp, wchar_t *originalFilen
int num_tries = 0;
do {
// Lets do it
- ResizeBitmap rb;
- rb.size = sizeof(ResizeBitmap);
- rb.hBmp = hBmp;
- rb.max_height = d.height;
- rb.max_width = d.width;
- rb.fit = (grow ? 0 : RESIZEBITMAP_FLAG_DONT_GROW)
- | (square ? RESIZEBITMAP_MAKE_SQUARE : RESIZEBITMAP_KEEP_PROPORTIONS);
-
- d.hBmpProto = (HBITMAP)CallService(MS_IMG_RESIZE, WPARAM(&rb), 0);
+ int fit = (grow ? 0 : RESIZEBITMAP_FLAG_DONT_GROW) | (square ? RESIZEBITMAP_MAKE_SQUARE : RESIZEBITMAP_KEEP_PROPORTIONS);
+ d.hBmpProto = Image_Resize(hBmp, fit, d.height, d.width);
if (d.hBmpProto == nullptr) {
if (d.temp_file[0] != '\0')
@@ -552,17 +545,8 @@ static int InternalSetMyAvatar(char *protocol, wchar_t *szFinalName, SetMyAvatar
}
else {
// Resize (to avoid too big avatars)
- ResizeBitmap rb = { 0 };
- rb.size = sizeof(ResizeBitmap);
- rb.hBmp = hBmp;
- rb.max_height = 300;
- rb.max_width = 300;
- rb.fit = (data.grow ? 0 : RESIZEBITMAP_FLAG_DONT_GROW)
- | (data.square ? RESIZEBITMAP_MAKE_SQUARE : RESIZEBITMAP_KEEP_PROPORTIONS);
-
- HBITMAP hBmpTmp = (HBITMAP)CallService(MS_IMG_RESIZE, WPARAM(&rb), 0);
-
- // Check if need to resize
+ int fit = (data.grow ? 0 : RESIZEBITMAP_FLAG_DONT_GROW) | (data.square ? RESIZEBITMAP_MAKE_SQUARE : RESIZEBITMAP_KEEP_PROPORTIONS);
+ HBITMAP hBmpTmp = Image_Resize(hBmp, fit, 300, 300);
if (hBmpTmp == hBmp || hBmpTmp == nullptr) {
// Use original image
mir_snwprintf(globalFile, L"%s\\my_global_avatar%s", globalFile, ext);
diff --git a/plugins/FloatingContacts/src/bitmap_funcs.cpp b/plugins/FloatingContacts/src/bitmap_funcs.cpp
index 5cbf09bc9b..d81c2102ff 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 = (HBITMAP)CallService(MS_IMG_LOAD, (WPARAM)fn, 0);
+ HBITMAP hBmpLoaded = Image_Load((const wchar_t*)fn, 0);
if (!hBmpLoaded)
return false;
diff --git a/plugins/HistoryStats/src/canvas.cpp b/plugins/HistoryStats/src/canvas.cpp
index 215f631104..1639521957 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.tszName = (wchar_t*)szFileName;
- return CallService(MS_IMG_SAVE, (WPARAM)&img, IMGL_WCHAR) == 0;
+ img.szName.w = (wchar_t*)szFileName;
+ return Image_Save(&img, IMGL_WCHAR) == 0;
}
diff --git a/plugins/Popup/src/bitmap_funcs.cpp b/plugins/Popup/src/bitmap_funcs.cpp
index cbce9cf707..0107441a57 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 = (HBITMAP)CallService(MS_IMG_LOAD, (WPARAM)fn, IMGL_WCHAR);
+ HBITMAP hBmpLoaded = Image_Load(fn, IMGL_WCHAR);
if (!hBmpLoaded)
return false;
diff --git a/plugins/TabSRMM/src/msgdlgutils.cpp b/plugins/TabSRMM/src/msgdlgutils.cpp
index fae16eb748..088a95636d 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.wszName = szFinalFilename;
+ ii.szName.w = szFinalFilename;
ii.hbm = hbm;
ii.dwMask = IMGI_HBITMAP;
ii.fif = FIF_UNKNOWN; // get the format from the filename extension. png is default.
- CallService(MS_IMG_SAVE, (WPARAM)&ii, IMGL_WCHAR);
+ Image_Save(&ii, IMGL_WCHAR);
}
}
@@ -1813,10 +1813,10 @@ void CTabBaseDlg::SendHBitmapAsFile(HBITMAP hbmp) const
IMGSRVC_INFO ii;
ii.cbSize = sizeof(ii);
ii.hbm = hbmp;
- ii.wszName = filename;
+ ii.szName.w = filename;
ii.dwMask = IMGI_HBITMAP;
ii.fif = FIF_JPEG;
- CallService(MS_IMG_SAVE, (WPARAM)&ii, IMGL_WCHAR);
+ Image_Save(&ii, IMGL_WCHAR);
int totalCount = 0;
wchar_t **ppFiles = nullptr;
diff --git a/plugins/TabSRMM/src/themes.cpp b/plugins/TabSRMM/src/themes.cpp
index 1ef9533f8e..ec2390160a 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 *)CallService(MS_IMG_LOAD, (WPARAM)tszFilename, IMGL_WCHAR | IMGL_RETURNDIB);
+ FIBITMAP *fib = (FIBITMAP *)Image_Load(tszFilename, IMGL_WCHAR | 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 *)CallService(MS_IMG_LOAD, (WPARAM)tszFilename, IMGL_WCHAR | IMGL_RETURNDIB);
+ fib = (FIBITMAP *)Image_Load(tszFilename, IMGL_WCHAR | IMGL_RETURNDIB);
COLORREF glowColor = M.GetDword(FONTMODULE, "aeroGlow", RGB(40, 40, 255));
hbm = FreeImage_CreateHBITMAPFromDIB(fib);
@@ -2078,14 +2078,7 @@ HBITMAP CSkin::ResizeBitmap(HBITMAP hBmpSrc, LONG width, LONG height, bool &must
GetObject(hBmpSrc, sizeof(bm), &bm);
if (bm.bmHeight != height || bm.bmWidth != width) {
- ::ResizeBitmap rb;
- rb.size = sizeof(rb);
- rb.fit = RESIZEBITMAP_STRETCH;
- rb.max_height = height;
- rb.max_width = width;
- rb.hBmp = hBmpSrc;
-
- HBITMAP hbmNew = (HBITMAP)CallService(MS_IMG_RESIZE, (WPARAM)&rb, 0);
+ HBITMAP hbmNew = Image_Resize(hBmpSrc, RESIZEBITMAP_STRETCH, height, width);
if (hbmNew != hBmpSrc)
mustFree = true;
return(hbmNew);
diff --git a/plugins/TipperYM/src/bitmap_func.cpp b/plugins/TipperYM/src/bitmap_func.cpp
index 1ec2a3696a..d2f7f561b5 100644
--- a/plugins/TipperYM/src/bitmap_func.cpp
+++ b/plugins/TipperYM/src/bitmap_func.cpp
@@ -154,7 +154,7 @@ void CreateFromBitmaps(bool bServiceTip)
if (tszFileName && *tszFileName != 0) {
FIBITMAP *fib = nullptr;
if (!skin.bCached) {
- FIBITMAP *fibLoad = (FIBITMAP *)CallService(MS_IMG_LOAD, (WPARAM)tszFileName, IMGL_WCHAR | IMGL_RETURNDIB);
+ FIBITMAP *fibLoad = (FIBITMAP *)Image_Load(tszFileName, IMGL_WCHAR | IMGL_RETURNDIB);
if (!fibLoad) continue;
if (FreeImage_GetBPP(fibLoad) != 32)
diff --git a/plugins/TipperYM/src/options.cpp b/plugins/TipperYM/src/options.cpp
index 17b3d0b310..15489d189c 100644
--- a/plugins/TipperYM/src/options.cpp
+++ b/plugins/TipperYM/src/options.cpp
@@ -1723,13 +1723,7 @@ INT_PTR CALLBACK DlgProcOptsSkin(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
int iWidth = dis->rcItem.right - dis->rcItem.left;
int iHeight = dis->rcItem.bottom - dis->rcItem.top;
- ResizeBitmap rb = { 0 };
- rb.size = sizeof(rb);
- rb.hBmp = hbmpPreview;
- rb.max_width = iWidth;
- rb.max_height = iHeight;
- rb.fit = RESIZEBITMAP_KEEP_PROPORTIONS;
- HBITMAP hbmpRes = (HBITMAP)CallService(MS_IMG_RESIZE, (WPARAM)&rb, 0);
+ HBITMAP hbmpRes = Image_Resize(hbmpPreview, RESIZEBITMAP_KEEP_PROPORTIONS, iWidth, iHeight);
if (hbmpRes) {
BITMAP bmp;
GetObject(hbmpRes, sizeof(bmp), &bmp);
diff --git a/plugins/TipperYM/src/popwin.cpp b/plugins/TipperYM/src/popwin.cpp
index 0a5b82200e..7c97954284 100644
--- a/plugins/TipperYM/src/popwin.cpp
+++ b/plugins/TipperYM/src/popwin.cpp
@@ -498,14 +498,7 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
ace = (AVATARCACHEENTRY *)CallService(MS_AV_GETMYAVATAR, 0, (LPARAM)pwd->clcit.szProto);
if (ace && ace->hbmPic && (ace->dwFlags & AVS_BITMAP_VALID) && !(ace->dwFlags & AVS_HIDEONCLIST)) {
- ResizeBitmap rb = { 0 };
- rb.size = sizeof(rb);
- rb.max_width = pwd->iRealAvatarWidth;
- rb.max_height = pwd->iRealAvatarHeight;
- rb.fit = RESIZEBITMAP_STRETCH | RESIZEBITMAP_KEEP_PROPORTIONS;
- rb.hBmp = ace->hbmPic;
- HBITMAP hbmpAvatar = (HBITMAP)CallService(MS_IMG_RESIZE, (WPARAM)&rb, 0);
-
+ HBITMAP hbmpAvatar = Image_Resize(ace->hbmPic, RESIZEBITMAP_STRETCH | RESIZEBITMAP_KEEP_PROPORTIONS, pwd->iRealAvatarWidth, pwd->iRealAvatarHeight);
if (hbmpAvatar) {
HRGN hrgnAvatar = nullptr;
if (opt.bAvatarRound) {
diff --git a/plugins/Toaster/src/utils.h b/plugins/Toaster/src/utils.h
index 2aa4802b8c..524a96730e 100644
--- a/plugins/Toaster/src/utils.h
+++ b/plugins/Toaster/src/utils.h
@@ -14,22 +14,19 @@ public:
__inline explicit ToasterImage(HICON hIcon) : _hBitmap(NULL), tszId(CMStringW(FORMAT, L"%p", hIcon).Detach())
{
ICONINFO icon = { 0 };
- if (GetIconInfo(hIcon, &icon))
- {
+ if (GetIconInfo(hIcon, &icon)) {
_hBitmap = icon.hbmColor;
DeleteObject(icon.hbmMask);
}
}
__inline explicit ToasterImage(HBITMAP bmp) : _hBitmap(bmp), tszId(CMStringW(FORMAT, L"%p", bmp).Detach())
- {
- }
+ {}
__inline explicit ToasterImage(const char *szProto) : _hBitmap(NULL), tszId(mir_a2u(szProto))
{
ICONINFO icon = { 0 };
- if (GetIconInfo(Skin_LoadProtoIcon(szProto, ID_STATUS_ONLINE, 1), &icon))
- {
+ if (GetIconInfo(Skin_LoadProtoIcon(szProto, ID_STATUS_ONLINE, 1), &icon)) {
_hBitmap = icon.hbmColor;
DeleteObject(icon.hbmMask);
}
@@ -45,26 +42,19 @@ public:
wchar_t wszSavePath[MAX_PATH];
mir_snwprintf(wszSavePath, L"%s\\MirandaToaster.%s.png", wszTempDir, tszId);
- if (!(GetFileAttributes(wszSavePath) < 0xFFFFFFF))
- {
+ if (!(GetFileAttributes(wszSavePath) < 0xFFFFFFF)) {
IMGSRVC_INFO isi = { sizeof(isi) };
- isi.wszName = mir_wstrdup(wszSavePath);
+ isi.szName.w = wszSavePath;
isi.hbm = _hBitmap;
isi.dwMask = IMGI_HBITMAP;
isi.fif = FREE_IMAGE_FORMAT::FIF_PNG;
- __try
- {
- CallService(MS_IMG_SAVE, (WPARAM)&isi, IMGL_WCHAR);
- }
- __except (EXCEPTION_EXECUTE_HANDLER)
- {
- return nullptr;
- }
+ Image_Save(&isi, IMGL_WCHAR);
}
return mir_wstrdup(wszSavePath);
}
__inline operator wchar_t*()
- { return Save();
+ {
+ return Save();
}
-}; \ No newline at end of file
+};
diff --git a/plugins/Utils.pas/mirutils.pas b/plugins/Utils.pas/mirutils.pas
index f6ffad2c6a..47f28ea776 100644
--- a/plugins/Utils.pas/mirutils.pas
+++ b/plugins/Utils.pas/mirutils.pas
@@ -590,7 +590,6 @@ var
req :TNETLIBHTTPREQUEST;
resp:PNETLIBHTTPREQUEST;
hNetLib:THANDLE;
- im:TIMGSRVC_MEMIO;
begin
result:=0;
if (url=nil) or (url^=#0) then
@@ -611,15 +610,8 @@ begin
if resp<>nil then
begin
if resp^.resultCode=200 then
- begin
- im.iLen :=resp.dataLength;
- im.pBuf :=resp.pData;
- im.flags:=size shl 16;
- im.fif :=FIF_JPEG;
- result :=CallService(MS_IMG_LOADFROMMEM,wparam(@im),0);
-// if result<>0 then
-// DeleteObject(SendMessage(wnd,STM_SETIMAGE,IMAGE_BITMAP,result)); //!!
- end;
+ result := Image_LoadFromMem(resp.pData, resp.dataLength, FIF_JPEG);
+
Netlib_FreeHttpRequest(resp);
end;
Netlib_CloseHandle(hNetLib);
diff --git a/plugins/Watrack/popup/pop_vars.inc b/plugins/Watrack/popup/pop_vars.inc
index 61e7edb9f7..4c192af720 100644
--- a/plugins/Watrack/popup/pop_vars.inc
+++ b/plugins/Watrack/popup/pop_vars.inc
@@ -16,7 +16,6 @@ var
DisablePlugin:integer;
IsPopup2Present:boolean;
- IsFreeImagePresent:boolean;
var
hMenuInfo :THANDLE;
ssmi,
diff --git a/plugins/Watrack/popup/popups.pas b/plugins/Watrack/popup/popups.pas
index 8e7782de69..f7b4b98da5 100644
--- a/plugins/Watrack/popup/popups.pas
+++ b/plugins/Watrack/popup/popups.pas
@@ -212,10 +212,7 @@ begin
if si.cover<>nil then
begin
- if IsFreeImagePresent then
- hbmAvatar:=CallService(MS_IMG_LOAD,wparam(si.cover),IMGL_WCHAR)
- else
- hbmAvatar:=0;
+ hbmAvatar:=Image_Load(si.cover, IMGL_WCHAR);
if hbmAvatar=0 then
begin
hbmAvatar:=CallService(MS_UTILS_LOADBITMAPW,0,lparam(si.cover));
@@ -397,7 +394,6 @@ begin
PopupPresent:=newstate;
if PopupPresent then
begin
- IsFreeImagePresent:=ServiceExists(MS_IMG_LOAD);
IsPopup2Present :=ServiceExists(MS_POPUP_ADDPOPUP2);
opthook:=HookEvent(ME_OPT_INITIALISE,@OnOptInitialise);
@@ -481,8 +477,7 @@ begin
ActionList:=nil;
if ServiceExists(MS_POPUP_ADDPOPUPW) then
begin
- IsFreeImagePresent:=ServiceExists(MS_IMG_LOAD);
- IsPopup2Present :=ServiceExists(MS_POPUP_ADDPOPUP2);
+ IsPopup2Present := ServiceExists(MS_POPUP_ADDPOPUP2);
PopupPresent:=true;
opthook:=HookEvent(ME_OPT_INITIALISE,@OnOptInitialise);
loadpopup;
diff --git a/protocols/FacebookRM/src/captcha.cpp b/protocols/FacebookRM/src/captcha.cpp
index bcd952fccc..96f13447d5 100644
--- a/protocols/FacebookRM/src/captcha.cpp
+++ b/protocols/FacebookRM/src/captcha.cpp
@@ -120,12 +120,7 @@ bool FacebookProto::RunCaptchaForm(std::string captchaUrl, std::string &result)
}
CAPTCHA_FORM_PARAMS param = {};
-
- IMGSRVC_MEMIO memio = { 0 };
- memio.iLen = reply->dataLength;
- memio.pBuf = reply->pData;
- memio.fif = FIF_UNKNOWN; /* detect */
- param.bmp = (HBITMAP)CallService(MS_IMG_LOADFROMMEM, (WPARAM)&memio);
+ param.bmp = Image_LoadFromMem(reply->pData, reply->dataLength, FIF_UNKNOWN);
BITMAP bmp = { 0 };
GetObject(param.bmp, sizeof(bmp), &bmp);
diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp
index cbf9715466..29ca4dd2da 100644
--- a/protocols/FacebookRM/src/json.cpp
+++ b/protocols/FacebookRM/src/json.cpp
@@ -525,19 +525,14 @@ const char* FacebookProto::ParseIcon(const std::string &url)
NETLIBHTTPREQUEST *reply = Netlib_HttpTransaction(facy.handle_, &req);
if (reply != nullptr && reply->resultCode == HTTP_CODE_OK) {
- IMGSRVC_MEMIO memio = { 0 };
- memio.iLen = reply->dataLength;
- memio.pBuf = reply->pData;
- memio.fif = FIF_UNKNOWN; /* detect */
-
- HBITMAP hBmp = (HBITMAP)CallService(MS_IMG_LOADFROMMEM, (WPARAM)&memio);
+ HBITMAP hBmp = Image_LoadFromMem(reply->pData, reply->dataLength, FIF_UNKNOWN);
if (hBmp != nullptr) {
IMGSRVC_INFO info = { sizeof(info) };
- info.wszName = wszFileName;
+ info.szName.w = wszFileName;
info.fif = FIF_ICO;
info.dwMask = IMGI_HBITMAP;
info.hbm = hBmp;
- CallService(MS_IMG_SAVE, (WPARAM)&info, IMGL_WCHAR);
+ Image_Save(&info, IMGL_WCHAR);
}
}
}
diff --git a/protocols/Gadu-Gadu/src/image.cpp b/protocols/Gadu-Gadu/src/image.cpp
index 23c485b2ad..38540c4620 100644
--- a/protocols/Gadu-Gadu/src/image.cpp
+++ b/protocols/Gadu-Gadu/src/image.cpp
@@ -1054,19 +1054,10 @@ void* GaduProto::img_loadpicture(gg_event* e, wchar_t *szFileName)
////////////////////////////////////////////////////////////////////
// Loading picture using Miranda Image services
- // Load image from memory
- if (!szFileName)
- {
- IMGSRVC_MEMIO memio;
- memio.iLen = dat->nSize;
- memio.pBuf = (void *)dat->lpData;
- memio.fif = FIF_UNKNOWN; /* detect */
- memio.flags = 0;
- dat->hBitmap = (HBITMAP)CallService(MS_IMG_LOADFROMMEM, (WPARAM)&memio, 0);
- }
- // Load image from file
+ if (!szFileName) // Load image from memory
+ dat->hBitmap = Image_LoadFromMem(dat->lpData, dat->nSize, FIF_UNKNOWN);
else
- dat->hBitmap = Bitmap_Load(szFileName);
+ dat->hBitmap = Bitmap_Load(szFileName); // Load image from file
// If everything is fine return the handle
if (dat->hBitmap)
diff --git a/protocols/Gadu-Gadu/src/token.cpp b/protocols/Gadu-Gadu/src/token.cpp
index d38435afa2..ebb9535726 100644
--- a/protocols/Gadu-Gadu/src/token.cpp
+++ b/protocols/Gadu-Gadu/src/token.cpp
@@ -137,14 +137,8 @@ int GaduProto::gettoken(GGTOKEN *token)
dat.height = t->height;
// Load bitmap
- IMGSRVC_MEMIO memio = { 0 };
- memio.iLen = h->body_size;
- memio.pBuf = h->body;
- memio.fif = FIF_UNKNOWN; /* detect */
- memio.flags = 0;
- dat.hBitmap = (HBITMAP)CallService(MS_IMG_LOADFROMMEM, (WPARAM)&memio, 0);
- if (dat.hBitmap == nullptr)
- {
+ dat.hBitmap = Image_LoadFromMem(h->body, h->body_size, FIF_UNKNOWN);
+ if (dat.hBitmap == nullptr) {
MessageBox(nullptr, TranslateT("Could not load token image."), m_tszUserName, MB_OK | MB_ICONSTOP);
gg_free_pubdir(h);
return FALSE;
diff --git a/protocols/JabberG/src/jabber_captcha.cpp b/protocols/JabberG/src/jabber_captcha.cpp
index c48aea4c00..f4ea12630f 100644
--- a/protocols/JabberG/src/jabber_captcha.cpp
+++ b/protocols/JabberG/src/jabber_captcha.cpp
@@ -146,12 +146,7 @@ bool CJabberProto::ProcessCaptcha(HXML node, HXML parentNode, ThreadData *info)
if (buffer == nullptr)
return false;
- IMGSRVC_MEMIO memio;
- memio.iLen = (long)bufferLen;
- memio.pBuf = (void *)buffer;
- memio.fif = FIF_UNKNOWN; /* detect */
- memio.flags = 0;
- param.bmp = (HBITMAP)CallService(MS_IMG_LOADFROMMEM, (WPARAM)&memio, 0);
+ param.bmp = Image_LoadFromMem(buffer, bufferLen, FIF_UNKNOWN);
BITMAP bmp = {0};
GetObject(param.bmp, sizeof(bmp), &bmp);
diff --git a/protocols/VKontakte/src/vk_captcha.cpp b/protocols/VKontakte/src/vk_captcha.cpp
index e06be3d052..72b8809e94 100644
--- a/protocols/VKontakte/src/vk_captcha.cpp
+++ b/protocols/VKontakte/src/vk_captcha.cpp
@@ -47,11 +47,7 @@ bool CVkProto::RunCaptchaForm(LPCSTR szUrl, CMStringA &result)
return false;
}
- IMGSRVC_MEMIO memio = { 0 };
- memio.iLen = reply->dataLength;
- memio.pBuf = reply->pData;
- memio.fif = FIF_UNKNOWN; /* detect */
- param.bmp = (HBITMAP)CallService(MS_IMG_LOADFROMMEM, (WPARAM)&memio);
+ param.bmp = Image_LoadFromMem(reply->pData, reply->dataLength, FIF_UNKNOWN);
BITMAP bmp = { 0 };
GetObject(param.bmp, sizeof(bmp), &bmp);
diff --git a/src/mir_app/src/image_utils.cpp b/src/mir_app/src/image_utils.cpp
index 0fbafb14e8..ee4bbcf870 100644
--- a/src/mir_app/src/image_utils.cpp
+++ b/src/mir_app/src/image_utils.cpp
@@ -34,24 +34,22 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// lParam = NULL
// return NULL on error, ResizeBitmap->hBmp if don't need to resize or a new HBITMAP if resized
-static INT_PTR serviceBmpFilterResizeBitmap(WPARAM wParam, LPARAM)
+MIR_APP_DLL(HBITMAP) Image_Resize(HBITMAP hBmp, int fit /* RESIZEBITMAP_*/, int max_width, int max_height)
{
- ResizeBitmap *info = (ResizeBitmap *)wParam;
- if (info == nullptr || info->size != sizeof(ResizeBitmap)
- || info->hBmp == nullptr
- || info->max_width < 0 || info->max_height < 0
- || (info->fit & ~RESIZEBITMAP_FLAG_DONT_GROW) < RESIZEBITMAP_STRETCH
- || (info->fit & ~RESIZEBITMAP_FLAG_DONT_GROW) > RESIZEBITMAP_MAKE_SQUARE)
+ if (hBmp == nullptr
+ || max_width < 0 || max_height < 0
+ || (fit & ~RESIZEBITMAP_FLAG_DONT_GROW) < RESIZEBITMAP_STRETCH
+ || (fit & ~RESIZEBITMAP_FLAG_DONT_GROW) > RESIZEBITMAP_MAKE_SQUARE)
return 0;
// Well, lets do it
// Calc final size
BITMAP bminfo;
- GetObject(info->hBmp, sizeof(bminfo), &bminfo);
+ GetObject(hBmp, sizeof(bminfo), &bminfo);
- int width = info->max_width == 0 ? bminfo.bmWidth : info->max_width;
- int height = info->max_height == 0 ? bminfo.bmHeight : info->max_height;
+ int width = max_width == 0 ? bminfo.bmWidth : max_width;
+ int height = max_height == 0 ? bminfo.bmHeight : max_height;
int xOrig = 0;
int yOrig = 0;
@@ -61,26 +59,26 @@ static INT_PTR serviceBmpFilterResizeBitmap(WPARAM wParam, LPARAM)
if (widthOrig == 0 || heightOrig == 0)
return 0;
- switch (info->fit & ~RESIZEBITMAP_FLAG_DONT_GROW) {
+ switch (fit & ~RESIZEBITMAP_FLAG_DONT_GROW) {
case RESIZEBITMAP_STRETCH:
// Do nothing
break;
case RESIZEBITMAP_KEEP_PROPORTIONS:
if (height * widthOrig / heightOrig <= width) {
- if (info->fit & RESIZEBITMAP_FLAG_DONT_GROW)
+ if (fit & RESIZEBITMAP_FLAG_DONT_GROW)
height = min(height, bminfo.bmHeight);
width = height * widthOrig / heightOrig;
}
else {
- if (info->fit & RESIZEBITMAP_FLAG_DONT_GROW)
+ if (fit & RESIZEBITMAP_FLAG_DONT_GROW)
width = min(width, bminfo.bmWidth);
height = width * heightOrig / widthOrig;
}
break;
case RESIZEBITMAP_MAKE_SQUARE:
- if (info->fit & RESIZEBITMAP_FLAG_DONT_GROW) {
+ if (fit & RESIZEBITMAP_FLAG_DONT_GROW) {
width = min(width, bminfo.bmWidth);
height = min(height, bminfo.bmHeight);
}
@@ -101,12 +99,12 @@ static INT_PTR serviceBmpFilterResizeBitmap(WPARAM wParam, LPARAM)
}
if ((width == bminfo.bmWidth && height == bminfo.bmHeight) ||
- ((info->fit & RESIZEBITMAP_FLAG_DONT_GROW) && !(info->fit & RESIZEBITMAP_MAKE_SQUARE) && width > bminfo.bmWidth && height > bminfo.bmHeight)) {
+ ((fit & RESIZEBITMAP_FLAG_DONT_GROW) && !(fit & RESIZEBITMAP_MAKE_SQUARE) && width > bminfo.bmWidth && height > bminfo.bmHeight)) {
// Do nothing
- return (INT_PTR)info->hBmp;
+ return hBmp;
}
- FIBITMAP *dib = FreeImage_CreateDIBFromHBITMAP(info->hBmp);
+ FIBITMAP *dib = FreeImage_CreateDIBFromHBITMAP(hBmp);
if (dib == nullptr)
return 0;
@@ -130,79 +128,81 @@ static INT_PTR serviceBmpFilterResizeBitmap(WPARAM wParam, LPARAM)
FreeImage_Unload(dib_tmp);
FreeImage_Unload(dib);
- return (INT_PTR)bitmap_new;
+ return bitmap_new;
}
///////////////////////////////////////////////////////////////////////////////
-// Load - initializes the plugin instance
+// Image_Load - initializes the plugin instance
-static INT_PTR serviceLoad(WPARAM wParam, LPARAM lParam)
+MIR_APP_DLL(HBITMAP) Image_Load(const wchar_t *pwszPath, int iFlags)
{
- char *lpszFilename = (char *)wParam;
- if (lpszFilename == nullptr)
+ if (pwszPath == nullptr)
return 0;
FREE_IMAGE_FORMAT fif = FIF_UNKNOWN;
- if (lParam & IMGL_WCHAR)
- fif = FreeImage_GetFileTypeU((wchar_t *)lpszFilename, 0);
+ if (iFlags & IMGL_WCHAR)
+ fif = FreeImage_GetFileTypeU(pwszPath, 0);
else
- fif = FreeImage_GetFileType(lpszFilename, 0);
+ fif = FreeImage_GetFileType((char*)pwszPath, 0);
if (fif == FIF_UNKNOWN) {
- if (lParam & IMGL_WCHAR)
- fif = FreeImage_GetFIFFromFilenameU((wchar_t *)lpszFilename);
+ if (iFlags & IMGL_WCHAR)
+ fif = FreeImage_GetFIFFromFilenameU(pwszPath);
else
- fif = FreeImage_GetFIFFromFilename(lpszFilename);
+ fif = FreeImage_GetFIFFromFilename((char*)pwszPath);
}
+
// check that the plugin has reading capabilities ...
-
- if ((fif != FIF_UNKNOWN) && FreeImage_FIFSupportsReading(fif)) {
+ if (fif != FIF_UNKNOWN && FreeImage_FIFSupportsReading(fif)) {
// ok, let's load the file
FIBITMAP *dib;
- if (lParam & IMGL_WCHAR)
- dib = FreeImage_LoadU(fif, (wchar_t *)lpszFilename, 0);
+ if (iFlags & IMGL_WCHAR)
+ dib = FreeImage_LoadU(fif, pwszPath, 0);
else
- dib = FreeImage_Load(fif, lpszFilename, 0);
+ dib = FreeImage_Load(fif, (char*)pwszPath, 0);
- if (dib == nullptr || (lParam & IMGL_RETURNDIB))
- return (INT_PTR)dib;
+ if (dib == nullptr || (iFlags & IMGL_RETURNDIB))
+ return HBITMAP(dib);
HBITMAP hbm = FreeImage_CreateHBITMAPFromDIB(dib);
FreeImage_Unload(dib);
FreeImage_CorrectBitmap32Alpha(hbm, FALSE);
- return (INT_PTR)hbm;
+ return hbm;
}
- return NULL;
+ return nullptr;
}
-static INT_PTR serviceLoadFromMem(WPARAM wParam, LPARAM lParam)
+/////////////////////////////////////////////////////////////////////////////////////////
+// Image_LoadFromMem - loads an image from memory
+
+MIR_APP_DLL(HBITMAP) Image_LoadFromMem(const void *pBuf, size_t cbLen, FREE_IMAGE_FORMAT fif)
{
- IMGSRVC_MEMIO *mio = (IMGSRVC_MEMIO *)wParam;
- if (mio->iLen == 0 || mio->pBuf == nullptr)
+ if (cbLen == 0 || pBuf == nullptr)
return 0;
- FIMEMORY *hmem = FreeImage_OpenMemory((BYTE *)mio->pBuf, mio->iLen);
- FREE_IMAGE_FORMAT fif = (mio->fif != FIF_UNKNOWN) ? mio->fif : mio->fif = FreeImage_GetFileTypeFromMemory(hmem, 0);
- FIBITMAP *dib = FreeImage_LoadFromMemory(fif, hmem, mio->flags);
- FreeImage_CloseMemory(hmem);
+ FIMEMORY *hmem = FreeImage_OpenMemory((BYTE *)pBuf, (DWORD)cbLen);
+ if (fif == FIF_UNKNOWN)
+ fif = FreeImage_GetFileTypeFromMemory(hmem, 0);
- if (dib == nullptr || (lParam & IMGL_RETURNDIB))
- return (INT_PTR)dib;
+ FIBITMAP *dib = FreeImage_LoadFromMemory(fif, hmem, 0);
+ FreeImage_CloseMemory(hmem);
+ if (dib == nullptr)
+ return nullptr;
HBITMAP hbm = FreeImage_CreateHBITMAPFromDIB(dib);
-
FreeImage_Unload(dib);
- return (INT_PTR)hbm;
+ return hbm;
}
-static INT_PTR serviceSave(WPARAM wParam, LPARAM lParam)
+/////////////////////////////////////////////////////////////////////////////////////////
+
+MIR_APP_DLL(int) Image_Save(const IMGSRVC_INFO *isi, int iFlags)
{
- IMGSRVC_INFO *isi = (IMGSRVC_INFO*)wParam;
if (isi == nullptr)
return 0;
if (isi->cbSize != sizeof(IMGSRVC_INFO))
return 0;
- if (isi->szName == nullptr)
+ if (isi->szName.a == nullptr)
return 0;
FREE_IMAGE_FORMAT fif;
@@ -210,10 +210,10 @@ static INT_PTR serviceSave(WPARAM wParam, LPARAM lParam)
FIBITMAP *dib = nullptr;
if (isi->fif == FIF_UNKNOWN) {
- if (lParam & IMGL_WCHAR)
- fif = FreeImage_GetFIFFromFilenameU(isi->wszName);
+ if (iFlags & IMGL_WCHAR)
+ fif = FreeImage_GetFIFFromFilenameU(isi->szName.w);
else
- fif = FreeImage_GetFIFFromFilename(isi->szName);
+ fif = FreeImage_GetFIFFromFilename(isi->szName.a);
}
else
fif = isi->fif;
@@ -233,21 +233,21 @@ static INT_PTR serviceSave(WPARAM wParam, LPARAM lParam)
if (dib == nullptr)
return 0;
- int flags = HIWORD(lParam);
+ int flags = HIWORD(iFlags);
int ret = 0;
if (fif == FIF_PNG || fif == FIF_BMP || fif == FIF_JNG) {
- if (lParam & IMGL_WCHAR)
- ret = FreeImage_SaveU(fif, dib, isi->wszName, flags);
+ if (iFlags & IMGL_WCHAR)
+ ret = FreeImage_SaveU(fif, dib, isi->szName.w, flags);
else
- ret = FreeImage_Save(fif, dib, isi->szName, flags);
+ ret = FreeImage_Save(fif, dib, isi->szName.a, flags);
}
else {
FIBITMAP *dib_new = FreeImage_ConvertTo24Bits(dib);
- if (lParam & IMGL_WCHAR)
- ret = FreeImage_SaveU(fif, dib_new, isi->wszName, flags);
+ if (iFlags & IMGL_WCHAR)
+ ret = FreeImage_SaveU(fif, dib_new, isi->szName.w, flags);
else
- ret = FreeImage_Save(fif, dib_new, isi->szName, flags);
+ ret = FreeImage_Save(fif, dib_new, isi->szName.a, flags);
FreeImage_Unload(dib_new);
}
@@ -255,11 +255,3 @@ static INT_PTR serviceSave(WPARAM wParam, LPARAM lParam)
FreeImage_Unload(dib);
return ret;
}
-
-void LoadImageUtils(void)
-{
- CreateServiceFunction(MS_IMG_LOAD, serviceLoad);
- CreateServiceFunction(MS_IMG_LOADFROMMEM, serviceLoadFromMem);
- CreateServiceFunction(MS_IMG_SAVE, serviceSave);
- CreateServiceFunction(MS_IMG_RESIZE, serviceBmpFilterResizeBitmap);
-}
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def
index 4bcd151b11..11289c7a7e 100644
--- a/src/mir_app/src/mir_app.def
+++ b/src/mir_app/src/mir_app.def
@@ -483,3 +483,7 @@ Contact_AddBySearch @499
??0PROTO_INTERFACE@@QAE@PBDPB_W@Z @501 NONAME
??1PROTO_INTERFACE@@QAE@XZ @502 NONAME
Proto_AuthRecv @503
+Image_Load @504
+Image_LoadFromMem @505
+Image_Resize @506
+Image_Save @507
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def
index 9939debfff..d6c4787c57 100644
--- a/src/mir_app/src/mir_app64.def
+++ b/src/mir_app/src/mir_app64.def
@@ -483,3 +483,7 @@ Contact_AddBySearch @499
??0PROTO_INTERFACE@@QEAA@PEBDPEB_W@Z @501 NONAME
??1PROTO_INTERFACE@@QEAA@XZ @502 NONAME
Proto_AuthRecv @503
+Image_Load @504
+Image_LoadFromMem @505
+Image_Resize @506
+Image_Save @507
diff --git a/src/mir_app/src/utils.cpp b/src/mir_app/src/utils.cpp
index 4125dd921f..170c7db7c2 100644
--- a/src/mir_app/src/utils.cpp
+++ b/src/mir_app/src/utils.cpp
@@ -317,8 +317,6 @@ static INT_PTR GetCountryList(WPARAM wParam, LPARAM lParam)
/////////////////////////////////////////////////////////////////////////////////////////
-void LoadImageUtils(void);
-
int LoadUtilsModule(void)
{
bModuleInitialized = TRUE;
@@ -330,7 +328,6 @@ int LoadUtilsModule(void)
CreateServiceFunction(MS_UTILS_ENTERSTRING, svcEnterString);
InitCrypt();
- LoadImageUtils();
return 0;
}
diff --git a/src/mir_core/src/bitmaps.cpp b/src/mir_core/src/bitmaps.cpp
index 6edffb9510..6fca273d5c 100644
--- a/src/mir_core/src/bitmaps.cpp
+++ b/src/mir_core/src/bitmaps.cpp
@@ -31,10 +31,7 @@ MIR_CORE_DLL(HBITMAP) Bitmap_Load(const wchar_t *ptszFileName)
if (!PathToAbsoluteW(ptszFileName, szFilename))
wcsncpy_s(szFilename, ptszFileName, _TRUNCATE);
- if (!ServiceExists(MS_IMG_LOAD))
- return nullptr;
-
- return (HBITMAP)CallService(MS_IMG_LOAD, (WPARAM)szFilename, IMGL_WCHAR);
+ return Image_Load(szFilename, IMGL_WCHAR);
}
MIR_CORE_DLL(void) Bitmap_GetFilter(wchar_t *dest, size_t destLen)