DllInterface.cpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. #include "stdafx.h"
  2. #include "DllInterface.h"
  3. #include <PlaqueInterfaceDLL.h>
  4. DllInterface::DllInterface()
  5. : m_isValid( FALSE )
  6. {
  7. Initialize();
  8. }
  9. DllInterface::~DllInterface()
  10. {
  11. if ( hDLL )
  12. {
  13. FreeLibrary( hDLL );
  14. }
  15. if ( plaqueResult.m_tPtLongeantPlaque )
  16. {
  17. delete[] plaqueResult.m_tPtLongeantPlaque;
  18. }
  19. if ( plaqueResult.m_tbPtsTrouvesFin )
  20. {
  21. delete[] plaqueResult.m_tbPtsTrouvesFin;
  22. }
  23. }
  24. BOOL DllInterface::IsValid()
  25. {
  26. return m_isValid;
  27. }
  28. void DllInterface::Clear()
  29. {
  30. plaqueResult.plaque_max_thickness = 0.0;
  31. plaqueResult.plaque_mean_thickness = 0.0;
  32. plaqueResult.plaque_area = 0.0;
  33. plaqueResult.plaque_mean_density = 0.0;
  34. plaqueResult.numberOfMeasures = 0;
  35. }
  36. plaque::PlaqueResult* DllInterface::GetResult()
  37. {
  38. return &plaqueResult;
  39. }
  40. BOOL DllInterface::initializeFromFile( const char* fileName, double mmPerPixelX, double mmPerPixelY )
  41. {
  42. return m_initializeFromFile( fileName, mmPerPixelX, mmPerPixelY );
  43. }
  44. int DllInterface::OnLButtonUp( int x, int y )
  45. {
  46. return m_onLButtonUp( x, y, &plaqueResult );
  47. }
  48. int DllInterface::computePlaque( int x, int y, int nbPts, unsigned char *points, int seuil1, int seuil2 )
  49. {
  50. return m_computePlaque( x, y, nbPts, points, &plaqueResult, seuil1, seuil2 );
  51. }
  52. int DllInterface::CalculerPlaqueManuelle( int nbPts, unsigned char *points )
  53. {
  54. return m_CalculerPlaqueManuelle(nbPts, points, &plaqueResult);
  55. }
  56. int DllInterface::fonctionDebug( )
  57. {
  58. return m_fonctionDebug( &plaqueResult );
  59. }
  60. void DllInterface::Initialize()
  61. {
  62. plaqueResult.m_tPtLongeantPlaque = NULL;
  63. plaqueResult.m_tbPtsTrouvesFin = NULL;
  64. Clear();
  65. hDLL = LoadLibrary( _T( "LibPlaqueDLL.dll" ) );
  66. if ( hDLL )
  67. {
  68. m_isValid = TRUE;
  69. m_initializeFromFile = (dll_initializeFromFile)GetProcAddress( hDLL, "initializeFromFile" );
  70. if ( !m_initializeFromFile )
  71. {
  72. m_isValid = FALSE;
  73. }
  74. initializeFromRaw = (dll_initializeFromRaw)GetProcAddress( hDLL, "initializeFromRaw" );
  75. if ( !initializeFromRaw )
  76. {
  77. m_isValid = FALSE;
  78. }
  79. m_onLButtonUp = (dll_onLButtonUp)GetProcAddress( hDLL, "OnLButtonUp" );
  80. if ( !m_onLButtonUp )
  81. {
  82. m_isValid = FALSE;
  83. }
  84. m_computePlaque = (dll_computePlaque)GetProcAddress( hDLL, "computePlaque" );
  85. if ( !m_computePlaque )
  86. {
  87. m_isValid = FALSE;
  88. }
  89. m_CalculerPlaqueManuelle = (dll_CalculerPlaqueManuelle)GetProcAddress( hDLL, "CalculerPlaqueManuelle" );
  90. if ( !m_CalculerPlaqueManuelle )
  91. {
  92. m_isValid = FALSE;
  93. }
  94. m_fonctionDebug = (dll_fonctionDebug)GetProcAddress( hDLL, "fonctionDebug" );
  95. if ( !m_fonctionDebug )
  96. {
  97. m_isValid = FALSE;
  98. }
  99. getDistanceToFirstPoint = (dll_getDistanceToFirstPoint)GetProcAddress( hDLL, "getDistanceToFirstPoint" );
  100. if ( !getDistanceToFirstPoint )
  101. {
  102. m_isValid = FALSE;
  103. }
  104. getImageWidth = (dll_getImageWidth)GetProcAddress( hDLL, "getImageWidth" );
  105. if ( !getImageWidth )
  106. {
  107. m_isValid = FALSE;
  108. }
  109. getImageHeight = (dll_getImageHeight)GetProcAddress( hDLL, "getImageHeight" );
  110. if ( !getImageHeight )
  111. {
  112. m_isValid = FALSE;
  113. }
  114. getImageBitsPerPixel = (dll_getImageBitsPerPixel)GetProcAddress( hDLL, "getImageBitsPerPixel" );
  115. if ( !getImageBitsPerPixel )
  116. {
  117. m_isValid = FALSE;
  118. }
  119. getPixelArray = (dll_getPixelArray)GetProcAddress( hDLL, "getPixelArray" );
  120. if ( !getPixelArray )
  121. {
  122. m_isValid = FALSE;
  123. }
  124. }
  125. }