displaying large bitmap file

This is a discussion on displaying large bitmap file within the Windows Programming forums, part of the Platform Specific Boards category; Hey friends i am trying to display a large bitmap . using following segment. but it returns a null handle ...

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    5

    Talking displaying large bitmap file

    Hey friends

    i am trying to display a large bitmap . using following segment. but it returns a null handle if bmp file is greater than 4500by 4500, otherwise it works fine.

    how can i load a large bmp file around 20 MB. i am confused , help me plz



    hdcroi = GetDC(hwnd1);
    hBaseBitmap = CreateDIBitmap(hdcroi, (LPBITMAPINFOHEADER) &pBmpInfor->bmiHeader,
    CBM_INIT, pBits, (LPBITMAPINFO) pBmpInfor, DIB_RGB_COLORS );

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Have you tried LoadImage( ) ?

  3. #3
    Banned Cgawd's Avatar
    Join Date
    Oct 2002
    Posts
    405
    If you add the bitmap as a resource, you can create an instance of the CBitmap class using the resource ID of the bitmap as the image to be loaded. If you want to load a bitmap from a file, you can use the LoadImage API call to load the bitmap from the file. After you load the bitmap, you can use the handle for the image to attach the image to the CBitmap class, like so:
    Code:
    HBITMAP hBitmap= (HBITMAP)::LoadImage(AfxGetInstanceHandle(), m_sFileName, IMAGE_BITMAP, 0,0, LR_LOADFROMFILE | LR_CREATEDIBSECTION);
    m_bmpBitmap.Attach(hBitmap);
    //create a second device context and select the bitmap into it
    
    CDC dcMem;
    dcMem.CreateCompatibleDC(dc);
    dcMem.SelectObject(&m_bmpBitmap);
    
    //copy the bitmap into the regular display device context
    dc->BitBlt(10, 10, bm.bmWidth, bm.bmHeight, &dcMem, 0, 0, SRCCOPY);
    
    //you can also copy and resize the image
    dc->StretchBlt(10, 10, (lRect.Width() - 20), (lRect.Height() -20), &dcMem, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Newbie homework help
    By fossage in forum C Programming
    Replies: 3
    Last Post: 04-30-2009, 04:27 PM
  2. Data Structure Eror
    By prominababy in forum C Programming
    Replies: 3
    Last Post: 01-06-2009, 08:35 AM
  3. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 04:02 AM
  4. gcc link external library
    By spank in forum C Programming
    Replies: 6
    Last Post: 08-08-2007, 03:44 PM
  5. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM

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