Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Load Resource's Bitmap To HBITMAP

Load Resource's Bitmap To HBITMAP

Scheduled Pinned Locked Moved C / C++ / MFC
questiongraphicslearning
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    akirachen
    wrote on last edited by
    #1

    Load Resource's Bitmap To HBITMAP I want to replace frame.LoadBmp("TextFrame.bmp") by frame.LoadBmp(IDB_BITMAP). On other words,Original loaded picture by function "LoadImage", I want to load picture by Resouce's Bitmap. HBITMAP hBitmap;//is member variable of CDibSection hBitmap=uknownfunction(IDB_BITMAP) How do I rewrite CDibSection::LoadBmp to Load Resource's Bitmap To HBITMAP? PS:IDB_BITMAP is a Bitmap of Resoucre. CDibSection frame; //////////////// if (frame.LoadBmp("TextFrame.bmp")) { HRGN h = frame.CreateRgn(); if (h) SetWindowRgn(h, TRUE); } //////////////// // Loading BMP file // BOOL CDibSection::LoadBmp(const char *path) { Destroy(); hBitmap = (HBITMAP)::LoadImage(::GetModuleHandle(0), path, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_LOADFROMFILE); if (!hBitmap) return FALSE; DIBSECTION dib; if (::GetObject(hBitmap, sizeof(DIBSECTION), &dib) != sizeof(DIBSECTION)) { ::DeleteObject(hBitmap); hBitmap = 0; return FALSE; } Header.Info = dib.dsBmih; for (int i=0; i<3; i++) Header.BitField[i] = dib.dsBitfields[i]; bytes_per_pixel = PixelBytes(dib.dsBmih.biBitCount); bytes_per_line = ScanBytes(dib.dsBmih.biWidth, dib.dsBmih.biBitCount); Bits = dib.dsBm.bmBits; return TRUE; }

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups