From 2f9333d29af9e199dfd7a8f1e262e7d71bf0634b Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Fri, 7 Jul 2017 15:58:49 +0000 Subject: [PATCH] EgtExecutor 1.8g1 : - aggiunta gestione immagini (inizialmente solo recupero dimensioni in pixel). --- DllGraphics.cpp | 26 ++++++++++++++---- DllGraphics.h | 2 ++ EXE_Image.cpp | 39 ++++++++++++++++++++++++++ EXE_Photo.cpp | 2 +- EgtExecutor.rc | Bin 15088 -> 15088 bytes EgtExecutor.vcxproj | 2 ++ EgtExecutor.vcxproj.filters | 6 ++++ LUA.h | 3 ++ LUA_Base.cpp | 4 +++ LUA_Image.cpp | 53 ++++++++++++++++++++++++++++++++++++ 10 files changed, 131 insertions(+), 6 deletions(-) create mode 100644 EXE_Image.cpp create mode 100644 LUA_Image.cpp diff --git a/DllGraphics.cpp b/DllGraphics.cpp index ddb32fe..0a7660e 100644 --- a/DllGraphics.cpp +++ b/DllGraphics.cpp @@ -38,6 +38,7 @@ static const char* EGR_GETEGRVERSION = "GetEGrVersion" ; static const char* EGR_SETEGRKEY = "SetEGrKey" ; static const char* EGR_CREATEEGRSCENE = "CreateEGrScene" ; static const char* EGR_CREATESCEEXECUTOR = "CreateSceExecutor" ; +static const char* EGR_CREATEEGRIMAGEMGR = "CreateEgrImageMgr" ; //----------------------------------------------------------------------------- @@ -90,7 +91,7 @@ IsLoadedGraphicsDll( void) void MySetEGrLogger( ILogger* pLogger) { - // verifico caricamento libreria MachMgr + // verifico caricamento libreria EgtGraphics if ( s_hEGr == nullptr) return ; // recupero funzione che imposta il logger @@ -105,7 +106,7 @@ MySetEGrLogger( ILogger* pLogger) const char* MyGetEGrVersion( void) { - // verifico caricamento libreria MachMgr + // verifico caricamento libreria EgtGraphics if ( s_hEGr == nullptr) return "" ; // recupero funzione che restituisce la versione della libreria @@ -120,7 +121,7 @@ MyGetEGrVersion( void) void MySetEGrKey( const string& sKey) { - // verifico caricamento libreria MachMgr + // verifico caricamento libreria EgtGraphics if ( s_hEGr == nullptr) return ; // recupero funzione che imposta i codici di protezione @@ -135,7 +136,7 @@ MySetEGrKey( const string& sKey) IEGrScene* MyCreateEGrScene( void) { - // verifico caricamento libreria MachMgr + // verifico caricamento libreria EgtGraphics if ( s_hEGr == nullptr) return nullptr ; // recupero funzione creazione oggetto @@ -150,7 +151,7 @@ MyCreateEGrScene( void) ISceExecutor* MyCreateSceExecutor( void) { - // verifico caricamento libreria MachMgr + // verifico caricamento libreria EgtGraphics if ( s_hEGr == nullptr) return nullptr ; // recupero funzione creazione oggetto @@ -160,3 +161,18 @@ MyCreateSceExecutor( void) return nullptr ; return pFun() ; } + +//----------------------------------------------------------------------------- +IEgrImageMgr* +MyCreateEgrImageMgr( void) +{ + // verifico caricamento libreria EgtGraphics + if ( s_hEGr == nullptr) + return nullptr ; + // recupero funzione creazione oggetto + typedef IEgrImageMgr* (* PF_CreateEgrImageMgr) ( void) ; + PF_CreateEgrImageMgr pFun = (PF_CreateEgrImageMgr)GetProcAddress( s_hEGr, EGR_CREATEEGRIMAGEMGR) ; + if ( pFun == nullptr) + return nullptr ; + return pFun() ; +} diff --git a/DllGraphics.h b/DllGraphics.h index 194f205..a2eadf7 100644 --- a/DllGraphics.h +++ b/DllGraphics.h @@ -18,6 +18,7 @@ class ILogger ; class IEGrScene ; class ISceExecutor ; +class IEgrImageMgr ; //---------------------------------------------------------------------------- bool LoadGraphicsDll( ILogger* pLogger, const std::string& sKey) ; @@ -28,3 +29,4 @@ void MySetEGrKey( const std::string& sKey) ; const char* MyGetEGrVersion( void) ; IEGrScene* MyCreateEGrScene( void) ; ISceExecutor* MyCreateSceExecutor(void) ; +IEgrImageMgr* MyCreateEgrImageMgr( void) ; diff --git a/EXE_Image.cpp b/EXE_Image.cpp new file mode 100644 index 0000000..2f9fef0 --- /dev/null +++ b/EXE_Image.cpp @@ -0,0 +1,39 @@ +//---------------------------------------------------------------------------- +// EgalTech 2015-2015 +//---------------------------------------------------------------------------- +// File : EXE_Image.cpp Data : 05.07.17 Versione : 1.8g1 +// Contenuto : Funzioni per gestione immagini. +// +// +// +// Modifiche : 05.07.17 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +//--------------------------- Include ---------------------------------------- +#include "stdafx.h" +#include "DllGraphics.h" +#include "/EgtDev/Include/EXeExecutor.h" +#include "/EgtDev/Include/EXeConst.h" +#include "/EgtDev/Include/EGrImageMgr.h" +#include "/EgtDev/Include/EgtPointerOwner.h" + +using namespace std ; + +//---------------------------------------------------------------------------- +bool +ExeGetImagePixels( const string& sFile, int& nPixelX, int& nPixelY) +{ + // assegno valori di default + nPixelX = 0 ; + nPixelY = 0 ; + + // preparo il gestore di immagini + PtrOwner pImageMgr( MyCreateEgrImageMgr()) ; + if ( IsNull( pImageMgr)) + return false ; + + // eseguo + return pImageMgr->GetImagePixels( sFile, nPixelX, nPixelY) ; +} diff --git a/EXE_Photo.cpp b/EXE_Photo.cpp index c5c8506..5a13311 100644 --- a/EXE_Photo.cpp +++ b/EXE_Photo.cpp @@ -183,4 +183,4 @@ ExeGetPhotoPixels( int nId, int& nPixelX, int& nPixelY) if ( ! pPhoto->GetName( sName)) return false ; return ( pScene->GetTexturePixels( sName, nPixelX, nPixelY) && nPixelX > 0 && nPixelY > 0) ; -} \ No newline at end of file +} diff --git a/EgtExecutor.rc b/EgtExecutor.rc index 5aaef91cb643501702e20304b73cdb4a51652f5f..eba1d85fb9dd98b1baa2a9c80bff71048d7b44bf 100644 GIT binary patch delta 103 zcmexR`k{2gH#Syt1|0^&&A-{4nVHjp3`efTEO4>oOp`YVR)EAOJ8~s&?h~?r$(o>Ndf?ZXC9>h delta 103 zcmexR`k{2gH#Sx?1|0_T&A-{4nVHjo3`efTEO4>oOp`YVR)EAOJ8~s&?h~?r$(o>Ndf?hTOQ2- diff --git a/EgtExecutor.vcxproj b/EgtExecutor.vcxproj index 5232716..95517ff 100644 --- a/EgtExecutor.vcxproj +++ b/EgtExecutor.vcxproj @@ -233,6 +233,7 @@ copy $(TargetPath) \EgtProg\Dll64 + @@ -287,6 +288,7 @@ copy $(TargetPath) \EgtProg\Dll64 + diff --git a/EgtExecutor.vcxproj.filters b/EgtExecutor.vcxproj.filters index 152d877..f948661 100644 --- a/EgtExecutor.vcxproj.filters +++ b/EgtExecutor.vcxproj.filters @@ -296,6 +296,12 @@ File di origine\Global + + File di origine\EXE + + + File di origine\LUA + diff --git a/LUA.h b/LUA.h index 6b747d3..b41770e 100644 --- a/LUA.h +++ b/LUA.h @@ -81,6 +81,9 @@ bool LuaInstallScene( LuaMgr& luaMgr) ; //-------------------------- Photo ------------------------------------------- bool LuaInstallPhoto( LuaMgr& luaMgr) ; +//-------------------------- Image ------------------------------------------- +bool LuaInstallImage( LuaMgr& luaMgr) ; + //-------------------------- Exchange ---------------------------------------- bool LuaInstallExchange( LuaMgr& luaMgr) ; diff --git a/LUA_Base.cpp b/LUA_Base.cpp index a7af5c3..a137ac2 100644 --- a/LUA_Base.cpp +++ b/LUA_Base.cpp @@ -114,6 +114,10 @@ LuaInstallEgtFunctions( LuaMgr& LuaMgr) LOG_ERROR( GetLogger(), "Error in LuaInstallPhoto (" __FUNCTION__ ")") return false ; } + if ( ! LuaInstallImage( LuaMgr)) { + LOG_ERROR( GetLogger(), "Error in LuaInstallImage (" __FUNCTION__ ")") + return false ; + } if ( ! LuaInstallExchange( LuaMgr)) { LOG_ERROR( GetLogger(), "Error in LuaInstallExchange (" __FUNCTION__ ")") return false ; diff --git a/LUA_Image.cpp b/LUA_Image.cpp new file mode 100644 index 0000000..bc939b5 --- /dev/null +++ b/LUA_Image.cpp @@ -0,0 +1,53 @@ +//---------------------------------------------------------------------------- +// EgalTech 2017-2017 +//---------------------------------------------------------------------------- +// File : LUA_Image.cpp Data : 05.07.17 Versione : 1.8g1 +// Contenuto : Funzioni sulle immagini per LUA. +// +// +// +// Modifiche : 05.07.17 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +//--------------------------- Include ---------------------------------------- +#include "stdafx.h" +#include "LUA.h" +#include "/EgtDev/Include/EXeExecutor.h" +#include "/EgtDev/Include/EGkLuaAux.h" +#include "/EgtDev/Include/EgnStringUtils.h" + +using namespace std ; + +//------------------------------------------------------------------------------- +static int +LuaGetImagePixels( lua_State* L) +{ + // 1 parametro : sFile + string sFile ; + LuaCheckParam( L, 1, sFile) + LuaClearStack( L) ; + // recupero la dimensione in pixels dell'immagine + int nPixelX, nPixelY ; + bool bOk = ExeGetImagePixels( sFile, nPixelX, nPixelY) ; + // restituisco il risultato + if ( bOk) { + LuaSetParam( L, nPixelX) ; + LuaSetParam( L, nPixelY) ; + return 2 ; + } + else { + LuaSetParam( L) ; + return 1 ; + } +} + +//------------------------------------------------------------------------------- +bool +LuaInstallImage( LuaMgr& luaMgr) +{ + bool bOk = ( &luaMgr != nullptr) ; + bOk = bOk && luaMgr.RegisterFunction( "EgtGetImagePixels", LuaGetImagePixels) ; + return bOk ; +}