打印方面我已做好了,但在取图方面还望高手解答.
解决方案 »
- 在程序中怎么调用虚幻引擎3做好的场景?
- 没有窗口的程序,怎么捕获鼠标和键盘的消息函数???
- 如何在对话框中放入文字,并加入滚动条?
- gdi+ drawImage 反锯齿
- 为什么Dialog的资源总是用类似“enum { IDD = IDD_DIALOG_INFORMATION };”这样的枚举类型定义?
- 请教!如何让一个子窗体在任务栏上占有一格?
- 请教用VC控制excel
- 如何用代码关闭dialog.DoModal()的窗口
- 关于CTree和FindFirstFile中的一个插入路径问题
- 如果连这个问题你都能回答,那我只能说,我服了你! 你是我遇到过的最高的手!!!
- 如何使用CSerialPort类收发二进制数据?
- how to convert BSTR to char
CBitmapFile,给我邮箱,可以发给你。
你能够把你处理打印的代码给我吗。
我正好需要参考一下。
hbmp = (HBITMAP)LoadImage(g_hinst, PATHOFYOURBITMAP, IMAGE_BITMAP, 0, 0, LR_DEFAULTSIZE | LR_LOADFROMFILE);
/////读取位图文件ScreenSaver.BMP
bitmap=(HBITMAP)LoadImage(AfxGetInstanceHandle(),"ScreenSaver.BMP",IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION);
ASSERT(bitmap);
HBITMAP OldBitmap;
CDC MemDC;CRect rect;
CDC *pDC=this->GetDC();
MemDC.CreateCompatibleDC(pDC);
GetClientRect(rect);
OldBitmap=(HBITMAP)MemDC.SelectObject(bitmap);
//use the MemDC to print the picture!
.....
MemDC.SelectObject(OldBitmap);
//---------------------.h文件
// Operations
public:
BITMAPINFO bmi;
HANDLE hTrueSrc;
LPSTR pTrueSrc;
CFile fileTrueBmp;
int imageWidth;
int imageHeight;
int displayCx;
int displayCy; bool IsShow;
void ShowPictrue(CDC * pDC,CRect rect,char filename[50]);
bool IsCopy;//---------------------对于是.cpp文件
CD02View::CD02View()
{
// TODO: add construction code here
imageWidth=640;
imageHeight=480;
displayCx=imageWidth;
displayCy=imageHeight; bmi.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
bmi.bmiHeader.biWidth=imageWidth;
bmi.bmiHeader.biHeight=imageHeight;
bmi.bmiHeader.biPlanes=1L;
bmi.bmiHeader.biBitCount=24;
bmi.bmiHeader.biCompression=0;
bmi.bmiHeader.biSizeImage=(long)(imageWidth*imageHeight*4);
bmi.bmiHeader.biXPelsPerMeter=0;
bmi.bmiHeader.biYPelsPerMeter=0;
bmi.bmiHeader.biClrUsed=0;
bmi.bmiHeader.biClrImportant=0;
hTrueSrc=::GlobalAlloc(GHND,(long)(imageWidth*imageHeight*4));
pTrueSrc=(LPSTR)::GlobalLock(hTrueSrc); IsShow=false;
IsCopy=true;
}//------------------------------------------------
CD02View::~CD02View()
{
GlobalUnlock(hTrueSrc);
GlobalFree(hTrueSrc);
}
//----------------------------------------------------------
void CD02View::OnDraw(CDC* pDC)
{
CD02Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
pDC->SetStretchBltMode(COLORONCOLOR); ShowPictrue(pDC,CRect(10,100,260,200),"d:\\d02\\1.bmp");
}
//-------------------------------------------------------------
void CD02View::ShowPictrue(CDC * pDC,CRect rect,char filename[50])
{
strcpy(m_filename,filename);
fileTrueBmp.Open(filename,
CFile::modeRead|CFile::typeBinary|CFile::shareExclusive);
fileTrueBmp.Seek(54,CFile::begin);
fileTrueBmp.ReadHuge(pTrueSrc,(long)(imageWidth*imageHeight*4));
fileTrueBmp.Close();
IsShow=true; StretchDIBits(pDC->m_hDC,rect.left,rect.top,rect.right,rect.bottom,0,0,imageWidth,imageHeight,
pTrueSrc,(LPBITMAPINFO)&bmi,DIB_RGB_COLORS,SRCCOPY);
}
---------------------------------//