FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Bug in ResizeImg()
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Bug in ResizeImg()
Posted: Wed Oct 28, 2015 02:22 PM

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

EMG

Posts: 858
Joined: Fri Oct 07, 2005 12:00 PM
Re: Bug in ResizeImg()
Posted: Wed Oct 28, 2015 02:47 PM

Is it related to last FWH build 4 ?

Best Regards,



Marco Turco

SOFTWARE XP LLP
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bug in ResizeImg()
Posted: Wed Oct 28, 2015 03:01 PM

Marco,

no, it was there in the previous builds too.

EMG

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bug in ResizeImg()
Posted: Wed Oct 28, 2015 03:51 PM

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

EMG

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug in ResizeImg()
Posted: Wed Oct 28, 2015 07:17 PM

Enrico,

I send you its source code by email, thanks

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bug in ResizeImg()
Posted: Wed Oct 28, 2015 07:20 PM

Antonio,

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

EMG

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bug in ResizeImg()
Posted: Wed Oct 28, 2015 07:31 PM
Antonio,

found! Replace

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


with

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


EMG
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bug in ResizeImg()
Posted: Wed Oct 28, 2015 07:46 PM

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

EMG

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bug in ResizeImg()
Posted: Wed Oct 28, 2015 07:51 PM
It seems to work in this form:

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


Please check.

EMG
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug in ResizeImg()
Posted: 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
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bug in ResizeImg()
Posted: Wed Oct 28, 2015 10:59 PM
Here it is:

Code (fw): Select all Collapse
#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
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bug in ResizeImg()
Posted: 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

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug in ResizeImg()
Posted: 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
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bug in ResizeImg()
Posted: Thu Oct 29, 2015 01:09 PM

Antonio,

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

EMG

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug in ResizeImg()
Posted: Thu Oct 29, 2015 01:14 PM

Enrico,

Not sure if we can speed up the loop

regards, saludos

Antonio Linares
www.fivetechsoft.com