42 int width = bitmap->GetWidth();
43 int height = bitmap->GetHeight();
44 HBITMAP hbmp = CreateCompatibleBitmap(m_hDC, width, height);
45 HDC hDCMemory = CreateCompatibleDC(m_hDC);
46 HBITMAP holdbmp = (HBITMAP)SelectObject(hDCMemory, hbmp);
47 BitBlt(hDCMemory, 0, 0, width, height, m_hDC, left, top, SRCCOPY);
48 SelectObject(hDCMemory, holdbmp);
50 bmi.bmiHeader.biSize =
sizeof bmi.bmiHeader;
51 bmi.bmiHeader.biBitCount = bitmap->GetBPP();
52 bmi.bmiHeader.biHeight = -height;
53 bmi.bmiHeader.biPlanes = 1;
54 bmi.bmiHeader.biWidth = width;
55 if (bitmap->GetBPP() > 8) {
56 ret = ::GetDIBits(hDCMemory, hbmp, 0, height,
57 bitmap->GetWritableBuffer().data(), &bmi,
58 DIB_RGB_COLORS) == height;
59 if (ret && bitmap->IsAlphaFormat()) {
60 bitmap->SetUniformOpaqueAlpha();
63 auto rgb_bitmap =
pdfium::MakeRetain<CFX_DIBitmap>();
65 bmi.bmiHeader.biBitCount = 24;
66 ::GetDIBits(hDCMemory, hbmp, 0, height,
67 rgb_bitmap->GetWritableBuffer().data(), &bmi, DIB_RGB_COLORS);
68 ret = bitmap->TransferBitmap(width, height,
std::move(rgb_bitmap), 0, 0);
75 DeleteObject(hDCMemory);
86 if (bitmap->IsMaskFormat()) {
87 int width = bitmap->GetWidth();
88 int height = bitmap->GetHeight();
90 if (bitmap->GetBPP() != 1 || alpha != 255) {
91 auto background =
pdfium::MakeRetain<CFX_DIBitmap>();
94 !background->CompositeMask(0, 0, width, height,
std::move(bitmap),
106 top - src_rect
.top, width
, height
, &clip_rect
,
111 if (bitmap->IsAlphaFormat()) {
112 auto rgb_bitmap =
pdfium::MakeRetain<CFX_DIBitmap>();
115 !rgb_bitmap->CompositeBitmap(0, 0, width, height,
std::move(bitmap),
144 bitmap = bitmap->StretchTo(dest_width, dest_height, options, &bitmap_clip);
167 dest_height > 10000 || dest_height < -10000) {
168 return UseFoxitStretchEngine(
std::move(bitmap), color, dest_left, dest_top,
169 dest_width, dest_height, pClipRect, options);
171 if (bitmap->IsMaskFormat()) {
173 image_rect
.left = dest_width > 0 ? dest_left : dest_left + dest_width;
174 image_rect
.right = dest_width > 0 ? dest_left + dest_width : dest_left;
175 image_rect
.top = dest_height > 0 ? dest_top : dest_top + dest_height;
176 image_rect
.bottom = dest_height > 0 ? dest_top + dest_height : dest_top;
177 FX_RECT clip_rect = image_rect;
187 auto background =
pdfium::MakeRetain<CFX_DIBitmap>();
191 !background->CompositeMask(0, 0, clip_width, clip_height,
192 std::move(bitmap), color, 0, 0,
201 if (bitmap->IsAlphaFormat()) {
204 if (pPlatform->m_GdiplusExt.IsAvailable()) {
205 return pPlatform->m_GdiplusExt.StretchDIBits(m_hDC, std::move(bitmap),
207 dest_width, dest_height);
209 return UseFoxitStretchEngine(
std::move(bitmap), color, dest_left, dest_top,
210 dest_width, dest_height, pClipRect,
bool GDI_StretchDIBits(RetainPtr< const CFX_DIBBase > source, int dest_left, int dest_top, int dest_width, int dest_height, const FXDIB_ResampleOptions &options)
StartResult StartDIBits(RetainPtr< const CFX_DIBBase > bitmap, float alpha, uint32_t color, const CFX_Matrix &matrix, const FXDIB_ResampleOptions &options, BlendMode blend_type) override
bool StretchDIBits(RetainPtr< const CFX_DIBBase > bitmap, uint32_t color, int dest_left, int dest_top, int dest_width, int dest_height, const FX_RECT *pClipRect, const FXDIB_ResampleOptions &options, BlendMode blend_type) override