Home | Info | Community | Development | myReactOS | Contact Us
[static]
Definition at line 867 of file hlpfile.c.
Referenced by HLPFILE_RtfAddBitmap().
{ HDC hdc, hdcMask, hdcMem, hdcEMF; HBITMAP hbm, hbmMask, hbmOldMask, hbmOldMem; HENHMETAFILE hEMF; BOOL ret = FALSE; void* data; UINT sz; hbm = CreateDIBitmap(hdc = GetDC(0), &bi->bmiHeader, CBM_INIT, pict, bi, DIB_RGB_COLORS); hdcMem = CreateCompatibleDC(hdc); hbmOldMem = SelectObject(hdcMem, hbm); /* create the mask bitmap from the main bitmap */ hdcMask = CreateCompatibleDC(hdc); hbmMask = CreateBitmap(bi->bmiHeader.biWidth, bi->bmiHeader.biHeight, 1, 1, NULL); hbmOldMask = SelectObject(hdcMask, hbmMask); SetBkColor(hdcMem, RGB(bi->bmiColors[nc - 1].rgbRed, bi->bmiColors[nc - 1].rgbGreen, bi->bmiColors[nc - 1].rgbBlue)); BitBlt(hdcMask, 0, 0, bi->bmiHeader.biWidth, bi->bmiHeader.biHeight, hdcMem, 0, 0, SRCCOPY); /* sets to RGB(0,0,0) the transparent bits in main bitmap */ SetBkColor(hdcMem, RGB(0,0,0)); SetTextColor(hdcMem, RGB(255,255,255)); BitBlt(hdcMem, 0, 0, bi->bmiHeader.biWidth, bi->bmiHeader.biHeight, hdcMask, 0, 0, SRCAND); SelectObject(hdcMask, hbmOldMask); DeleteDC(hdcMask); SelectObject(hdcMem, hbmOldMem); DeleteDC(hdcMem); /* we create the bitmap on the fly */ hdcEMF = CreateEnhMetaFile(NULL, NULL, NULL, NULL); hdcMem = CreateCompatibleDC(hdcEMF); /* sets to RGB(0,0,0) the transparent bits in final bitmap */ hbmOldMem = SelectObject(hdcMem, hbmMask); SetBkColor(hdcEMF, RGB(255, 255, 255)); SetTextColor(hdcEMF, RGB(0, 0, 0)); BitBlt(hdcEMF, 0, 0, bi->bmiHeader.biWidth, bi->bmiHeader.biHeight, hdcMem, 0, 0, SRCAND); /* and copy the remaining bits of main bitmap */ SelectObject(hdcMem, hbm); BitBlt(hdcEMF, 0, 0, bi->bmiHeader.biWidth, bi->bmiHeader.biHeight, hdcMem, 0, 0, SRCPAINT); SelectObject(hdcMem, hbmOldMem); DeleteDC(hdcMem); /* do the cleanup */ ReleaseDC(0, hdc); DeleteObject(hbmMask); DeleteObject(hbm); hEMF = CloseEnhMetaFile(hdcEMF); /* generate rtf stream */ sz = GetEnhMetaFileBits(hEMF, 0, NULL); if (sz && (data = HeapAlloc(GetProcessHeap(), 0, sz))) { if (sz == GetEnhMetaFileBits(hEMF, sz, data)) { ret = HLPFILE_RtfAddControl(rd, "{\\pict\\emfblip") && HLPFILE_RtfAddHexBytes(rd, data, sz) && HLPFILE_RtfAddControl(rd, "}"); } HeapFree(GetProcessHeap(), 0, data); } DeleteEnhMetaFile(hEMF); return ret; }