diff --git a/uppsrc/CtrlCore/ImageWin32.cpp b/uppsrc/CtrlCore/ImageWin32.cpp index bd08e9ce4..847961347 100644 --- a/uppsrc/CtrlCore/ImageWin32.cpp +++ b/uppsrc/CtrlCore/ImageWin32.cpp @@ -254,13 +254,18 @@ void ImageSysData::Paint(SystemDraw& w, int x, int y, const Rect& src, Color c) if(sr.IsEmpty()) return; int kind = img.GetKind(); + +// DDUMP(GetDeviceCaps(dc, RASTERCAPS) & RC_BITBLT); +// DDUMP(GetDeviceCaps(dc, RASTERCAPS) & RC_DI_BITMAP); + if(kind == IMAGE_EMPTY) return; if(kind == IMAGE_OPAQUE && !IsNull(c)) { w.DrawRect(x, y, sz.cx, sz.cy, c); return; } - if(kind == IMAGE_OPAQUE && paintcount == 0 && sr == Rect(sz) && IsWinNT() && w.IsGui()) { + if(kind == IMAGE_OPAQUE && (paintcount == 0 || w.IsPrinter()) && sr == Rect(sz) && + (GetDeviceCaps(dc, RASTERCAPS) & RC_DIBTODEV)) { LTIMING("Image Opaque direct set"); SetSurface(w, x, y, sz.cx, sz.cy, ~img); paintcount++; @@ -279,41 +284,9 @@ void ImageSysData::Paint(SystemDraw& w, int x, int y, const Rect& src, Color c) SysImageRealized(img); return; } -#if 0 - if(kind == IMAGE_MASK/* || GetKind() == IMAGE_OPAQUE*/) { - HDC dcMem = ::CreateCompatibleDC(dc); - if(!hmask) { - LTIMING("Image Mask create"); - Buffer bmp(len); - hmask = CreateBitMask(~img, sz, sz, sz, bmp); - if(!hbmp) - CreateHBMP(dc, bmp); - } - LTIMING("Image Mask blt"); - HBITMAP o = (HBITMAP)::SelectObject(dcMem, ::CreateCompatibleBitmap(dc, sz.cx, sz.cy)); - ::BitBlt(dcMem, 0, 0, ssz.cx, ssz.cy, dc, x, y, SRCCOPY); - HDC dcMem2 = ::CreateCompatibleDC(dc); - ::SelectObject(dcMem2, hmask); - ::BitBlt(dcMem, 0, 0, ssz.cx, ssz.cy, dcMem2, sr.left, sr.top, SRCAND); - if(IsNull(c)) { - ::SelectObject(dcMem2, hbmp); - ::BitBlt(dcMem, 0, 0, ssz.cx, ssz.cy, dcMem2, sr.left, sr.top, SRCPAINT); - } - else { - HBRUSH ho = (HBRUSH) SelectObject(dcMem, CreateSolidBrush(c)); - ::BitBlt(dcMem, 0, 0, ssz.cx, ssz.cy, dcMem2, sr.left, sr.top, 0xba0b09); - ::DeleteObject(::SelectObject(dcMem, ho)); - } - ::BitBlt(dc, x, y, ssz.cx, ssz.cy, dcMem, 0, 0, SRCCOPY); - ::DeleteObject(::SelectObject(dcMem, o)); - ::DeleteDC(dcMem2); - ::DeleteDC(dcMem); - SysImageRealized(img); - return; - } -#endif -#ifndef PLATFORM_WINCE - if(fnAlphaBlend() && IsNull(c) && !ImageFallBack) { + if(fnAlphaBlend() && IsNull(c) && !ImageFallBack && + !(w.IsPrinter() && (GetDeviceCaps(dc, SHADEBLENDCAPS) & (SB_PIXEL_ALPHA|SB_PREMULT_ALPHA)) != + (SB_PIXEL_ALPHA|SB_PREMULT_ALPHA))) { if(!himg) { LTIMING("Image Alpha create"); BitmapInfo32__ bi(sz.cx, sz.cy); @@ -334,12 +307,12 @@ void ImageSysData::Paint(SystemDraw& w, int x, int y, const Rect& src, Color c) // ::DeleteDC(dcMem); SysImageRealized(img); } - else -#endif - { + else { LTIMING("Image Alpha sw"); DrawSurface sf(w, x, y, ssz.cx, ssz.cy); RGBA *t = sf; + if(w.IsPrinter()) // We have got here because printer does not support alpha blending + Fill(t, White(), ssz.cx * ssz.cy); for(int i = sr.top; i < sr.bottom; i++) { if(IsNull(c)) AlphaBlendOpaque(t, img[i] + sr.left, ssz.cx); diff --git a/uppsrc/Report/Report.cpp b/uppsrc/Report/Report.cpp index 6dc599193..02e29a2fd 100644 --- a/uppsrc/Report/Report.cpp +++ b/uppsrc/Report/Report.cpp @@ -2,6 +2,8 @@ NAMESPACE_UPP +#define LLOG(x) DLOG(x) + Report::Report() { mg.x = mg.y = Null; @@ -64,6 +66,7 @@ void Report::StartPage(int i) { DrawingDraw dw(GetSize()); page.At(i) = dw; + LLOG("Creating page " << i); Create(GetSize()); WhenPage(); PaintHF(*this, 0, header, i); @@ -128,6 +131,13 @@ Report& Report::Footer(const char *qtf, int spc) return *this; } +Report& Report::OnPage(Callback whenpage) +{ + WhenPage = whenpage; + RestartPage(); + return *this; +} + void Report::RestartPage() { page.SetCount(pagei + 1); diff --git a/uppsrc/Report/Report.h b/uppsrc/Report/Report.h index 1d4df6ebc..aed1a4c10 100644 --- a/uppsrc/Report/Report.h +++ b/uppsrc/Report/Report.h @@ -14,13 +14,13 @@ public: virtual Draw& Page(int i); private: - Array page; - int pagei; - int y; - String header, footer; - int headercy, headerspc, footercy, footerspc; - Point mg; - One printerjob; + Array page; + int pagei; + int y; + String header, footer; + int headercy, headerspc, footercy, footerspc; + Point mg; + One printerjob; void Flush(); String FormatHF(const char *s, int pageno); @@ -28,9 +28,10 @@ private: void PaintHF(Draw& w, int y, const char *qtf, int i); void StartPage(int i); void RestartPage(); + + Callback WhenPage; public: - Callback WhenPage; int GetCount() { Flush(); return page.GetCount(); } Drawing GetPage(int i) { Flush(); return page[i]; } @@ -65,6 +66,7 @@ public: Report& Margins(int top, int left) { mg.y = top; mg.x = left; return *this; } Report& Header(const char *qtf, int spc = 150); Report& Footer(const char *qtf, int spc = 150); + Report& OnPage(Callback whenpage); Report& NoHeader() { return Header(NULL, 0); } Report& NoFooter() { return Footer(NULL, 0); } diff --git a/uppsrc/plugin/jpg/jpgupp.cpp b/uppsrc/plugin/jpg/jpgupp.cpp index a413fbe0e..385bc8f0d 100644 --- a/uppsrc/plugin/jpg/jpgupp.cpp +++ b/uppsrc/plugin/jpg/jpgupp.cpp @@ -341,7 +341,7 @@ int JPGRaster::Data::ExifDir(const char *begin, int offset, IFD_TYPE type) // i, tag, fmt, count, BinHexEncode(data, data + len))); if(type == BASE_IFD) { if(tag == 0x112) - metadata.Add("orientation", int(data[0])); + metadata.Add("orientation", Exif16(data[0])); if(tag == 0x8825) { int offset = Exif32(data); // puts(NFormat("GPS IFD at %08x", offset));