From a4cff1c9e20892ba66b2fe67125992081f392354 Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Sun, 4 Nov 2012 20:01:22 +0900 Subject: [PATCH] epjitsu: implement get_gcd Signed-off-by: Hiroshi Miura --- backend/epjitsu.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/backend/epjitsu.c b/backend/epjitsu.c index a99507616..ee3f4948d 100644 --- a/backend/epjitsu.c +++ b/backend/epjitsu.c @@ -3980,13 +3980,17 @@ read_from_scanner(struct scanner *s, struct transfer * tp) static int get_GCD(int x, int y) { - /* Here should be implemented Euclidean algorithm */ - /* FIXME: only works with 225x200 */ - if (x == 225 && y == 200) - { - return 25; + int z; + + while (y > 0) { + if (y > x) { + z = x;x = y;y = z; + } + z = y; + y = x % y; + x = z; } - return 1; + return x; } /* test it is nessesary to insert row because of non-square pixel */