Thread: displaying large bitmap file

  1. #1
    Registered User
    Join Date
    Nov 2002

    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,

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

  3. #3
    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:
    HBITMAP hBitmap= (HBITMAP)::LoadImage(AfxGetInstanceHandle(), m_sFileName, IMAGE_BITMAP, 0,0, LR_LOADFROMFILE | LR_CREATEDIBSECTION);
    //create a second device context and select the bitmap into it
    CDC dcMem;
    //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, 09:35 AM
  3. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 05: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