MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / scale_precondition

Function scale_precondition

src/Engine/Scalers/scalebit.cpp:438–466  ·  view source on GitHub ↗

* Check if the scale implementation is applicable at the given arguments. * \param scale Scale factor. 2, 203 (fox 2x3), 204 (for 2x4), 3 or 4. * \param pixel Bytes per pixel of the source and destination bitmap. * \param width Horizontal size in pixels of the source bitmap. * \param height Vertical size in pixels of the source bitmap. * \return * - -1 on precondition violated. * - 0 on

Source from the content-addressed store, hash-verified

436 * - 0 on success.
437 */
438int scale_precondition(unsigned scale, unsigned pixel, unsigned width, unsigned height)
439{
440 if (pixel != 1 && pixel != 2 && pixel != 4)
441 return -1;
442
443 switch (scale) {
444 case 202 :
445 case 203 :
446 case 204 :
447 case 2 :
448 case 303 :
449 case 3 :
450 if (height < 2)
451 return -1;
452 break;
453 case 404 :
454 case 4 :
455 if (height < 4)
456 return -1;
457 break;
458 default:
459 return -1;
460 }
461
462 if (width < 2)
463 return -1;
464
465 return 0;
466}
467
468/**
469 * Apply the Scale effect on a bitmap.

Callers 1

_zoomSurfaceYMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected