Documented GVF_SAVE_VAR alongside other flags, and removed a query/doubt
[AROS.git] / rom / graphics / scalerdiv.c
blob16a29e93be542637f63dd5a4dcafb3fc22c074d0
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Graphics function ScalerDiv()
6 Lang: english
7 */
9 #include "graphics_intern.h"
11 /*****************************************************************************
13 NAME */
14 #include <proto/graphics.h>
16 AROS_LH3(UWORD, ScalerDiv,
18 /* SYNOPSIS */
19 AROS_LHA(UWORD, factor, D0),
20 AROS_LHA(UWORD, numerator, D1),
21 AROS_LHA(UWORD, denominator, D2),
23 /* LOCATION */
24 struct GfxBase *, GfxBase, 114, Graphics)
26 /* FUNCTION
27 Use this to precalculate the width/height of the destination
28 bitmap. As factor give the width/height of the original bitmap
29 that is to be scaled via ScaleBitMap(), as numerator give
30 the value you will write into bsa_XSrcFactor/bsa_YSrcFactor
31 and as denominator the value of bsa_XDestFactor/bsa_YDestFactor.
33 INPUTS
34 factor - a number in the range of 0..16383
35 numerator - a number in the range of 1..16383
36 denominator - a number in the range of 1..16383
38 RESULT
40 NOTES
42 EXAMPLE
44 BUGS
46 SEE ALSO
47 BitMapScale()
49 INTERNALS
51 HISTORY
53 *****************************************************************************/
55 AROS_LIBFUNC_INIT
57 ULONG res;
58 if (0 == factor || 0 == numerator || 0 == denominator)
59 return 0;
60 else
61 res = (ULONG)((ULONG)factor * (ULONG)numerator) / denominator;
63 if (0 == res)
64 return 1;
66 if (((factor * numerator) % denominator) >= ((denominator + 1) >> 1))
67 res++;
69 return res;
71 AROS_LIBFUNC_EXIT
72 } /* ScalerDiv */