41 int width = pBitmap->GetWidth();
42 int height = pBitmap->GetHeight();
43 HBITMAP hbmp = CreateCompatibleBitmap(m_hDC, width, height);
44 HDC hDCMemory = CreateCompatibleDC(m_hDC);
45 HBITMAP holdbmp = (HBITMAP)SelectObject(hDCMemory, hbmp);
46 BitBlt(hDCMemory, 0, 0, width, height, m_hDC, left, top, SRCCOPY);
47 SelectObject(hDCMemory, holdbmp);
49 memset(&bmi, 0,
sizeof bmi);
50 bmi.bmiHeader.biSize =
sizeof bmi.bmiHeader;
51 bmi.bmiHeader.biBitCount = pBitmap->GetBPP();
52 bmi.bmiHeader.biHeight = -height;
53 bmi.bmiHeader.biPlanes = 1;
54 bmi.bmiHeader.biWidth = width;
55 if (pBitmap->GetBPP() > 8) {
56 ret = ::GetDIBits(hDCMemory, hbmp, 0, height,
57 pBitmap->GetWritableBuffer().data(), &bmi,
58 DIB_RGB_COLORS) == height;
60 auto rgb_bitmap = pdfium::MakeRetain<CFX_DIBitmap>();
62 bmi.bmiHeader.biBitCount = 24;
63 ::GetDIBits(hDCMemory, hbmp, 0, height,
64 rgb_bitmap->GetWritableBuffer().data(), &bmi, DIB_RGB_COLORS);
65 ret = pBitmap->TransferBitmap(0, 0, width, height, std::move(rgb_bitmap),
71 if (ret && pBitmap->IsAlphaFormat())
72 pBitmap->SetUniformOpaqueAlpha();
75 DeleteObject(hDCMemory);
86 if (pSource->IsMaskFormat()) {
87 int width = pSource->GetWidth();
88 int height = pSource->GetHeight();
90 if (pSource->GetBPP() != 1 || alpha != 255) {
91 auto background = pdfium::MakeRetain<CFX_DIBitmap>();
94 !background->CompositeMask(0, 0, width, height,
std::move(pSource),
106 top - src_rect
.top, width
, height
, &clip_rect
,
111 if (pSource->IsAlphaFormat()) {
112 auto bitmap = pdfium::MakeRetain<CFX_DIBitmap>();
115 !bitmap->CompositeBitmap(0, 0, width, height,
std::move(pSource),
143 bitmap = bitmap->StretchTo(dest_width, dest_height, options, &bitmap_clip);
166 dest_height > 10000 || dest_height < -10000) {
167 return UseFoxitStretchEngine(
std::move(bitmap), color, dest_left, dest_top,
168 dest_width, dest_height, pClipRect, options);
170 if (bitmap->IsMaskFormat()) {
172 image_rect
.left = dest_width > 0 ? dest_left : dest_left + dest_width;
173 image_rect
.right = dest_width > 0 ? dest_left + dest_width : dest_left;
174 image_rect
.top = dest_height > 0 ? dest_top : dest_top + dest_height;
175 image_rect
.bottom = dest_height > 0 ? dest_top + dest_height : dest_top;
176 FX_RECT clip_rect = image_rect;
186 auto background = pdfium::MakeRetain<CFX_DIBitmap>();
190 !background->CompositeMask(0, 0, clip_width, clip_height,
191 std::move(bitmap), color, 0, 0,
200 if (bitmap->IsAlphaFormat()) {
203 if (pPlatform->m_GdiplusExt.IsAvailable()) {
204 return pPlatform->m_GdiplusExt.StretchDIBits(
205 m_hDC, std::move(bitmap), dest_left, dest_top, dest_width,
206 dest_height, pClipRect, FXDIB_ResampleOptions());
208 return UseFoxitStretchEngine(
std::move(bitmap), color, dest_left, dest_top,
209 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)
bool SetDIBits(const RetainPtr< const CFX_DIBBase > &pBitmap, uint32_t color, const FX_RECT &src_rect, int left, int top, 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
bool StartDIBits(RetainPtr< const CFX_DIBBase > bitmap, float alpha, uint32_t color, const CFX_Matrix &matrix, const FXDIB_ResampleOptions &options, std::unique_ptr< CFX_ImageRenderer > *handle, BlendMode blend_type) override