Bug in GradientFill()?

Bug in GradientFill()?

Postby Enrico Maria Giordano » Sun Feb 07, 2010 11:20 am

In the following sample you will see that there is something strange in how GradientFill() paint the gradient when nPos is greater than 0.5:

Code: Select all  Expand view
#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg, oSay

    DEFINE DIALOG oDlg

    @ 1, 1 SAY oSay PROMPT "";
           SIZE 100, 20

    @ 3, 1 BUTTON "Test";
           ACTION TEST( oSay )

    ACTIVATE DIALOG oDlg;
             CENTER

    RETURN NIL


STATIC FUNCTION TEST( oSay )

    LOCAL i, j

    FOR i = 1 TO 3
        FOR j = 0 TO 100
            GRADIENTFILL( oSay:GetDC(), 0, 0, oSay:nHeight, oSay:nWidth, ACLRGRAD( j ), .F. )

            oSay:ReleaseDC()

            INKEY( 0.01 )

            SYSREFRESH()
        NEXT
    NEXT

    RETURN NIL


#define CLRSTA RGB( 4, 210, 10 )
#define CLREND RGB( 255, 255, 255 )


STATIC FUNCTION ACLRGRAD( nPos )

    LOCAL aClr

    IF nPos = 0
        aClr = { { 1, CLREND, CLRSTA } }
    ELSEIF nPos = 100
        aClr = { { 1, CLRSTA, CLREND } }
    ELSE
        aClr = { { nPos / 100, CLRSTA, CLREND }, { ( 100 - nPos ) / 100, CLREND, CLRSTA } }
    ENDIF

    RETURN aClr


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8570
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in GradientFill()?

Postby Daniel Garcia-Gil » Sun Feb 07, 2010 3:37 pm

Hello Enrico

yes, is a Gradient function bug, now is solved

the problem come when the difference between top, bottom or left, right is over 100 and first gradient is over 50%

please test now the sample with the bug fixed

http://www.sitasoft.com/fivewin/test/grafill1.zip
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: Bug in GradientFill()?

Postby Daniel Garcia-Gil » Sun Feb 07, 2010 3:57 pm

Hello Enrico...

i made some change in TProgress class, maybe is very usefull for you in this case

this a sample:

http://www.sitasoft.com/fivewin/test/progres2.zip
Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

   local oDlg, oProg1, oProg2
   
   DEFINE DIALOG oDlg TITLE "Progress Bars"
   
   @ 1, 1 PROGRESS oProg1 SIZE 80, 12 MARQUEE

   @ 1, 20 PROGRESS oProg2 SIZE 12, 50 VERTICAL
   
   @ 3,  9 BUTTON "Ok" ACTION ( oProg1:SetMarquee( .T. ), Increase( oProg1, oProg2 ) )
   
   oDlg:bStart = { || Increase( oProg1, oProg2 ) }
   
   ACTIVATE DIALOG oDlg CENTER ;
      ON INIT ( oProg1:SetRange( 0, 100 ), oProg1:SetStep( 1 ),;
                oProg2:SetRange( 0, 100 ), oProg2:SetStep( 1 ) )
   
return nil  

function Increase( oProg1, oProg2 )

   local n

   for n = 1 to 111
      // oProg1:StepIt()
      // oProg2:StepIt()
      oProg1:SetPos( n )
      oProg2:SetPos( n )
      if n = 55
         oProg1:SetMarquee( .F. )
      endif
      Sleep( 50 )
      SysRefresh()
   next
   
return nil      



i will explain for other user too

open file: TProgress.prg
after
Code: Select all  Expand view
#define PBM_GETPOS        1032

add
Code: Select all  Expand view
#define PBM_SETMARQUEE    1034


add new method
Code: Select all  Expand view
METHOD SetMarquee( lOnOff ) INLINE __ChangeStyleWindow( ::hWnd, PBM_SETMARQUEE, , lOnOff )


