Hi, Mr. Antonio/Mr. Enrico
Can I use JPEG file for BRUSH ?
thank's
Regards
Areang
case cBmpFile != nil
if File( cBmpFile )
::hBitMap = ReadBitmap( 0, cBmpFile )
::hBrush = If( ::hBitmap != 0, CreatePatternBrush( ::hBitmap ), )
endif
#include "Fivewin.ch"
STATIC hLib
FUNCTION MAIN()
LOCAL oDlg, oBrush
DEFINE BRUSH oBrush FILENAME "test.jpg"
DEFINE DIALOG oDlg;
BRUSH oBrush
ACTIVATE DIALOG oDlg;
CENTER
RETURN NIL
#define CBM_INIT 4
#define DIB_RGB_COLORS 0
FUNCTION FILOADIMG( cFile )
LOCAL nFormat, hDib, hInfoH, hInfo, hBits, hWnd, hDC, hBmp
IF UPPER( CFILEEXT( cFile ) ) = "BMP"
RETURN READBITMAP( 0, cFile )
ENDIF
#ifdef __CLIPPER__
hLib = LOADLIB32( "freeimage.dll" )
#else
hLib = LOADLIBRARY( "freeimage.dll" )
#endif
if hLib <= 32
MsgStop( "Cannot load FreeImage.dll" )
return 0
endif
nFormat = FIGETFILETYPE( cFile, 0 )
hDib = FILOAD( nFormat, cFile, 0 )
hInfoH = FIGETINFOHEADER( hDib )
hInfo = FIGETINFO( hDib )
hBits = FIGETBITS( hDib )
hWnd = GETDESKTOPWINDOW()
#ifdef __CLIPPER__
hDC = GETDC32( hWnd )
#else
hDC = GETDC( hWnd )
#endif
hBmp = CREATEDIBITMAP( hDC, hInfoH, CBM_INIT, hBits, hInfo, DIB_RGB_COLORS )
#ifdef __CLIPPER__
RELEASEDC32( hWnd, hDC )
#else
RELEASEDC( hWnd, hDC )
#endif
FIUNLOAD( hDib )
#ifdef __CLIPPER__
FREELIB32( hLib )
#else
FREELIBRARY( hLib )
#endif
#ifdef __CLIPPER__
hBmp = NLOWORD( WOWHANDLE16( hBmp, 8 ) )
#endif
RETURN hBmp
FUNCTION FISAVEIMG( cSrcFile, cDstFile, nDstFormat, nQuality )
LOCAL nSrcFormat, hDib, hDib2, lOk
DEFAULT nQuality := 0
#ifdef __CLIPPER__
hLib = LOADLIB32( "freeimage.dll" )
#else
hLib = LOADLIBRARY( "freeimage.dll" )
#endif
nSrcFormat = FIGETFILETYPE( cSrcFile, 0 )
hDib = FILOAD( nSrcFormat, cSrcFile, 0 )
hDib2 = FICNV24( hDib )
lOk = FISAVE( nDstFormat, hDib2, cDstFile, nQuality )
FIUNLOAD( hDib )
FIUNLOAD( hDib2 )
#ifdef __CLIPPER__
FREELIB32( hLib )
#else
FREELIBRARY( hLib )
#endif
RETURN lOk
//----------------------------------------------------------------------------//
DLL32 STATIC FUNCTION FIGETFILETYPE( cFileName AS LPSTR, nSize AS LONG ) AS LONG;
PASCAL FROM "_FreeImage_GetFileType@8" LIB hLib
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 FISAVE( nFormat AS LONG, hDib AS LONG, cFileName AS LPSTR, nFlags AS LONG ) AS BOOL;
PASCAL FROM "_FreeImage_Save@16" LIB hLib
DLL32 STATIC FUNCTION FIUNLOAD( hDib AS LONG ) AS VOID;
PASCAL FROM "_FreeImage_Unload@4" LIB hLib
DLL32 STATIC FUNCTION FIGETINFOHEADER( hDib AS LONG ) AS LONG;
PASCAL FROM "_FreeImage_GetInfoHeader@4" LIB hLib
DLL32 STATIC FUNCTION FIGETINFO( hDib AS LONG ) AS LONG;
PASCAL FROM "_FreeImage_GetInfo@4" LIB hLib
DLL32 STATIC FUNCTION FIGETBITS( hDib AS LONG ) AS LONG;
PASCAL FROM "_FreeImage_GetBits@4" LIB hLib
DLL32 STATIC FUNCTION FICNV24( hDib AS LONG ) AS LONG;
PASCAL FROM "_FreeImage_ConvertTo24Bits@4" LIB hLib
DLL32 STATIC FUNCTION GETDC32( hWnd AS LONG ) AS LONG;
PASCAL FROM "GetDC" LIB "user32.dll"
DLL32 STATIC FUNCTION RELEASEDC32( hWnd AS LONG ) AS LONG;
PASCAL FROM "ReleaseDC" LIB "user32.dll"
DLL32 STATIC FUNCTION CREATEDIBITMAP( hDC AS LONG, hInfoH AS LONG, nFlags AS LONG, hBits AS LONG, hInfo AS LONG, nUsage AS LONG ) AS LONG;
PASCAL FROM "CreateDIBitmap" LIB "gdi32.dll"
DLL32 FUNCTION WOWHANDLE16( nHandle AS LONG, nHandleType AS LONG ) AS LONG;
PASCAL FROM "WOWHandle16" LIB "wow32.dll"
//----------------------------------------------------------------------------//
case cBmpFile != nil
if File( cBmpFile )
::hBitMap = FILoadImg( cBmpFile )
// ::hBitMap = ReadBitmap( 0, cBmpFile )
::hBrush = If( ::hBitmap != 0, CreatePatternBrush( ::hBitmap ), )
endif
fleal wrote:hi guys,
a question. Where's the freeimage.dll for xharbour or harbour ??
Thanks
Fernando
FUNCTION MAIN()
LOCAL oWnd, oBrush
DEFINE BRUSH oBrush FILENAME "xsnow.gif"
DEFINE WINDOW oWnd;
BRUSH oBrush
ACTIVATE WINDOW oWnd
RETURN NIL
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 87 guests