FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour clear IMAGE
Posts: 1303
Joined: Tue Jul 21, 2009 08:12 AM
clear IMAGE
Posted: Thu Jul 18, 2013 08:28 AM
Hello,

I want to set a button (ID 102) to clear the Image:

Code (fw): Select all Collapse
   REDEFINE IMAGE  oBmpFoto1             ID 103 OF oFld:aDialogs[ 3 ] UPDATE ;
                                                FILENAME oData:FOTO  ;
                                                ON CLICK ( oData:FOTO := _CargaFoto (oBmpFoto1, oDlg)  ) ADJUST 

   REDEFINE BUTTON                       ID 101 OF oFld:aDialogs[ 3 ] ;
                                                ACTION ( oData:FOTO := _CargaFoto (oBmpFoto1, oDlg)  ) 

   REDEFINE BUTTON                       ID 102 OF oFld:aDialogs[ 3 ] ;
                                                ACTION ( oData:FOTO := "", alert(odata:foto), oBmpFoto1:Refresh(), oFld:Update(), oFld:Refresh(), oDlg:Refresh()  )



But despite I set oData:Foto to "" and I call refresh and update, the previous picture is still there, I need to remove it.

Maybe I miss something or it is a bug.

Thank you.
Muchas gracias. Many thanks.



Un saludo, Best regards,



Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producción]



Implementando MSVC 2010, FWH64 y ADO.



Abandonando uso xHarbour y SQLRDD.
Posts: 663
Joined: Mon Dec 05, 2005 11:22 PM
Re: clear IMAGE
Posted: Thu Jul 18, 2013 05:08 PM

I had the same problem in my imaging product. I got around it by creating a blank image "blank,jpg" and using it when there is no image wanted.

Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: clear IMAGE
Posted: Thu Jul 18, 2013 05:58 PM
Lucas

Here is a snipit of code I use for Images with some help and advice from our good friend Uwe.

Have a look at how the image is defined with oImage and bPainted then deleted with the function DelImage()

Rick Lipkin
Code (fw): Select all Collapse
// images

REDEFINE IMAGE oImage ID 701 FILENAME NIL of oUsers ;
         PIXEL  ADJUST BORDER

     oImage:bPainted := { |hDC| DRAW_IMG( oImage, hDC, cImage, cPicFileName ) }

REDEFINE GET oGET var cImage ID 706 of oUsers PICTURE "@!" READONLY // displays the filename only

REDEFINE BTNBMP oButt4 ID 702 of oUsers ;
         RESOURCE "ADD16","DADD16","DADD16" ;
         PROMPT "Import    " LEFT 2007;
         ACTION ( GetImage( @oImage,oRsPet,oUsers,@cImage,oGet,@cPicFileName ),;
                  _ChkButtons( cMode,oRsPet,oButt4,oButt5,oButt6,oButt7))

REDEFINE BTNBMP oButt5 ID 703 of oUsers ;
         RESOURCE "EDIT16","DEDIT16","DEDIT16" ;
         PROMPT "Export    " LEFT 2007;
         ACTION ( ExportImage( oRsPet,0 ) )

REDEFINE BTNBMP oButt6 ID 704 of oUsers ;
         RESOURCE "DELETE16","DDELETE16", "DDELETE16" ;
         PROMPT "Delete    " LEFT 2007;
         ACTION ( DelImage(@oImage,oRsPet,oUsers,oGet,@cImage,@cPicFileName ),;
                  _ChkButtons( cMode,oRsPet,oButt4,oButt5,oButt6,oButt7))

REDEFINE BTNBMP oButt7 ID 705 of oUsers ;
         RESOURCE "VIEW16","DVIEW16","DVIEW16" ;
         PROMPT "Print      " LEFT 2007;
         ACTION ( PrintImage( oRsPet,0 ) )

// end images

//------------- Image-Brush from Uwe ----------
Static FUNC Draw_Img( oImage, hDC, cImage, cPicFileName  )

LOCAL oBrush,cDefa
LOCAL aRect := GETCLIENTRECT( oImage:hWnd )

cDefa  := set(7)

If cPicFileName = " " // ad mode because blank .. cImage passed as is
Else
   cImage := cDefa+"\Pictures\"+alltrim( cImage )
Endif

// added for on paint
SysReFresh()

IF FILE( cImage )
    DEFINE IMAGE oBrush FILENAME cImage
    PalBmpDraw( hDC, 0, 0, oBrush:hBitmap, , aRect[4], aRect[3] )
    oBrush:End()
ENDIF

RETURN( NIL )

//----------------------------------------------------------------------------//
Static Func DelImage( oImage,oRsPet,oDlg,oGet,cImage,cPicFileName )

LOCAL Saying,cFILE,cDefa

cDefa := set(7)
cFile := oRsPet:Fields("PicFileName"):Value

If cFile = " " .or. empty( cFile )
   Saying := "Sorry .. there is no Image to Delete"
   MsgInfo( Saying )
   Return(.f.)
Endif

Saying := "Are you SURE you want to Delete this Image ?"+chr(10)
Saying += cFile

If MsgNoYes( Saying )

   Ferase(cDefa+"\Pictures\"+alltrim(cFile))
   cImage := " "
   oGet:Refresh()
   oImage:Refresh()
   oDlg:ReFresh()
   SysReFresh()

   cPicFileName := space(50)
   oRsPet:Fields("PicFileName"):Value := cPicFileName
   oRsPet:Update()

   SysReFresh()

Endif

Return(nil)
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: clear IMAGE
Posted: Thu Jul 18, 2013 06:14 PM
Mr Lucas

Let me try to make it simple for you.

#1. If you want to change the image with a new image file :
ACTION ( oData:foto := <newfilename>, oImage:LoadBmp( oData:foto ) )

#2. If you want to clear image
ACTION ( oData:foto := "", ClearImage( oImage ) )

I shall give you a function to ClearImage
Code (fw): Select all Collapse
function ClearImage( oBmp )

   WITH OBJECT oBmp
      PalBmpFree( :hBitmap, :hPalette )
      :hBitmap := :hPalette  := 0
      :cBmpFile := :cResName := nil
      :Refresh()
   END

return nil


We try to provide an appropriate method in the class in the next version.
Regards



G. N. Rao.

Hyderabad, India
Posts: 518
Joined: Fri Jun 29, 2012 12:49 PM
Re: clear IMAGE
Posted: Thu Jul 18, 2013 06:15 PM

Lucas;

Try this oBmpFoto1:LoadImage("nada")

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: clear IMAGE
Posted: Thu Jul 18, 2013 08:36 PM
elvira wrote:Lucas;

Try this oBmpFoto1:LoadImage("nada")

This also works. Giving a non-empty name, which is not an existing image file also works. This is a work around.
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: clear IMAGE
Posted: Sat Aug 03, 2013 02:11 PM

From FWH 13.07, we can use
oImg:Clear()

Regards



G. N. Rao.

Hyderabad, India

Continue the discussion