//----------------------------------------------------------------------------//
METHOD LButtonDown( nRow, nCol, nFlags ) CLASS TImage
if ::bLClicked != nil
Eval( ::bLClicked, nRow, nCol, nFlags )
else
::lBoxDraw = .t.
::nBoxTop = nRow
::nBoxLeft = nCol
::nBoxBottom = nRow
::nBoxRight = nCol
::Capture()
::DrawBox()
endif
return nil
//----------------------------------------------------------------------------//
METHOD MouseMove( nRow, nCol, nFlags ) CLASS TImage
if ::lBoxDraw
::DrawBox()
::nBoxBottom = nRow
::nBoxRight = nCol
::DrawBox()
endif
return Super:MouseMove( nRow, nCol, nFlags )
//----------------------------------------------------------------------------//
METHOD LButtonUp( nRow, nCol, nFlags ) CLASS TImage
if ::lBoxDraw
::DrawBox()
::lBoxDraw = .f.
ReleaseCapture()
// ::nWidth := ::nBoxRight - ::nBoxLeft
// ::nHeight := ::nBoxBottom - ::nBoxTop
Super:ScrollAdjust()
Super:refresh( .t. )
endif
return nil
#pragma BEGINDUM
HB_FUNC( DRAWFOCUSRECT )
{
RECT rc;
rc.top = hb_parni( 2, 1 );
rc.left = hb_parni( 2, 2 );
rc.bottom = hb_parni( 2, 3 );
rc.right = hb_parni( 2, 4 );
hb_retl( DrawFocusRect( (HDC) hb_parnl( 1 ), &rc ) );
}
#pragma ENDDUMP
WaitRun('nconvert -out bmp -crop ' + STR(x1) + STR(y1) + STR(x2-x1+1) + STR(y2-y1+1) + '-quiet -o Recorte.bmp "FotoOrig.bmp"', 0)
function CopiaRect( oWnd, aRect )
local hBmp := WndCopy4( oWnd:hWnd, aRect )
DibWrite( "screen.bmp", DibFromBitmap( hBmp ) )
DeleteObject( hBmp )
return nil
#pragma BEGINDUMP
#include "windows.h"
#include "hbapi.h"
HB_FUNC( WNDCOPY4 )
{
HWND hWnd = ( HWND ) hb_parnl( 1 );
HDC hDC = GetWindowDC( hWnd );
int x = hb_parni( 2, 2 )+1;
int y = hb_parni( 2, 1 )+1;
int cx = hb_parni( 2, 4 ) - x-2;
int cy = hb_parni( 2, 3 ) - y-2;
HDC hMemDC;
HBITMAP hBitmap, hOldBmp;
hMemDC = CreateCompatibleDC( hDC );
hBitmap = CreateCompatibleBitmap( hDC, cx, cy );
hOldBmp = ( HBITMAP ) SelectObject( hMemDC, hBitmap );
StretchBlt(hMemDC, 0, 0, cx, cy, hDC, x, y,cx, cy, SRCCOPY );
SelectObject( hMemDC, hOldBmp );
DeleteDC( hMemDC );
ReleaseDC( hWnd, hDC );
hb_retnl( (LONG ) hBitmap );
}
#pragma ENDDUMP
Function SaveImage( cFile, nFormat, nFlag )
local lOk
local hDib
// 0 -> Bmp
// 2 -> Jpg
// 13 -> Png
DEFAULT nFormat := fiGetFileType( cFile, 0 )
hDib := fiLoad( nFormat, cFile, 0 )
if hDib == 0
MsgStop( "No image loaded" )
return nil
endif
lOk := fiSave( nFormat, hDib, cFile, nFlag )
if !lOk
MsgInfo( "Can't not save file" )
endif
return Nil
DLL32 STATIC FUNCTION FILOAD( nFormat AS LONG, cFileName AS LPSTR,nFlags AS LONG ) AS LONG;
PASCAL FROM "_FreeImage_Load@12" LIB hLib
DLL32 STATIC FUNCTION FIGETFILETYPE( cFileName AS LPSTR, nSize AS LONG )AS LONG;
PASCAL FROM "_FreeImage_GetFileType@8" LIB hLib
DLL32 STATIC FUNCTION FISAVE( nFormat AS LONG, hDib AS LONG, cFileName AS LPSTR, nFlags AS LONG ) AS BOOL;
PASCAL FROM "_FreeImage_Save@16" LIB hLib
Return to FiveWin para Harbour/xHarbour
Users browsing this forum: Google [Bot] and 23 guests