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. Create a bitmap [modified]

Create a bitmap [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
graphicsdebuggingquestion
3 Posts 3 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.
  • R Offline
    R Offline
    realJSOP
    wrote on last edited by
    #1

    I have two bitmaps (loaded from resources). I want to combine thse two bitmaps side-by-side into a 3rd bitmap. I want to put the 3rd (combined) bitmap into an image list. I tried using the BitmapDC class from the GDI articles section, but I'm missing something (obviously, otherwise I wouldn't be here). Here's the code I'm using now:

    CBitmap bmp1;
    CBitmap bmp2;
    bmp1.LoadBitmap(nImgConsult);
    bmp2.LoadBitmap(nImgLabs);
    CBitmapDC bmpDC(34, 21, GetDC(), RGB(255,255,255));
    DrawBitmap(&bmp1, &bmpDC, CPoint(0, 0));
    DrawBitmap(&bmp2, &bmpDC, CPoint(17, 0));
    CBitmap\* pBMP = bmpDC.Close();
    if (!m\_ResultsImages.Replace(0, pBMP, NULL))
    {
    	TRACE("ImageList.Replace failed\\n");
    }
    delete pBMP;
    

    Any hints, clues, or alternative code? -- modified at 11:36 Wednesday 26th July, 2006

    Z V 2 Replies Last reply
    0
    • R realJSOP

      I have two bitmaps (loaded from resources). I want to combine thse two bitmaps side-by-side into a 3rd bitmap. I want to put the 3rd (combined) bitmap into an image list. I tried using the BitmapDC class from the GDI articles section, but I'm missing something (obviously, otherwise I wouldn't be here). Here's the code I'm using now:

      CBitmap bmp1;
      CBitmap bmp2;
      bmp1.LoadBitmap(nImgConsult);
      bmp2.LoadBitmap(nImgLabs);
      CBitmapDC bmpDC(34, 21, GetDC(), RGB(255,255,255));
      DrawBitmap(&bmp1, &bmpDC, CPoint(0, 0));
      DrawBitmap(&bmp2, &bmpDC, CPoint(17, 0));
      CBitmap\* pBMP = bmpDC.Close();
      if (!m\_ResultsImages.Replace(0, pBMP, NULL))
      {
      	TRACE("ImageList.Replace failed\\n");
      }
      delete pBMP;
      

      Any hints, clues, or alternative code? -- modified at 11:36 Wednesday 26th July, 2006

      Z Offline
      Z Offline
      Zac Howland
      wrote on last edited by
      #2

      Why not just use the GetBitmapBits/SetBitmapBits (and CGdiObject::GetObject) to get the bits from images 1 and 2, create a byte array that is the size of the sum of both those arrays (which should be double the size of either one if the bitmaps are the same size), copy the bytes from image 1 to the first part of the new array, and image 2 to the last part of the new array and then use SetBitmapBits on a newly created CBitmap object?

      If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week Zac

      1 Reply Last reply
      0
      • R realJSOP

        I have two bitmaps (loaded from resources). I want to combine thse two bitmaps side-by-side into a 3rd bitmap. I want to put the 3rd (combined) bitmap into an image list. I tried using the BitmapDC class from the GDI articles section, but I'm missing something (obviously, otherwise I wouldn't be here). Here's the code I'm using now:

        CBitmap bmp1;
        CBitmap bmp2;
        bmp1.LoadBitmap(nImgConsult);
        bmp2.LoadBitmap(nImgLabs);
        CBitmapDC bmpDC(34, 21, GetDC(), RGB(255,255,255));
        DrawBitmap(&bmp1, &bmpDC, CPoint(0, 0));
        DrawBitmap(&bmp2, &bmpDC, CPoint(17, 0));
        CBitmap\* pBMP = bmpDC.Close();
        if (!m\_ResultsImages.Replace(0, pBMP, NULL))
        {
        	TRACE("ImageList.Replace failed\\n");
        }
        delete pBMP;
        

        Any hints, clues, or alternative code? -- modified at 11:36 Wednesday 26th July, 2006

        V Offline
        V Offline
        valikac
        wrote on last edited by
        #3

        another approach is create a bitmap sized to fit both source bitmaps. arrange the bitmaps via bitblt() Kuphryn

        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