Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
assuming i have a bitmap image containing an object in a white background ..how to crop the object in the bitmap image using c++..also ignore the 54 byte bitmap header..plz hlp!guys try to rply asap..


thanks in advance..
Posted
Updated 25-Aug-14 21:14pm
v3

There are two principal ways to solve your question:

(a) Access the bitmap data and extract the desired rectangle by hand. That requires to know the size of each pixel, the length of each line (including slack bytes), the sequence in which lines are stored (top-to-bottom or bottom-to-top), and the number of available lines. All these things are contained in the BITMAP structure.

(b) Load the bitmap into a memory DC, create a second memory DC and load a bitmap of the target size into it, then bitblt from the first into the second DC with suitable offsets and sizes.

Either way will work. You will have to study the bitmap API of windows and learn about the BITMAP structure, the way in which bitmaps are stored in memory, and how bitblt works.
 
Share this answer
 
 
Share this answer
 
Comments
Richard MacCutchan 26-Aug-14 4:28am    
More precise about what? You need to go and study some of those links to learn how to manipulate bitmaps.
Richard MacCutchan 27-Aug-14 3:03am    
I'm not upset, and there is no 'simple' code. As I said before, you need to go and study the articles on GDI and bitmaps in order to learn how to do what you want.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900