| 263 | } |
| 264 | |
| 265 | static PyObject* PyCompareBitmaps( PyObject* self, PyObject* args ) |
| 266 | { |
| 267 | using namespace Tr2RenderContextEnum; |
| 268 | |
| 269 | PyObject* img1Obj = nullptr; |
| 270 | PyObject* img2Obj = nullptr; |
| 271 | PyObject* diffObj = nullptr; |
| 272 | unsigned tolerance = 0; |
| 273 | if( !PyArg_ParseTuple( args, "OO|iO", &img1Obj, &img2Obj, &tolerance, &diffObj ) ) |
| 274 | { |
| 275 | return NULL; |
| 276 | } |
| 277 | |
| 278 | Tr2HostBitmap* img1 = BluePythonCast<Tr2HostBitmap*>( img1Obj ); |
| 279 | if( !img1 ) |
| 280 | { |
| 281 | PyErr_SetString( PyExc_TypeError, "CompareBitmaps: First parameter must be a Tr2HostBitmap object" ); |
| 282 | return NULL; |
| 283 | } |
| 284 | |
| 285 | Tr2HostBitmap* img2 = BluePythonCast<Tr2HostBitmap*>( img2Obj ); |
| 286 | if( !img2 ) |
| 287 | { |
| 288 | PyErr_SetString( PyExc_TypeError, "CompareBitmaps: Second parameter must be a Tr2HostBitmap object" ); |
| 289 | return NULL; |
| 290 | } |
| 291 | |
| 292 | Tr2HostBitmap* diff = nullptr; |
| 293 | |
| 294 | if( diffObj ) |
| 295 | { |
| 296 | diff = BluePythonCast<Tr2HostBitmap*>( diffObj ); |
| 297 | if( !diff ) |
| 298 | { |
| 299 | PyErr_SetString( PyExc_TypeError, "CompareBitmaps: Third parameter must be a Tr2HostBitmap object" ); |
| 300 | return NULL; |
| 301 | } |
| 302 | } |
| 303 | |
| 304 | if( !img1->IsValid() || !img2->IsValid() ) |
| 305 | { |
| 306 | PyErr_SetString( PyExc_TypeError, "CompareBitmaps: invalid source/destination bitmaps" ); |
| 307 | return NULL; |
| 308 | } |
| 309 | |
| 310 | if( img1->GetWidth() != img2->GetWidth() || |
| 311 | img1->GetHeight() != img2->GetHeight() || |
| 312 | img1->GetFormat() != img2->GetFormat() || |
| 313 | img1->GetMipCount() != img2->GetMipCount() || |
| 314 | img1->GetType() != TEX_TYPE_2D || |
| 315 | img2->GetType() != TEX_TYPE_2D ) |
| 316 | { |
| 317 | char buffer[2048]; |
| 318 | sprintf_s( buffer, |
| 319 | "CompareBitmaps only works between identical layout 2D bitmaps. " |
| 320 | " image1: %ux%ux%u %i %i image2: %ux%ux%u %i %i", |
| 321 | unsigned( img1->GetWidth() ), |
| 322 | unsigned( img1->GetHeight() ), |
nothing calls this directly
no test coverage detected