Using a slightly modified TestImage.prg from the \samples folder .. I am selecting an Image .. it Loads .. and I am asking if the User wants to Keep the selected File ( YesNo ) ..
In Order for the User to see the file the oImage:LoadBmp( gcFile ) has to load. The only way I could figure out how to Work the No Save .. was to Issue the oImage:Destroy() .. Which works.
When you go back in the same session and re-select another Image .. The oImage:LoadBmp( gcFile ) fails to load the new Image .. I am sure it has to do with the Destroy().
Is there a method I am missing in Timage or TBitmap Class that will allow me to just Nil out the oImage Object and Refresh it with a Blank screen ??
Thanks
Rick Lipkin
- Code: Select all Expand view RUN
#include "FiveWin.ch"
#include "Image.ch"
//----------------------------------------------------------------------------//
function Main()
LOCAL oDlg, oImage, saying, lSetAlpha := .t.
If .not. file("FreeImage.dll")
Saying := "Sorry .. FreeImage.DLL is not available"
MsgInfo( saying )
Return(.f.)
Endif
// setalpha( .f. )
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,oDlg )
@ 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, 26 CHECKBOX oImage:lStretch PROMPT "Stretch" SIZE 50, 10 OF oDlg ;
ON CHANGE ( oImage:ScrollAdjust(), oImage:Refresh() )
@ 11, 26 CHECKBOX lSetAlpha PROMPT "Set Alpha Channel" SIZE 80, 10 OF oDlg ;
ON CHANGE ( SetAlpha( lSetAlpha ), oImage:Refresh() )
ACTIVATE DIALOG oDlg CENTER
return nil
//----------------------------------------------------------------------------//
function GetImage( oImage,oDlg )
local nLen,nStart,cPic,cFileName
local gcFile,cOldFile
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 )
oDlg:ReFresh()
SysReFresh()
If rat( "\", gcFile ) > 0
nLen := len( gcFile)
nStart := rat( "\", gcFile )
cPic := substr( gcFile,nStart+1, (nLen-nStart))
Endif
Saying := "Are you SURE you want to Save this File"+chr(10)
Saying += cPic+" ?"
If MsgNoYes( saying )
Else
oImage:Destroy()
oDlg:ReFresh()
SysReFresh()
Endif
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
//------------------