| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- #include "stdafx.h"
- #include "DllInterface.h"
- #include <PlaqueInterfaceDLL.h>
- DllInterface::DllInterface()
- : m_isValid( FALSE )
- {
- Initialize();
- }
- DllInterface::~DllInterface()
- {
- if ( hDLL )
- {
- FreeLibrary( hDLL );
- }
- if ( plaqueResult.m_tPtLongeantPlaque )
- {
- delete[] plaqueResult.m_tPtLongeantPlaque;
- }
- if ( plaqueResult.m_tbPtsTrouvesFin )
- {
- delete[] plaqueResult.m_tbPtsTrouvesFin;
- }
- }
- BOOL DllInterface::IsValid()
- {
- return m_isValid;
- }
- void DllInterface::Clear()
- {
- plaqueResult.plaque_max_thickness = 0.0;
- plaqueResult.plaque_mean_thickness = 0.0;
- plaqueResult.plaque_area = 0.0;
- plaqueResult.plaque_mean_density = 0.0;
- plaqueResult.numberOfMeasures = 0;
- }
-
- plaque::PlaqueResult* DllInterface::GetResult()
- {
- return &plaqueResult;
- }
- BOOL DllInterface::initializeFromFile( const char* fileName, double mmPerPixelX, double mmPerPixelY )
- {
- return m_initializeFromFile( fileName, mmPerPixelX, mmPerPixelY );
- }
- int DllInterface::OnLButtonUp( int x, int y )
- {
- return m_onLButtonUp( x, y, &plaqueResult );
- }
- int DllInterface::computePlaque( int x, int y, int nbPts, unsigned char *points, int seuil1, int seuil2 )
- {
- return m_computePlaque( x, y, nbPts, points, &plaqueResult, seuil1, seuil2 );
- }
- int DllInterface::CalculerPlaqueManuelle( int nbPts, unsigned char *points )
- {
- return m_CalculerPlaqueManuelle(nbPts, points, &plaqueResult);
- }
- int DllInterface::fonctionDebug( )
- {
- return m_fonctionDebug( &plaqueResult );
- }
- void DllInterface::Initialize()
- {
- plaqueResult.m_tPtLongeantPlaque = NULL;
- plaqueResult.m_tbPtsTrouvesFin = NULL;
- Clear();
- hDLL = LoadLibrary( _T( "LibPlaqueDLL.dll" ) );
- if ( hDLL )
- {
- m_isValid = TRUE;
- m_initializeFromFile = (dll_initializeFromFile)GetProcAddress( hDLL, "initializeFromFile" );
- if ( !m_initializeFromFile )
- {
- m_isValid = FALSE;
- }
- initializeFromRaw = (dll_initializeFromRaw)GetProcAddress( hDLL, "initializeFromRaw" );
- if ( !initializeFromRaw )
- {
- m_isValid = FALSE;
- }
-
- m_onLButtonUp = (dll_onLButtonUp)GetProcAddress( hDLL, "OnLButtonUp" );
- if ( !m_onLButtonUp )
- {
- m_isValid = FALSE;
- }
-
- m_computePlaque = (dll_computePlaque)GetProcAddress( hDLL, "computePlaque" );
- if ( !m_computePlaque )
- {
- m_isValid = FALSE;
- }
- m_CalculerPlaqueManuelle = (dll_CalculerPlaqueManuelle)GetProcAddress( hDLL, "CalculerPlaqueManuelle" );
- if ( !m_CalculerPlaqueManuelle )
- {
- m_isValid = FALSE;
- }
- m_fonctionDebug = (dll_fonctionDebug)GetProcAddress( hDLL, "fonctionDebug" );
- if ( !m_fonctionDebug )
- {
- m_isValid = FALSE;
- }
- getDistanceToFirstPoint = (dll_getDistanceToFirstPoint)GetProcAddress( hDLL, "getDistanceToFirstPoint" );
- if ( !getDistanceToFirstPoint )
- {
- m_isValid = FALSE;
- }
- getImageWidth = (dll_getImageWidth)GetProcAddress( hDLL, "getImageWidth" );
- if ( !getImageWidth )
- {
- m_isValid = FALSE;
- }
- getImageHeight = (dll_getImageHeight)GetProcAddress( hDLL, "getImageHeight" );
- if ( !getImageHeight )
- {
- m_isValid = FALSE;
- }
- getImageBitsPerPixel = (dll_getImageBitsPerPixel)GetProcAddress( hDLL, "getImageBitsPerPixel" );
- if ( !getImageBitsPerPixel )
- {
- m_isValid = FALSE;
- }
- getPixelArray = (dll_getPixelArray)GetProcAddress( hDLL, "getPixelArray" );
- if ( !getPixelArray )
- {
- m_isValid = FALSE;
- }
- }
- }
|