Why can not print a big transparent BMP image(small image can be transparent) !?
- From: kevin <hdzhang264@xxxxxxx>
- Date: Tue, 29 Jul 2008 01:03:28 -0700 (PDT)
Now, I want to print a transparent BMP image(background is set to
White 0xff0xff0xff).
I have two BMP image:
bmpFirst: pixel dimension(72*72), LOMETRIC(0.1mm)
dimension(191,191), resolution(96dpi, or 3780pixel/meter)
bmpSecond:pixel dimension(226*226), LOMETRIC(0.1mm)
dimension(191,191), resolution(300dpi, or 11808pixel/meter)
I used the following code.
hDC->SetMapMode(MM_LOMETRIC);
TransparentBlt2(hDC->m_hDC,0,0,190,-190,bmpFirstDC.m_hDC,
0,0,bm.nWidth,bm.nHeight,crMask);//bm.nWidth,bm.nHeight are both
pixel
dimension
when hDC is Screen Display(for example, a dialog STATIC control), two
image displayed the same size, and both are transparent.
But When hDC is Printer handle, tow image still displayed the same
size, but the bmpSecond shows Full Black image.
I am confused. why the later is full Black?
void COcxMainDlg::TransparentBlt2( HDC hdcDest,
int nXOriginDest,
int nYOriginDest,
int nWidthDest,
int nHeightDest,
HDC hdcSrc,
int nXOriginSrc,
int nYOriginSrc,
int nWidthSrc,
int nHeightSrc,
UINT crTransparent
)
{
HBITMAP hOldImageBMP, hImageBMP = CreateCompatibleBitmap(hdcDest,
nWidthDest, nHeightDest);
HBITMAP hOldMaskBMP, hMaskBMP = CreateBitmap(nWidthDest,
nHeightDest,
1, 1, NULL);
HDC hImageDC = CreateCompatibleDC(hdcDest);
HDC hMaskDC = CreateCompatibleDC(hdcDest);
hOldImageBMP = (HBITMAP)SelectObject(hImageDC, hImageBMP);
hOldMaskBMP = (HBITMAP)SelectObject(hMaskDC, hMaskBMP);
StretchBlt(hImageDC, 0, 0, nWidthDest, nHeightDest,
hdcSrc, nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc, SRCCOPY);
SetBkColor(hImageDC, crTransparent);
StretchBlt(hMaskDC, 0, 0, nWidthDest, nHeightDest, hImageDC, 0, 0,
nWidthDest, nHeightDest,SRCCOPY);
SetBkColor(hImageDC, RGB(0,0,0));
SetTextColor(hImageDC, RGB(255,255,255));
//BitBlt(hImageDC, 0, 0, nWidthDest, nHeightDest, hMaskDC, 0, 0,
SRCAND);
StretchBlt(hImageDC, 0, 0, nWidthDest, nHeightDest, hMaskDC, 0, 0,
nWidthDest, nHeightDest,SRCAND);
SetBkColor(hdcDest,RGB(0xff,0xff,0xff));
SetTextColor(hdcDest,RGB(0,0,0));
//BitBlt(hdcDest, nXOriginDest, nYOriginDest, nWidthDest,
nHeightDest, hMaskDC, 0, 0, SRCAND);
StretchBlt(hdcDest, nXOriginDest, nYOriginDest, nWidthDest, -
nHeightDest, hMaskDC, 0, 0, nWidthDest, nHeightDest, SRCAND);
//BitBlt(hdcDest, nXOriginDest, nYOriginDest, nWidthDest,
nHeightDest, hImageDC, 0, 0, SRCPAINT);
StretchBlt(hdcDest, nXOriginDest, nYOriginDest, nWidthDest, -
nHeightDest, hImageDC, 0, 0, nWidthDest, nHeightDest,SRCPAINT);
SelectObject(hImageDC, hOldImageBMP);
DeleteDC(hImageDC);
SelectObject(hMaskDC, hOldMaskBMP);
DeleteDC(hMaskDC);
DeleteObject(hImageBMP);
DeleteObject(hMaskBMP);
}
.
- Prev by Date: Re: LoadImage(LR_LOADFROMFILE) fails with no error
- Next by Date: Re: How can i get the dimensions of an HICON?
- Previous by thread: LoadImage(LR_LOADFROMFILE) fails with no error
- Next by thread: Help for improving the performance of GDIPlus Bitmap drawing
- Index(es):
Relevant Pages
|
Loading