Don't get OOPBase in this ugly way.
[tangerine.git] / rom / graphics / scalerdiv.c
blob5a5d04013c8f02f9d209f313f3608271190a28ab
1 /*
2 Copyright © 1995-2001, 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
54 AROS_LIBBASE_EXT_DECL(struct GfxBase *,GfxBase)
56 ULONG res;
57 if (0 == factor)
58 return 0;
59 else
60 res = (ULONG)((ULONG)factor * (ULONG)numerator) / denominator;
62 if (0 == res)
63 return 1;
65 if (((factor * numerator) % denominator) >= ((denominator + 1) >> 1))
66 res++;
68 return res;
70 AROS_LIBFUNC_EXIT
71 } /* ScalerDiv */