De-duplicate code to load pointer to the TransparentBlt() system function at run-time.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12234 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Manolo Gouy 2017-05-06 07:36:40 +00:00
parent 0794cc0ceb
commit 39b2976f88
2 changed files with 13 additions and 15 deletions

View File

@ -157,6 +157,9 @@ protected:
This class is implemented only on the MSWindows platform. It 's extremely similar to Fl_GDI_Graphics_Driver.
*/
class FL_EXPORT Fl_GDI_Printer_Graphics_Driver : public Fl_GDI_Graphics_Driver {
private:
typedef BOOL (WINAPI* transparent_f_type) (HDC,int,int,int,int,HDC,int,int,int,int,UINT);
transparent_f_type TransparentBlt();
public:
virtual int has_feature(driver_feature mask) { return mask & (NATIVE | PRINTER); }
void draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy);

View File

@ -415,16 +415,17 @@ void Fl_GDI_Graphics_Driver::draw(Fl_Bitmap *bm, int XP, int YP, int WP, int HP,
DeleteDC(tempdc);
}
// TODO: move this into a file with the printer implementations
Fl_GDI_Printer_Graphics_Driver::transparent_f_type Fl_GDI_Printer_Graphics_Driver::TransparentBlt() {
HMODULE hMod;
static transparent_f_type fpter = ( (hMod = LoadLibrary("MSIMG32.DLL")) ?
(transparent_f_type)GetProcAddress(hMod, "TransparentBlt") : NULL
);
return fpter;
}
void Fl_GDI_Printer_Graphics_Driver::draw(Fl_Bitmap *bm, int XP, int YP, int WP, int HP, int cx, int cy) {
int X, Y, W, H;
typedef BOOL (WINAPI* fl_transp_func) (HDC,int,int,int,int,HDC,int,int,int,int,UINT);
static fl_transp_func fl_TransparentBlt = NULL;
static HMODULE hMod = NULL;
if (!hMod) {
hMod = LoadLibrary("MSIMG32.DLL");
if (hMod) fl_TransparentBlt = (fl_transp_func)GetProcAddress(hMod, "TransparentBlt");
}
transparent_f_type fl_TransparentBlt = TransparentBlt();
if (!fl_TransparentBlt) {
Fl_GDI_Graphics_Driver::draw(bm, XP, YP, WP, HP, cx, cy);
return;
@ -611,13 +612,7 @@ void Fl_GDI_Graphics_Driver::draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP
void Fl_GDI_Printer_Graphics_Driver::draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy) {
int X, Y, W, H;
if (Fl_Graphics_Driver::prepare(pxm, XP, YP, WP, HP, cx, cy, X, Y, W, H)) return;
typedef BOOL (WINAPI* fl_transp_func) (HDC,int,int,int,int,HDC,int,int,int,int,UINT);
static HMODULE hMod = NULL;
static fl_transp_func fl_TransparentBlt = NULL;
if (!hMod) {
hMod = LoadLibrary("MSIMG32.DLL");
if(hMod) fl_TransparentBlt = (fl_transp_func)GetProcAddress(hMod, "TransparentBlt");
}
transparent_f_type fl_TransparentBlt = TransparentBlt();
if (fl_TransparentBlt) {
HDC new_gc = CreateCompatibleDC(gc_);
int save = SaveDC(new_gc);