Quantcast
Channel: Visual C forum
Viewing all articles
Browse latest Browse all 15302

Creating a Bitmap from a Bitmap in C++

$
0
0
Hello, I would like to create a bitmap from other bitmaps. The C# code that worked is
g.DrawImage(background, distance, 0, new Rectangle(0, 0, 1000, 1000), GraphicsUnit.Pixel);
g.DrawImage(background2, 0, 0, new Rectangle(0, 0, background2.Width, background2.Height), GraphicsUnit.Pixel);

I would like to do this in C++. The code I am trying is
HDC hdc = CreateCompatibleDC(NULL);
HGDIOBJ original = SelectObject(hdc, hBitmapbackground);
HDC hdc2 = CreateCompatibleDC(NULL);
HGDIOBJ original2 = SelectObject(hdc2, hBitmapbackground2);
BitBlt(hdc, 0, 0, 1000, 1000, hdc2 , distance, 0, SRCCOPY);
BitBlt(hdc, 100, 0, 100, 100, hdc2, 0, 5, SRCCOPY);
hBitmapbackground = (HBITMAP)GetCurrentObject(hdc, OBJ_BITMAP);
SelectObject(hdc, original);
DeleteDC(hdc);
SelectObject(hdc2, original2);
DeleteDC(hdc2);

The problem is that hBitmapbackground is the same even after the GetCurrentObject function. Any ideas? Thank you
Sincerely, Jakeinc

Sincerely, Jakeinc


Viewing all articles
Browse latest Browse all 15302

Trending Articles