您的位置:首页 >> 编程开发 >> Visual C++ >> 位图操作 >> 正文
RSS
 

BMP位图操作(象素操作)

http://www.rdxx.com 05年07月27日 21:55 CSDN 我要投稿

关键词: 象素 , 位图 , BMP , 操作

下面一段代码对BMP的象素操作非常有用:

void CBmpTryView::OnDraw(CDC* pDC)
{
    CBmpTryDoc* pDoc = GetDocument();
    ASSERT_VALID(pDoc);
    // TODO: add draw code for native data here

    CDC memdcX,memdcY;
    memdcX.CreateCompatibleDC(pDC);
            //map these CDC objects to your window DC
    memdcY.CreateCompatibleDC(pDC);

    BITMAP bmpX,bmpY;
   
    CBitmap mybmp,bmpClone;
    bmpClone.LoadBitmap(IDB_BITMAP2);
             //initialize the clone bitmap object(empty image in
             //this case) before using

    DWORD dwValue,dwValue2;    
    
   

      if(TRUE == mybmp.LoadBitmap(IDB_BITMAP1))
      {          
          mybmp.GetBitmap(&bmpX); //Get bitmap dimensions
                                  //into BITMAP structure.
          BYTE* bmpBuffer=(BYTE*)GlobalAlloc(GPTR,
             bmpX.bmWidthBytes*bmpX.bmHeight);//allocate memory for image
                                              //byte buffer
          dwValue=mybmp.GetBitmapBits(bmpX.bmWidthBytes*bmpX.bmHeight,
                   bmpBuffer);//Get the bitmap bits 
                              //into a structure    

         
          dwValue2 = bmpClone.SetBitmapBits(bmpX.bmWidthBytes*bmpX.bmHeight,
               bmpBuffer);//generate image from
                          //above buffer
          bmpClone.GetBitmap(&bmpY);

          memdcX.SelectObject(mybmp);//select original bitmap

共5页  1 2 3 4 5

 
 
标签: 象素 , 位图 , BMP , 操作 打印本文
 
 
  热点搜索
 
 
 



Valid XHTML 1.0 Transitional
Copyright ©2005 - 2008 Rdxx.Com,All Rights Reserved
收藏本页
收藏本站