Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(439)

Unified Diff: ui/gfx/gdi_util.cc

Issue 12340015: [CLOSED] Big patch. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gfx/gdi_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/gdi_util.cc
diff --git a/ui/gfx/gdi_util.cc b/ui/gfx/gdi_util.cc
index 13f141ae8028eb619541353e08b16f82e8ec9d55..88c09355a28fc8de7a600eaba6a3137c94e57b80 100644
--- a/ui/gfx/gdi_util.cc
+++ b/ui/gfx/gdi_util.cc
@@ -4,6 +4,7 @@
#include "ui/gfx/gdi_util.h"
+#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
namespace gfx {
@@ -28,7 +29,6 @@ void CreateBitmapHeaderWithColorDepth(int width, int height, int color_depth,
hdr->biClrImportant = 0;
}
-
void CreateBitmapV4Header(int width, int height, BITMAPV4HEADER* hdr) {
// Because bmp v4 header is just an extension, we just create a v3 header and
// copy the bits over to the v4 header.
@@ -119,4 +119,27 @@ bool ScaleDC(HDC dc, double scale_factor) {
return !!ModifyWorldTransform(dc, &xform, MWT_LEFTMULTIPLY);
}
+void StretchDIBits(HDC hdc, int dest_x, int dest_y, int dest_w, int dest_h,
+ int src_x, int src_y, int src_w, int src_h, void* pixels,
+ const BITMAPINFO* bitmap_info) {
+ // When blitting a rectangle that touches the bottom, left corner of the
+ // bitmap, StretchDIBits looks at it top-down! For more details, see
+ // http://wiki.allegro.cc/index.php?title=StretchDIBits.
+ int rv;
+ int bitmap_h = -bitmap_info->bmiHeader.biHeight;
+ int bottom_up_src_y = bitmap_h - src_y - src_h;
+ if (bottom_up_src_y == 0 && src_x == 0 && src_h != bitmap_h) {
+ rv = ::StretchDIBits(hdc,
+ dest_x, dest_h + dest_y - 1, dest_w, -dest_h,
+ src_x, bitmap_h - src_y + 1, src_w, -src_h,
+ pixels, bitmap_info, DIB_RGB_COLORS, SRCCOPY);
+ } else {
+ rv = ::StretchDIBits(hdc,
+ dest_x, dest_y, dest_w, dest_h,
+ src_x, bottom_up_src_y, src_w, src_h,
+ pixels, bitmap_info, DIB_RGB_COLORS, SRCCOPY);
+ }
+ DCHECK(rv != GDI_ERROR);
+}
+
} // namespace gfx
« no previous file with comments | « ui/gfx/gdi_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698