diff --git a/uppsrc/CtrlCore/ImageWin32.cpp b/uppsrc/CtrlCore/ImageWin32.cpp index feb4c3dfd..21505a75d 100644 --- a/uppsrc/CtrlCore/ImageWin32.cpp +++ b/uppsrc/CtrlCore/ImageWin32.cpp @@ -305,11 +305,14 @@ struct ImageSysDataMaker : LRUCache::Maker { virtual int Make(ImageSysData& object) const { object.Init(img); return (int)img.GetLength(); } }; -void SystemDraw::SysDrawImageOp(int x, int y, const Image& img, const Rect& src, Color color) +void SystemDraw::SysDrawImageOp(int x, int y, const Image& _img, const Rect& src, Color color) { LLOG("SysDrawImageOp " << img.GetSerialId() << ' ' << img.GetSize()); GuiLock __; + + Image img = _img; + if(img.GetLength() == 0) return; @@ -324,6 +327,11 @@ void SystemDraw::SysDrawImageOp(int x, int y, const Image& img, const Rect& src, SetSurface(*this, x, y, sz.cx, sz.cy, ~img); return; } + + if(!IsNull(color)) { // avoid SW emulation + img = CachedSetColorKeepAlpha(img, color); + color = Null; + } ImageSysDataMaker m; static LRUCache cache; diff --git a/upptst/DrawImageColor/DrawImageColor.upp b/upptst/DrawImageColor/DrawImageColor.upp new file mode 100644 index 000000000..5872304d3 --- /dev/null +++ b/upptst/DrawImageColor/DrawImageColor.upp @@ -0,0 +1,9 @@ +uses + CtrlLib; + +file + main.cpp; + +mainconfig + "" = "GUI"; + diff --git a/upptst/DrawImageColor/main.cpp b/upptst/DrawImageColor/main.cpp new file mode 100644 index 000000000..41a9f7e71 --- /dev/null +++ b/upptst/DrawImageColor/main.cpp @@ -0,0 +1,15 @@ +#include + +using namespace Upp; + +struct MyApp : TopWindow { + void Paint(Draw& w) override { + w.DrawRect(GetSize(), White()); + w.DrawImage(100, 100, CtrlImg::undo(), Red()); + } +}; + +GUI_APP_MAIN +{ + MyApp().Run(); +}