#include "FiveWin.ch"
#include "Image.ch"
//----------------------------------------------------------------------------//
function Main()
LOCAL oWnd, oImage
DEFINE WINDOW oWnd FROM 0, 0 TO 22, 60 ;
TITLE FWDESCRIPTION + " JPG,JIF,GIF,BMP,DIB,RLE,TGA,PCX support!"
@ 0, 0 IMAGE oImage SIZE 300, 300 OF oWnd SCROLL ADJUST
oImage:Progress( .f. )
@ 2, 56 BUTTON "Select Image" SIZE 100,20 OF oWnd ACTION GetImage( oImage )
@ 4, 56 BUTTON "Print" SIZE 100,20 OF oWnd ACTION PrintImage( oImage )
@ 6, 56 BUTTON "Copy" SIZE 100, 20 OF oWnd ;
ACTION oImage:CopyToClipboard()
@ 8, 56 BUTTON "Paste" SIZE 100, 20 OF oWnd ;
ACTION ( oImage:LoadFromClipboard(), oImage:Refresh() )
@ 10, 56 BUTTON "Save" SIZE 100, 20 OF oWnd ;
ACTION ( oImage:SaveImage( "SAVED.JPG", 2, 25 ), MsgInfo( "saved as saved.jpg" ) )
@ 12, 56 BUTTON "Exit" SIZE 100, 20 OF oWnd ACTION oWnd:End()
@ 20, 56 CHECKBOX oImage:lStretch PROMPT "Stretch" SIZE 100, 20 OF oWnd ;
ON CHANGE ( oImage:ScrollAdjust(), oImage:Refresh() )
ACTIVATE WINDOW oWnd ON DROPFILES TakeDrop( aFiles, oImage )
return nil
//----------------------------------------------------------------------------//
STATIC FUNCTION TakeDrop( aFiles, oImage )
LOCAL nPos
FOR nPos = 1 to Len( aFiles )
IF UPPER( RIGHT( aFiles[ nPos ], 3 ) ) == "JPG" .OR. UPPER( RIGHT( aFiles[ nPos ], 3 ) ) == "BMP" // etc.
oImage:LoadBmp( aFiles[ nPos ] )
EXIT
ENDIF
NEXT nPos
RETURN NIL
//----------------------------------------------------------------------------//
function GetImage( oImage )
local gcFile := cGetFile( "Bitmap (*.bmp)| *.bmp|" + ;
"DIB (*.dib)| *.dib|" + ;
"PCX (*.pcx)| *.pcx|" + ;
"JPEG (*.jpg)| *.jpg|" + ;
"GIF (*.gif)| *.gif|" + ;
"TARGA (*.tga)| *.tga|" + ;
"RLE (*.rle)| *.rle|" + ;
"All Files (*.*)| *.*" ;
,"Please select a image file", 4 )
if ! Empty( gcFile ) .and. File( gcFile )
oImage:LoadBmp( gcFile )
endif
return nil
//----------------------------------------------------------------------------//
function PrintImage( oImage )
local oPrn
PRINT oPrn NAME "Image Printing" PREVIEW
PAGE
oPrn:SayImage( 0, 0, oImage )
ENDPAGE
ENDPRINT
return nil
//----------------------------------------------------------------------------//
procedure AppSys // XBase++ requirement
return
//----------------------------------------------------------------------------//
#include "FiveWin.ch"
#include "Image.ch"
//----------------------------------------------------------------------------//
function Main()
LOCAL oDlg, oImage
DEFINE DIALOG oDlg FROM 0, 0 TO 22, 60 ;
TITLE FWDESCRIPTION + " JPG,JIF,GIF,BMP,DIB,RLE,TGA,PCX support!"
@ 0, 0 IMAGE oImage SIZE 150, 150 OF oDlg SCROLL ADJUST
oImage:Progress( .f. )
@ 1, 28 BUTTON "Select Image" SIZE 50, 10 OF oDlg ACTION GetImage( oImage )
@ 2, 28 BUTTON "Print" SIZE 50, 10 OF oDlg ACTION PrintImage( oImage )
@ 3, 28 BUTTON "Copy" SIZE 50, 10 OF oDlg ;
ACTION oImage:CopyToClipboard()
@ 4, 28 BUTTON "Paste" SIZE 50, 10 OF oDlg ;
ACTION ( oImage:LoadFromClipboard(), oImage:Refresh() )
@ 5, 28 BUTTON "Save" SIZE 50, 10 OF oDlg ;
ACTION ( oImage:SaveImage( "SAVED.JPG", 2, 25 ), MsgInfo( "saved as saved.jpg" ) )
@ 6, 28 BUTTON "Exit" SIZE 50, 10 OF oDlg ACTION oDlg:End()
@ 10, 28 CHECKBOX oImage:lStretch PROMPT "Stretch" SIZE 50, 10 OF oDlg ;
ON CHANGE ( oImage:ScrollAdjust(), oImage:Refresh() )
ACTIVATE DIALOG oDlg CENTER ON INIT SetDrop( oDlg, oImage )
return nil
//----------------------------------------------------------------------------//
STATIC FUNCTION SetDrop( oDlg, oImage )
DragAcceptFiles( oDlg:hWnd, .t. )
oDlg:bDropFiles = { | nRow, nCol, aFiles | TakeDrop( nRow, nCol, aFiles, oImage ) }
RETURN NIL
//----------------------------------------------------------------------------//
STATIC FUNCTION TakeDrop( nRow, nCol, aFiles, oImage )
LOCAL nPos
FOR nPos = 1 to Len( aFiles )
IF UPPER( RIGHT( aFiles[ nPos ], 3 ) ) == "JPG" .OR. UPPER( RIGHT( aFiles[ nPos ], 3 ) ) == "BMP" // etc.
oImage:LoadBmp( aFiles[ nPos ] )
EXIT
ENDIF
NEXT nPos
RETURN NIL
//----------------------------------------------------------------------------//
function GetImage( oImage )
local gcFile := cGetFile( "Bitmap (*.bmp)| *.bmp|" + ;
"DIB (*.dib)| *.dib|" + ;
"PCX (*.pcx)| *.pcx|" + ;
"JPEG (*.jpg)| *.jpg|" + ;
"GIF (*.gif)| *.gif|" + ;
"TARGA (*.tga)| *.tga|" + ;
"RLE (*.rle)| *.rle|" + ;
"All Files (*.*)| *.*" ;
,"Please select a image file", 4 )
if ! Empty( gcFile ) .and. File( gcFile )
oImage:LoadBmp( gcFile )
endif
return nil
//----------------------------------------------------------------------------//
function PrintImage( oImage )
local oPrn
PRINT oPrn NAME "Image Printing" PREVIEW
PAGE
oPrn:SayImage( 0, 0, oImage )
ENDPAGE
ENDPRINT
return nil
//----------------------------------------------------------------------------//
procedure AppSys // XBase++ requirement
return
//----------------------------------------------------------------------------//
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 85 guests