Link to home
Start Free TrialLog in
Avatar of lieunguyenhoa
lieunguyenhoa

asked on

How to cut apart of image???

HI everybody, i very thanks for peoples see my topic.

I have 2 MDI (window) on my application, at the window 1 has an existing image and my problem here:
       1. "I don't know how to break/cut a image at the time when mouse clicked everywhere on my image(x,y)."
       2. "How to push a part breaked/cut into the window 2".

 Please, help me!!I'm a newbabie :D
Thanks so much for send mail: tranducmille@gmail.com
ASKER CERTIFIED SOLUTION
Avatar of mahesh1402
mahesh1402
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
and if you just want for show purpose on other window ie. you dont want to store cropped bitmap  then only BitBlt() function is sufficient for you...

BOOL BitBlt(HDC hdcDest,int nXDest,int nYDest,int nWidth,int nHeight,HDC hdcSrc,int nXSrc, int nYSrc,DWORD dwRop)

Here you can pass int nXSrc, int nYSrc which is source point of mouse you clicked on image. Image from this source point to image (width,height) will be displayed. But if you want to display in selected RECT then use above function.


MAHESH
Avatar of lieunguyenhoa
lieunguyenhoa

ASKER

Hi mahesh1402 ! thanks for you answer
But my purpose is crop an image to 2 part or to divide in two at the mouse is clicked (not RECT dimensions).
THanks, please help me.
>>But my purpose is crop an image to 2 part or to divide in two at the mouse is clicked (not RECT dimensions).

Any how cropped Image will be in Rectangular dimensions only.. so you need to pass your mouse point as x1,y1 and x1+width, y1+height as RECT dimensions.
(x1,y1,x1+width,y1+height) are your RECT dimensions. Read above second comment.

MAHESH
Thanks, i will try. Could  you send to me a sample for above function? "CropBitmap(HBITMAP hbm, PRECT prc)"
and 2 parameters how to used it??
Once again, thanks.
for just display purpose you dont need CropBitmap. Only BitBlt() function is enough for you. I have just uploaded sample project with executable on following link.
In a dialog box bitmap will be displayed and when you click with mouse on it cropped bitmap will be display near original bitmap. You can change co-ordinates in BitBlt() function to change rectangular portion in bitmap.

http://s56.yousendit.com/d.aspx?id=0E4M7ZRYHX1AJ36UKM5UWME9ML   <== download from here

MAHESH
Hi, MAHESH
THanks so much !