MCPcopy Create free account
hub / github.com/carbonengine/trinity / PyCompareBitmaps

Function PyCompareBitmaps

trinity/Tr2HostBitmap_Blue.cpp:265–400  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

263}
264
265static 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() ),

Callers

nothing calls this directly

Calls 10

ToPythonFunction · 0.85
GetTrueMipCountMethod · 0.80
GetMipSizeMethod · 0.80
IsValidMethod · 0.45
GetWidthMethod · 0.45
GetHeightMethod · 0.45
GetFormatMethod · 0.45
GetMipCountMethod · 0.45
GetTypeMethod · 0.45
CreateMethod · 0.45

Tested by

no test coverage detected