bitmap

This is a discussion on bitmap within the Windows Programming forums, part of the Platform Specific Boards category; Can someone please help?I'm trying to print a bitmap to the screen. This is where I'm upto: ------------------------------------------------------------------------------------ void CSketcherView::OnDraw(CDC* ...

  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    22

    bitmap

    Can someone please help?I'm trying to print a bitmap to the screen.
    This is where I'm upto:
    ------------------------------------------------------------------------------------
    void CSketcherView::OnDraw(CDC* pDC)
    {
    CSketcherDoc* pDoc = GetDocument();
    ASSERT_VALID(pDoc);

    CBitmap MyBit;
    MyBit.LoadBitmap(IDB_BITMAP2);
    MyBit.CreateBitmap(100,40,);

    CBitmap* pOldBitmap = pDC->SelectObject(&MyBit);

    pDC->BitBlt(0,0,100,100,pDC,0,0,SRCCOPY);
    ----------------------------------------------------------------------------------

    I'm not sure of the last three parameters in CreateBitmap.
    Also BitBlt could be wrong.
    I have looked through the forum but still can't work it out.

    Phil

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    Here is one solution.

    Code:
    CBitmap MyBit;
    MyBit.LoadBitmap(IDB_BITMAP2);
    MyBit.CreateBitmap(100,40,);
    
    CDC memoryDC;
    memoryDC.CreateCompatibleDC(pDC);
    CBitMap *pOldBitmap = memoryDC.SelectObject(&MyBit);
    memoryDC.SetMapMode(pDC->GetMapMode());
    memoryDC.BitBlt(0, 0, 100, 100, &memoryDC, 0, 0, SRCCOPY);
    memoryDC.SetObject(pOldBitMap);
    The solution is you should create a memory device context, load the bitmap onto the virtual DC, and then blit it onto the screen.

    Kuphryn

  3. #3
    Registered User
    Join Date
    Aug 2001
    Posts
    22
    Thanks for helping me with my problem kuphryn.I still can't
    get it to compile.Here are the errors.
    ---------------------------------------------------------------------------------


    cpp(63) : error C2660: 'CreateBitmap' : function does not take 2 parameters
    cpp(70) : error C2039: 'SetObject' : is not a member of 'CDC'
    microsoft visual studio\vc98\mfc\include\afxwin.h(636) : see declaration of 'CDC'


    I can see that the CreateBitmap function has more parameters.
    I looked up in msdn but I'm still not sure of the values to put there.
    Phil

  4. #4
    Registered User
    Join Date
    Aug 2001
    Posts
    22

    Thumbs up

    Since my last post I found a tutorial on the web.Which I
    tried and it worked first time.Great my first bitmap.
    For anyone who is interested the link is
    http://www.wiu.edu/users/mflll/CS412g/bitmaps.html


    Phil

  5. #5
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    Cool.

    I made some typos in the reply. One of which was "SetObject." I meant "SelectObject."

    Kuphryn

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Loading a bitmap (Without using glaux)
    By Shamino in forum Game Programming
    Replies: 7
    Last Post: 03-16-2006, 09:43 AM
  2. OpenGL -- Bitmaps
    By HQSneaker in forum Game Programming
    Replies: 14
    Last Post: 09-06-2004, 05:04 PM
  3. Loading a Bitmap resource for OpenGL Texture[x]
    By the dead tree in forum Game Programming
    Replies: 4
    Last Post: 08-26-2004, 02:12 PM
  4. bitmap not going onto screen
    By stallion in forum Windows Programming
    Replies: 4
    Last Post: 02-22-2003, 10:07 AM
  5. texture is all white in opengl!
    By Crossbow in forum Game Programming
    Replies: 7
    Last Post: 03-31-2002, 11:54 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21