Alternative Gif Control

User avatar
karinha
Posts: 4882
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Alternative Gif Control

Post by karinha »

Master Enrico, me genera este error.

Code: Select all

ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
³ FiveWin for xHarbour 17.01 - Jan. 2017          xHarbour development power ³Ü
³ (c) FiveTech 1993-2017 for Microsoft Windows 9X/NT/200X/ME/XP/Vista/7/8/10 ³Û
ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙÛ
ÿ ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
Compiling...
xHarbour 1.2.3 Intl. (SimpLex) (Build 20170215)
Copyright 1999-2017, http://www.xharbour.org http://www.harbour-project.org/
Compiling 'testgif7.prg' and generating preprocessed output to 'testgif7.ppo'...

Done.

Lines 164, Functions/Procedures 7, pCodes 950
Embarcadero C++ 7.30 for Win32 Copyright (c) 1993-2017 Embarcadero Technologies, Inc.
testgif7.c:

Warning W8022 c:\bcc73\include\windows\sdk\GdiplusHeaders.h 650: 'Bitmap::Clone(const Rect &,int)' hides virtual function 'Image::Clone()'
Error E2268 testgif7.prg 248: Call to undefined function 'hb_storvni' in function HB_FUN_GDIPLUSIMAGEGETFRAMEDIMENSIONS()

*** 1 errors in Compile ***
* Linking errors *
 
Este ejemplo, también genera el mismo error.

http://amicoperry.altervista.org/data/gif.prg

Regards, saludos.
João Santos - São Paulo - Brasil
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Alternative Gif Control

Post by Enrico Maria Giordano »

Please put hb_storvni() in your sample as the following extract :

Code: Select all

using namespace Gdiplus;


void hb_storvni( int iValue, int iParam, int iIndex )
{
   hb_storni( iValue, iParam, iIndex );
}

HB_FUNC( GDIPLUSIMAGEFROMFILE )
EMG
marca
Posts: 104
Joined: Mon Aug 13, 2007 5:22 pm
Location: Brazil
Contact:

Re: Alternative Gif Control

Post by marca »

Enrico Maria Giordano wrote:Please put hb_storvni() in your sample as the following extract :

Code: Select all

using namespace Gdiplus;


void hb_storvni( int iValue, int iParam, int iIndex )
{
   hb_storni( iValue, iParam, iIndex );
}

HB_FUNC( GDIPLUSIMAGEFROMFILE )
EMG

Já com a mudança da este outro erro
Com o fonte novo

┌────────────────────────────────────────────────────────────────────────────┐
│ FiveWin for xHarbour 14.04 - Apr. 2014 xHarbour development power │▄
│ (c) FiveTech, 1993-2014 for Microsoft Windows 9X/NT/200X/ME/XP/Vista/7/8 │█
└────────────────────────────────────────────────────────────────────────────┘█
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
Compiling...
xHarbour 1.2.3 Intl. (SimpLex) (Build 20150518)
Copyright 1999-2015, http://www.xharbour.org http://www.harbour-project.org/
Compiling 'sv_gifs.prg' and generating preprocessed output to 'sv_gifs.ppo'...
Generating C source output to 'sv_gifs.c'...
Done.
Lines 169, Functions/Procedures 7, pCodes 945
Embarcadero C++ 7.00 for Win32 Copyright (c) 1993-2015 Embarcadero Technologies,
Inc.
sv_gifs.c:
Warning W8022 c:\Language\Borland\include\windows\sdk\GdiplusHeaders.h 636: 'Bit
map::Clone(const Rect &,int)' hides virtual function 'Image::Clone()'
Turbo Incremental Link 6.70 Copyright (c) 1997-2014 Embarcadero Technologies, In
c.
Error: Unresolved external '_HB_FUN_GDIBMP' referenced from C:\LANGUAGE\FWH\SAMP
LES\SV_GIFS.OBJ
Error: Unable to perform link
* Linking errors *
Marcelo Ferro da Silveira
Fwh14.04/xHarbour 1.2.3 Simplex / Bcc582 / Pelles 8
SqlLib /xMate/WS
User avatar
karinha
Posts: 4882
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Alternative Gif Control

Post by karinha »

Yes!! Perfecto Enrico, many thanks!

Image

Code: Select all

#include "fivewin.ch"

********** TEST CODE **********
proc main
    LOCAL oWnd, oGif
    DEFINE DIALOG oWnd TITLE "3D objects"
    oGif := GifControl():New(10,10,oWnd,,,"segu0020.gif")
    oGif := GifControl():New(10,100,oWnd,100,100,"TEST_GIF")
    oGif := GifControl():New(10,200,oWnd,,,"TEST_GIF")
    oGif:lUseDoubleBuffer := .T. // necessary for transparent gif
    ACTIVATE DIALOG oWnd
*******************************

********* GifControl **********
#define COLOR_BTNFACE   15
#define SRCCOPY         0xCC0020

