打印方面我已做好了,但在取图方面还望高手解答.

解决方案 »

  1.   

    取图的方法,我这里有个类
    CBitmapFile,给我邮箱,可以发给你。
    你能够把你处理打印的代码给我吗。
    我正好需要参考一下。
      

  2.   

    HBITMAP hbmp; 
    hbmp = (HBITMAP)LoadImage(g_hinst, PATHOFYOURBITMAP, IMAGE_BITMAP, 0, 0, LR_DEFAULTSIZE | LR_LOADFROMFILE);
      

  3.   

    HBITMAP bitmap;
       /////读取位图文件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);
      

  4.   

    对于DIB位图,不妨使用发下办法(以640*480 24Bit为例):
    //---------------------.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);
    }
    ---------------------------------//