by RAMESHBABU » Sat Apr 01, 2006 2:47 am
Mr.Rafael
This is the working sample to Crop a Bitmap to the required size.
This program is simplified version of "TESTBMP.PRG" to demonstrate
your particular requirement.
Regards,
- Ramesh Babu P
#include "Fivewin.ch"
static bmpFish, aCoors := {10,10,135,240} // Your Coordinates
FUNCTION main()
local oDlg
local n := 1
#ifndef __CLIPPER__
SET RESOURCES TO "Fishes32.dll" // 32 bits DLL version
#else
SET RESOURCES TO "Fishes16.dll" // 16 bits DLL version for Clipper users
#endif
DEFINE DIALOG oDlg RESOURCE "Fish"
REDEFINE BITMAP bmpFish ID 110 OF oDlg NAME "Fish1"
*bmpFish:bLDblClick = { | nRow, nCol, nFlags | ;
* MsgInfo( "DblClick on the bitmap" ) }
bmpFish:bLDblClick = { ||Crop(bmpfish, aCoors)}
REDEFINE BUTTON ID 120 OF oDlg ;
ACTION If( n > 1, bmpFish:SetBMP( "Fish" + AllTrim( Str( --n ) ) ), ;
Tone( 956, 2 ) )
REDEFINE BUTTON ID 130 OF oDlg ;
ACTION If( n < 6, bmpFish:SetBMP( "Fish" + AllTrim( Str( ++n ) ) ), ;
Tone( 956, 2 ) )
ACTIVATE DIALOG oDlg CENTERED
return nil
*******************************************************************************
*** FUNCTION Crop(oBmp,aCoors) to Crop the Bitmap to the required Coordinates ***
*******************************************************************************
FUNCTION Crop(oBmp, aCoors)
oBmp:nTop := aCoors[1]
oBmp:nLeft := aCoors[2]
oBmp:nBottom := aCoors[3]
oBmp:nRight := aCoors[4]
oBmp:Box(oBmp:nTop, oBmp:nLeft, oBmp:nBottom, oBmp:nRight)
DibWrite( "crop.bmp", DibFromBitmap( wnd_bitmap( oBmp:hWnd,;
oBmp:nTop, oBmp:nLeft, oBmp:nBottom+1, oBmp:nRight+1 ) ) )
oBmp:LoadBMP("crop.bmp")
oBmp:Refresh()
// ERASE crop.bmp
RETURN nil
**********