I need to free the bitpointer, because this function is executed multiple times and memory usage is growing for a reason I don\'t understand and it crashes afte
bitpointer
In SelectObject, save the returned value: HGDIOBJ save = SelectObject(hdcTemp, hBitmap2);
HGDIOBJ save = SelectObject(hdcTemp, hBitmap2);
Then before ReleaseDC, delete the DIB DeleteObject( SelectObject(hdcTemp, save) );
DeleteObject( SelectObject(hdcTemp, save) );
Otherwise, you create bitmaps and don't delete them.