Scale two one-byte values by a third one, which is treated as the numerator of a fraction whose demominator is 256.
In other words, it computes i,j * (scale / 256), ensuring that non-zero values passed in remain non zero, no matter how low the scale argument.
- Warning
- This function always modifies its arguments in place!
- Parameters
-
i | first value to scale |
j | second value to scale |
scale | scale factor, in n/256 units |
Definition at line 447 of file scale8.h.
447 {
448#if SCALE8_C == 1
449 uint8_t nonzeroscale = (
scale != 0) ? 1 : 0;
450 i = (i == 0) ? 0 : (((int)i * (int)(
scale)) >> 8) + nonzeroscale;
451 j = (j == 0) ? 0 : (((int)j * (int)(
scale)) >> 8) + nonzeroscale;
452#elif SCALE8_AVRASM == 1
456#else
457#error "No implementation for nscale8x2 available."
458#endif
459}
UISlider scale("Scale", 4,.1, 4,.1)
LIB8STATIC_ALWAYS_INLINE void cleanup_R1()
Clean up the r1 register after a series of *LEAVING_R1_DIRTY calls.
LIB8STATIC_ALWAYS_INLINE void nscale8_video_LEAVING_R1_DIRTY(uint8_t &i, fract8 scale)
In place modifying version of scale8_video() that does not clean up the R1 register on AVR.
References cleanup_R1(), LIB8STATIC, nscale8_video_LEAVING_R1_DIRTY(), and scale.