WIN platform: implement Fl_GDI_Graphics_Driver::draw_scaled(Fl_Image *img,int,int,int,int) when img is a Fl_RGB_Image
Implementation uses StretchBlt() when img->d() is 1 or 3 and AlphaBlend() when it is 2 or 4. This should turn useful to draw images on HighDPI displays using the display's true resolution. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@12053 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
52479a5ef1
commit
bbfd919773
@ -35,6 +35,8 @@
|
||||
This class is implemented only on the MSWindows platform.
|
||||
*/
|
||||
class FL_EXPORT Fl_GDI_Graphics_Driver : public Fl_Graphics_Driver {
|
||||
private:
|
||||
BOOL alpha_blend_(int x, int y, int w, int h, HDC src_gc, int srcx, int srcy, int srcw, int srch);
|
||||
protected:
|
||||
HDC gc_;
|
||||
int numcount;
|
||||
@ -62,6 +64,7 @@ public:
|
||||
void draw(Fl_Pixmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy);
|
||||
void draw(Fl_Bitmap *pxm, int XP, int YP, int WP, int HP, int cx, int cy);
|
||||
void draw(Fl_RGB_Image *img, int XP, int YP, int WP, int HP, int cx, int cy);
|
||||
int draw_scaled(Fl_Image *img, int XP, int YP, int WP, int HP);
|
||||
void draw_image(const uchar* buf, int X,int Y,int W,int H, int D=3, int L=0);
|
||||
void draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D=3);
|
||||
void draw_image_mono(const uchar* buf, int X,int Y,int W,int H, int D=1, int L=0);
|
||||
|
@ -113,6 +113,10 @@ void Fl_GDI_Graphics_Driver::copy_offscreen(int x,int y,int w,int h,HBITMAP bitm
|
||||
DeleteDC(new_gc);
|
||||
}
|
||||
|
||||
BOOL Fl_GDI_Graphics_Driver::alpha_blend_(int x, int y, int w, int h, HDC src_gc, int srcx, int srcy, int srcw, int srch) {
|
||||
return fl_alpha_blend(gc_, x, y, w, h, src_gc, srcx, srcy, srcw, srch, blendfunc);
|
||||
}
|
||||
|
||||
#if ! defined(FL_DOXYGEN)
|
||||
void Fl_GDI_Graphics_Driver::copy_offscreen_with_alpha(int x,int y,int w,int h,HBITMAP bitmap,int srcx,int srcy) {
|
||||
HDC new_gc = CreateCompatibleDC(gc_);
|
||||
@ -121,7 +125,7 @@ void Fl_GDI_Graphics_Driver::copy_offscreen_with_alpha(int x,int y,int w,int h,H
|
||||
BOOL alpha_ok = 0;
|
||||
// first try to alpha blend
|
||||
if ( can_do_alpha_blending() ) {
|
||||
alpha_ok = fl_alpha_blend(gc_, x, y, w, h, new_gc, srcx, srcy, w, h, blendfunc);
|
||||
alpha_ok = alpha_blend_(x, y, w, h, new_gc, srcx, srcy, w, h);
|
||||
}
|
||||
// if that failed (it shouldn't), still copy the bitmap over, but now alpha is 1
|
||||
if (!alpha_ok) {
|
||||
|
@ -541,6 +541,25 @@ int Fl_GDI_Printer_Graphics_Driver::draw_scaled(Fl_Image *img, int XP, int YP, i
|
||||
return 1;
|
||||
}
|
||||
|
||||
int Fl_GDI_Graphics_Driver::draw_scaled(Fl_Image *img, int XP, int YP, int WP, int HP) {
|
||||
if (img->d() == 0 || img->count() >= 2) return 0; // for bitmaps and pixmaps
|
||||
|
||||
Fl_RGB_Image *rgb = (Fl_RGB_Image*)img;
|
||||
if (!rgb->id_) rgb->id_ = (fl_uintptr_t)build_id(rgb, (void**)&(rgb->mask_));
|
||||
HDC new_gc = CreateCompatibleDC(gc_);
|
||||
int save = SaveDC(new_gc);
|
||||
SelectObject(new_gc, (HBITMAP)rgb->id_);
|
||||
if ((img->d() % 2) == 0 & can_do_alpha_blending()) {
|
||||
alpha_blend_(XP, YP, WP, HP, new_gc, 0, 0, rgb->w(), rgb->h());
|
||||
} else {
|
||||
SetStretchBltMode(gc_, HALFTONE);
|
||||
StretchBlt(gc_, XP, YP, WP, HP, new_gc, 0, 0, rgb->w(), rgb->h(), SRCCOPY);
|
||||
}
|
||||
RestoreDC(new_gc, save);
|
||||
DeleteDC(new_gc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void Fl_GDI_Graphics_Driver::uncache(Fl_RGB_Image*, fl_uintptr_t &id_, fl_uintptr_t &mask_)
|
||||
{
|
||||
if (id_) {
|
||||
|
Loading…
Reference in New Issue
Block a user