Bug in ResizeImg()

Bug in ResizeImg()

Postby Enrico Maria Giordano » Wed Oct 28, 2015 2:22 pm

The result of ResizeImg() is slightly different in width and height if compared with ResizeBmp() and PalBmpDraw().

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

Re: Bug in ResizeImg()

Postby Marco Turco » Wed Oct 28, 2015 2:47 pm

Is it related to last FWH build 4 ?
Best Regards,

Marco Turco
SOFTWARE XP LLP
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Re: Bug in ResizeImg()

Postby Enrico Maria Giordano » Wed Oct 28, 2015 3:01 pm

Marco,

no, it was there in the previous builds too.

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

Re: Bug in ResizeImg()

Postby Enrico Maria Giordano » Wed Oct 28, 2015 3:51 pm

Unfortunately, there is no source code for ResizeImg() so I can't try to fix the problem. :-(

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

Re: Bug in ResizeImg()

Postby Antonio Linares » Wed Oct 28, 2015 7:17 pm

Enrico,

I send you its source code by email, thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42203
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bug in ResizeImg()

Postby Enrico Maria Giordano » Wed Oct 28, 2015 7:20 pm

Antonio,

thank you. I'll do some experiment with it.

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

Re: Bug in ResizeImg()

Postby Enrico Maria Giordano » Wed Oct 28, 2015 7:31 pm

Antonio,

found! Replace

Code: Select all  Expand view  RUN
      iRateW     = ( DOUBLE ) iNewWidth  / ( DOUBLE ) bm.bmWidth  * 100 + 1;
       iRateH     = ( DOUBLE ) iNewHeight / ( DOUBLE ) bm.bmHeight * 100 + 1;
 


with

Code: Select all  Expand view  RUN
      iRateW     = ( DOUBLE ) iNewWidth  / ( DOUBLE ) bm.bmWidth  * 100;
       iRateH     = ( DOUBLE ) iNewHeight / ( DOUBLE ) bm.bmHeight * 100;


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

Re: Bug in ResizeImg()

Postby Enrico Maria Giordano » Wed Oct 28, 2015 7:46 pm

I spoke too fast. It GPFs, I don't know why. I continue to experiment...

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

Re: Bug in ResizeImg()

Postby Enrico Maria Giordano » Wed Oct 28, 2015 7:51 pm

It seems to work in this form:

Code: Select all  Expand view  RUN
      iRateW     = ( DOUBLE ) iNewWidth  / ( DOUBLE ) bm.bmWidth  * 100 + 0.9;
       iRateH     = ( DOUBLE ) iNewHeight / ( DOUBLE ) bm.bmHeight * 100 + 0.9;


Please check.

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

Re: Bug in ResizeImg()

Postby Antonio Linares » Wed Oct 28, 2015 10:07 pm

Enrico,

Could you please provide an example to test it ? thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42203
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bug in ResizeImg()

Postby Enrico Maria Giordano » Wed Oct 28, 2015 10:59 pm

Here it is:

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


FUNCTION MAIN()

    TEST( .T. )

    TEST( .F. )

    RETURN NIL


STATIC FUNCTION TEST( lImg )

    LOCAL oDlg

    DEFINE DIALOG oDlg;
           STYLE NOR( WS_POPUP, WS_DLGFRAME, DS_MODALFRAME );
           SIZE 800, 600

    ACTIVATE DIALOG oDlg;
             ON PAINT DRAWIMG( "c:\fwh\bitmaps\magic.bmp", hDC, oDlg:nWidth, oDlg:nHeight, lImg );
             CENTER

    RETURN NIL


STATIC FUNCTION DRAWIMG( cFile, hDC, nWidth, nHeight, lImg )

    LOCAL hImg := LOADIMG( cFile )

    LOCAL hImg2

    IF lImg
        hImg2 = RESIZEIMG( hImg, nWidth, nHeight )
    ELSE
        hImg2 = RESIZEBMP( hImg, nWidth, nHeight )
    ENDIF

    ABPAINT( hDC, 0, 0, hImg2, 255 )

    DELETEOBJECT( hImg2 )
    DELETEOBJECT( hImg )

    RETURN NIL


STATIC FUNCTION LOADIMG( cFile )

    IF !FILE( cFile )
        RETURN 0
    ENDIF

    RETURN GDIP_IMAGEFROMFILE( cFile, .T. )


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

Re: Bug in ResizeImg()

Postby Enrico Maria Giordano » Thu Oct 29, 2015 11:23 am

Another request. :-)

ResizeImg() is a bit slower, probably due to the two nested loops involved. How to speed it up?

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

Re: Bug in ResizeImg()

Postby Antonio Linares » Thu Oct 29, 2015 12:50 pm

Enrico,

Do you need to resize the bitmap or simply paint it larger ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42203
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bug in ResizeImg()

Postby Enrico Maria Giordano » Thu Oct 29, 2015 1:09 pm

Antonio,

yes, paint it larger (or smaller). But ABPaint() doesn't support resize.

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

Re: Bug in ResizeImg()

Postby Antonio Linares » Thu Oct 29, 2015 1:14 pm

Enrico,

Not sure if we can speed up the loop
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42203
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 81 guests