class GifControl FROM TControl
    CLASSDATA lRegistered AS LOGICAL
    DATA oImage
    DATA hGlobal //used in case of load from resource
    DATA aFrameLen
    DATA oTimer
    DATA nCurrFrame
    DATA lUseDoubleBuffer INIT .F.

    METHOD New( nRow, nCol, oWnd, nWidth, nHeight, szFileName ) CONSTRUCTOR
    METHOD Display() INLINE ::BeginPaint(),::Paint(),::EndPaint(),0
    METHOD Paint()
    METHOD Initiate( hDlg )

    METHOD ChangeFrame()

    METHOD Destroy()
endclass

METHOD New( nRow, nCol, oWnd, nWidth, nHeight, szFileName, nClrPane ) class GifControl
    ::oImage := GDIBmp():New()
    if file(szFileName)
        ::oImage:hBmp := GDIPlusImageFromFile(szFileName)
    else
        ::hGlobal := CopyResourceInGlobal(GetResources(),szFileName, 10)
        ::oImage:hBmp := GDIPlusImageFromGlobal(::hGlobal)
    endif

    ::aFrameLen := GdiPlusImageGetFrameDimensions(::oImage:hBmp)

    DEFAULT nRow := 10, nCol := 10, oWnd := GetWndDefault()
    DEFAULT nWidth := ::oImage:GetWidth()-1
    DEFAULT nHeight := ::oImage:GetHeight()-1


    ::oWnd := oWnd
    ::nId       := ::GetNewId()
    ::nStyle    := nOR( WS_CHILD, WS_VISIBLE, WS_TABSTOP )
    ::nTop    := nRow
    ::nLeft  := nCol
    ::nBottom  := ::nTop + nHeight - 1
    ::nRight    := ::nLeft + nWidth

    if empty(nClrPane)
        ::nClrPane := iif(Upper( oWnd:Classname() ) != "TWINDOW",;
                                GetSysColor( COLOR_BTNFACE ),;
                                oWnd:nClrPane)
    endif


    ::Register( nOR( CS_VREDRAW, CS_HREDRAW ) )
    ::oBrush    := TBrush():New( , ::nClrPane )


    ::nCurrFrame := -1
   if ! Empty( oWnd:hWnd )
      ::Create( )
      oWnd:AddControl( Self )
      ::ChangeFrame()
   else
      oWnd:DefControl( Self )
      // In this case?
   endif

return Self

METHOD Initiate( hDlg ) class GifControl

   ::Super:Initiate( hDlg )

   ::ChangeFrame()

return nil


METHOD Destroy() class GifControl
    ::Super:Destroy()
    if .not. empty(::hGlobal)
        GlobalFree(::hGlobal)
        ::hGlobal:=nil
    endif
    if .not. empty(::oImage)
        ::oImage:Destroy()
    endif
    if .not. empty(::oTimer)
        ::oTimer:End()
    endif
return nil

METHOD Paint() class GifControl
    local aRect := GetClientRect( ::hWnd )
    local hDCMem, hBmpMem
    local hOldBmp
    LOCAL g

    if ::lUseDoubleBuffer
        hDCMem  = CreateCompatibleDC( ::hDC )
        hBmpMem = CreateCompatibleBitmap( ::hDC, aRect[ 4 ], aRect[ 3 ] )
        hOldBmp = SelectObject( hDCMem, hBmpMem )
        g := Graphics():New(hDCMem)

        FillRect( hDCMem, aRect, ::oBrush:hBrush )

    else
        g := Graphics():New(::hDC)
    endif

    g:DrawImage(::oImage,0,0,aRect[ 4 ], aRect[ 3 ] )
    g:Destroy()

    if ::lUseDoubleBuffer
        BitBlt( ::hDC, 0, 0, aRect[4], aRect[3], hDCMem, 0, 0, SRCCOPY )
        SelectObject( hDCMem, hOldBmp )
        DeleteObject( hBmpMem )
        DeleteDC( hDCMem )
    endif

return nil

METHOD ChangeFrame() class GifControl
    LOCAL cS := Self
    ::nCurrFrame++
    //? ::nCurrFrame
    if empty(::aFrameLen)
        return nil
    endif
    if ::nCurrFrame == len(::aFrameLen)
        ::nCurrFrame := 0
    endif
    GdiPlusImageSelectActiveFrame(::oImage:hBmp,::nCurrFrame)

    if empty(::oTimer)
        DEFINE TIMER ::oTimer ;
                     INTERVAL ::aFrameLen[::nCurrFrame+1] ;
                     ACTION cS:ChangeFrame() ;
                     OF Self
    else
        ::oTimer:DeActivate()
    endif
    ::oTimer:nInterval := ::aFrameLen[::nCurrFrame+1]
    ::oTimer:Activate()

    ::Refresh(.F.)

return nil

#pragma BEGINDUMP
#include <hbapi.h>
#include <Windows.h>
#include <gdiplus.h>
using namespace Gdiplus;

// Enrico Maria Giordano Escribio - para xHarbour and BCC73
void hb_storvni( int iValue, int iParam, int iIndex )
{
   hb_storni( iValue, iParam, iIndex );
}