the function __ChangeStyleWindow is same provided by: Hernan Diego Ceccarelli ( viewtopic.php?p=93212#p93212 ) thank Hernan

Add new parameter METHOD New
lMarquee
Code: Select all  Expand view
METHOD New( nTop, nLeft, oWnd, nPos, nClrFore, nClrBack, lPixel,;
            lDesign, nWidth, nHeight, cMsg, lVertical, lMarquee ) CLASS TProgress


locate in METHOD New
Code: Select all  Expand view
          nPos     := 0, lVertical := .f.

replace with
Code: Select all  Expand view
          nPos     := 0, lVertical := .f.,;
           lMarquee := .F.

locate in METHOD New
Code: Select all  Expand view
  ::nStyle    = nOR( WS_CHILD, WS_VISIBLE,;
                      If( lDesign, WS_CLIPSIBLINGS, 0 ),;
                      If( lVertical, PBS_VERTICAL, 0 ), WS_TABSTOP )

replace with
Code: Select all  Expand view
  ::nStyle    = nOR( WS_CHILD, WS_VISIBLE,;
                      If( lDesign, WS_CLIPSIBLINGS, 0 ),;
                      If( lVertical, PBS_VERTICAL, 0 ), WS_TABSTOP,;
                      If( lMarquee, PBM_SETMARQUEE, 0 ) )


Open file fivewin.ch
locate and replace @ nRow, nCol PROGRESS command with
Code: Select all  Expand view
#xcommand @ <nRow>, <nCol> PROGRESS <oPrg> ;
             [ <of: OF, WINDOW, DIALOG> <oWnd> ] ;
             [ <pos: POS, POSITION> <nPos> ] ;
             [ COLOR <nClrFore> [,<nClrBack>] ] ;
             [ <pixel: PIXEL> ] ;
             [ <design: DESIGN> ] ;
             [ SIZE <nWidth>, <nHeight> ] ;
             [ MESSAGE <cMsg> ] ;
             [ <vert: VERTICAL> ] ;
             [ <lMar: MARQUEE> ];
       => ;
          <oPrg> := TProgress():New( <nRow>, <nCol>, <oWnd>, [<nPos>],;
                                     <nClrFore>, <nClrBack>, <.pixel.>, <.design.>,;
                                     <nWidth>, <nHeight>, <cMsg>, <.vert.>, <.lMar.> )
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: Bug in GradientFill()?

Postby Enrico Maria Giordano » Sun Feb 07, 2010 3:57 pm

Thank you. Can you show the fix to GradientFill(), please?

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8570
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in GradientFill()?

Postby Daniel Garcia-Gil » Sun Feb 07, 2010 4:00 pm

Hello enrico...

so sorry, i cant show the fix, because gradient is a fivewin internal function
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: Bug in GradientFill()?

Postby Enrico Maria Giordano » Sun Feb 07, 2010 4:04 pm

Ok, no problem. I can wait for the next FWH build.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8570
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in GradientFill()?

Postby Daniel Garcia-Gil » Sun Feb 07, 2010 4:13 pm

Enrico, did you tested tprogress change posted here??
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: Bug in GradientFill()?

Postby Enrico Maria Giordano » Sun Feb 07, 2010 4:15 pm

I tested your EXE and it's fine and very nice, thank you.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8570
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in GradientFill()?

Postby anserkk » Sun Feb 07, 2010 5:39 pm

Dear Mr.Daniel & Mr.EMG,

Do this TProgress fix solves the problem in Vista & Windows 7 when used along with the .Manifest file ?.

Regards
Anser
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Bug in GradientFill()?

Postby Daniel Garcia-Gil » Sun Feb 07, 2010 5:47 pm

Hello Anserkk

sorry, no, it only a new feature to tprogress class
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: Bug in GradientFill()?

Postby anserkk » Mon Feb 08, 2010 4:18 am

sorry, no, it only a new feature to tprogress class

Ok. Thank you for the information.

Regards
Anser
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Bug in GradientFill()?

Postby ukoenig » Mon Feb 08, 2010 10:07 pm

Hello Daniel,

does Your change in GradientFill solve this Problem as well ?
It is the same Result like in Enrico's example.

Image

Best Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Bug in GradientFill()?

Postby Daniel Garcia-Gil » Mon Feb 08, 2010 10:13 pm

Hello Uwe...

i think yes... :)
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: Bug in GradientFill()?

Postby Daniel Garcia-Gil » Mon Feb 08, 2010 10:25 pm

Hello Uwe.

it is a sample
Code: Select all  Expand view

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg, oSay

    DEFINE DIALOG oDlg size 400,400

    ACTIVATE DIALOG oDlg;
             CENTER;
             ON PAINT GradientFill( hDC, 0, 0, oDlg:nHeight, oDlg:nWidth, ;
                                   { { 0.5, 8388608,16117445 }, { 0.5, 16117445, 8388608 } } )

RETURN NIL
 


Image
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: Bug in GradientFill()?

Postby Enrico Maria Giordano » Tue Feb 09, 2010 9:28 am

One more bug. This sample GPFs because nSegments is zero (in Gradient()). That's because nSlice is a fractional number smaller than 1 (in GradientFill()):

Code: Select all  Expand view
#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg, oSay

    DEFINE DIALOG oDlg

    @ 1, 1 SAY oSay PROMPT "";
           SIZE 50, 20

    @ 3, 1 BUTTON "Test";
           ACTION TEST( oSay )

    ACTIVATE DIALOG oDlg;
             CENTER

    RETURN NIL


STATIC FUNCTION TEST( oSay )

    LOCAL i, j

    FOR i = 1 TO 3
        FOR j = 0 TO 100
            GRADIENTFILL( oSay:GetDC(), 0, 0, oSay:nHeight, oSay:nWidth, ACLRGRAD( j ), .F. )

            oSay:ReleaseDC()

            INKEY( 0.01 )

            SYSREFRESH()
        NEXT
    NEXT

    RETURN NIL


#define CLRSTA RGB( 4, 210, 10 )
#define CLREND RGB( 255, 255, 255 )


STATIC FUNCTION ACLRGRAD( nPos )

    LOCAL aClr

    IF nPos = 0
        aClr = { { 1, CLREND, CLRSTA } }
    ELSEIF nPos = 100
        aClr = { { 1, CLRSTA, CLREND } }
    ELSE
        aClr = { { nPos / 100, CLRSTA, CLREND }, { ( 100 - nPos ) / 100, CLREND, CLRSTA } }
    ENDIF

    RETURN aClr


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8570
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 33 guests