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