HB_FUNC( GDIPLUSIMAGEFROMFILE )
{
    wchar_t *cFileName = hb_mbtowc( hb_parc(1) );
    Image* pImage =  Image::FromFile(cFileName);
    hb_xfree( cFileName );
    hb_retptr(pImage);
}

HB_FUNC( COPYRESOURCEINGLOBAL )
{
    HINSTANCE hInst = ( HINSTANCE ) hb_parnl( 1 );

    HRSRC hResource = FindResource(hInst, hb_parc(2), MAKEINTRESOURCE( hb_parni( 3 ) ));
    if (!hResource) { hb_ret(); return; }

    DWORD imageSize = SizeofResource(hInst, hResource);
    if (!imageSize) { hb_ret(); return; }


    const void* pResourceData = LockResource(LoadResource(hInst, hResource));
    if (!pResourceData) { hb_ret(); return; }

    HANDLE hBuffer  = GlobalAlloc(GMEM_MOVEABLE, imageSize);
    if (hBuffer)
    {
        void* pBuffer = GlobalLock(hBuffer);
        if (pBuffer)
        {
            memcpy(pBuffer, pResourceData, imageSize);
            GlobalUnlock(hBuffer);
        }
    }
#ifndef _WIN64
    hb_retnl((long)hBuffer);
#else
   hb_parnll((long long)hBuffer);
#endif
}


HB_FUNC( GDIPLUSIMAGEFROMGLOBAL )
{
#ifndef _WIN64
    HGLOBAL hBuffer = ( HGLOBAL ) hb_parnl( 1 );
#else
    HGLOBAL hBuffer = ( HGLOBAL ) hb_parnll( 1 );
#endif
    IStream* pStream = NULL;
    Image* pImage = 0;
    if (CreateStreamOnHGlobal(hBuffer, TRUE, &pStream) == S_OK)
    {
            pImage = Image::FromStream(pStream);
            pStream->Release();
    }
    hb_retptr(pImage);
}

HB_FUNC( GDIPLUSIMAGEGETFRAMEDIMENSIONS )
{
    Image* pImage = (Image*)hb_parptr(1);
    UINT nFrame = pImage->GetFrameDimensionsCount();
    GUID g;
    if(nFrame == 0)
    {
        hb_ret();
        return;
    }
    pImage->GetFrameDimensionsList(&g,1);
    nFrame = pImage->GetFrameCount(&g);
    hb_reta(nFrame);

    UINT nSize = pImage->GetPropertyItemSize(PropertyTagFrameDelay);
    PropertyItem* pPropertyItem = (PropertyItem*) malloc(nSize);
    pImage->GetPropertyItem(PropertyTagFrameDelay, nSize, pPropertyItem);
    for(UINT i=0;i<nFrame;i++)
    {
        hb_storvni( ((UINT*)pPropertyItem[0].value)[i]  * 10 , -1, i+1 );
    }
    free(pPropertyItem);
}

HB_FUNC( GDIPLUSIMAGESELECTACTIVEFRAME )
{
    Image* pImage = (Image*)hb_parptr(1);
    GUID g = FrameDimensionTime;
    pImage->SelectActiveFrame(&g, hb_parni(2));
    hb_ret();
}

HB_FUNC( MYDRAW )
{
    Graphics g((HDC)hb_parnl(1));
    Image* i = (Image*)hb_parptr(2);
    g.DrawImage(i,0,0,i->GetWidth(),i->GetHeight());
}


#pragma ENDDUMP

/*  // comments
#pragma BEGINDUMP

#include <hbapi.h>

void hb_storvni( int iValue, int iParam, int iIndex )
{
   hb_storni( iValue, iParam, iIndex );
}

#pragma ENDDUMP
*/
 

Regards, saludos.
João Santos - São Paulo - Brasil
marca
Posts: 104
Joined: Mon Aug 13, 2007 5:22 pm
Location: Brazil
Contact:

Re: Alternative Gif Control

Post by marca »

Com a minha versão 14.04 do Five não funciona da o erro que mencionei.
Marcelo Ferro da Silveira
Fwh14.04/xHarbour 1.2.3 Simplex / Bcc582 / Pelles 8
SqlLib /xMate/WS
AntoninoP
Posts: 347
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy
Contact:

Re: Alternative Gif Control

Post by AntoninoP »

Very good people!
maybe the xHarbour can be under ifdef:

Code: Select all

#ifdef __XHARBOUR__

// Enrico Maria Giordano -  xHarbour and BCC73
void hb_storvni( int iValue, int iParam, int iIndex )
{
   hb_storni( iValue, iParam, iIndex );
}

#endif
For complete the example you can include the resource file: http://amicoperry.altervista.org/data/gif.rc

Code: Select all

#include <windows.h>

TEST_GIF 10 "Scrivendo.gif"
and the image http://amicoperry.altervista.org/data/Scrivendo.gif
Image

:wink:
User avatar
karinha
Posts: 4882
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Alternative Gif Control

Post by karinha »

Perfect Antonio. Thanks.
João Santos - São Paulo - Brasil
Post Reply