• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 369
  • Last Modified:

copy bitmap over second bitmap

I have a problem.

I want to copy a bitmap over second bitmap at the specified location and then save that bitmap as third bitmap.

if anybody knows the solution then please give sample code.

  • 2
1 Solution
Roshan DavisCommented:
Create two memory dc. Select two bitmaps in two memory DCs.
BilBlt one dc to another.

Using GetDIBits get tha bitmap data, and save the bitmap into a file.

Good Luck
Hmmm, I'd have to guess that you want to copy one bitmap _transparently_ over another bitmap. In that case you will have to apply masking in between the blitting steps. Let me know if that is what you are after and I'll hunt down a tutorial for you.

malik_mumtazAuthor Commented:
yes f10yd i am looking what you have guessed. i will wait for your response.
This link http://www.codeproject.com/bitmap/transbitmapmask.asp describes hot to draw transparent bitmaps. Saving a bitmap to file is illustrated here: http://www.codeguru.com/bitmap/bitmap_to_file.shtml . Just copy-paste the function and call it with a HBITMAP retrieved from the CBitmap class.

CBitmap MyBmp;
// do your processing
WriteDIB( _T( "filename.bmp" ), (HBITMAP)MyBmp );

You may have to change to WriteDIB declaration using a const HANDLE, i.e.

WriteDIB( LPCTSTR zsFileName, const HANDLE hDIB )

This should get you going.


Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now