Fix IO memory access .. SB128 driver makes noises in VMWare - CMI is untested (Curren...
[AROS.git] / rom / graphics / scalerdiv.c
blob5639ea700e160f2bce8a7378b0c7fcc00bc282f8
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Graphics function ScalerDiv()
6 Lang: english
7 */
9 /*****************************************************************************
11 NAME */
12 #include <proto/graphics.h>
14 AROS_LH3(UWORD, ScalerDiv,
16 /* SYNOPSIS */
17 AROS_LHA(UWORD, factor, D0),
18 AROS_LHA(UWORD, numerator, D1),
19 AROS_LHA(UWORD, denominator, D2),
21 /* LOCATION */
22 struct GfxBase *, GfxBase, 114, Graphics)
24 /* FUNCTION
25 Use this to precalculate the width/height of the destination
26 bitmap. As factor give the width/height of the original bitmap
27 that is to be scaled via ScaleBitMap(), as numerator give
28 the value you will write into bsa_XSrcFactor/bsa_YSrcFactor
29 and as denominator the value of bsa_XDestFactor/bsa_YDestFactor.
31 INPUTS
32 factor - a number in the range of 0..16383
33 numerator - a number in the range of 1..16383
34 denominator - a number in the range of 1..16383
36 RESULT
38 NOTES
40 EXAMPLE
42 BUGS
44 SEE ALSO
45 BitMapScale()
47 INTERNALS
49 HISTORY
51 *****************************************************************************/
53 AROS_LIBFUNC_INIT
55 ULONG res;
56 if (0 == factor)
57 return 0;
58 else
59 res = (ULONG)((ULONG)factor * (ULONG)numerator) / denominator;
61 if (0 == res)
62 return 1;
64 if (((factor * numerator) % denominator) >= ((denominator + 1) >> 1))
65 res++;
67 return res;
69 AROS_LIBFUNC_EXIT
70 } /* ScalerDiv */