From 8da4aa27122b9a0a5befdc86f8d391278a0211f3 Mon Sep 17 00:00:00 2001 From: Steven Edwards Date: Sun, 16 Nov 2003 22:44:39 +0000 Subject: [PATCH] Added port of LineDDA function from WINE. svn path=/trunk/; revision=6671 --- reactos/lib/gdi32/makefile | 3 +- reactos/lib/gdi32/misc/stubs.c | 22 +------- reactos/lib/gdi32/objects/linedda.c | 80 +++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 22 deletions(-) create mode 100644 reactos/lib/gdi32/objects/linedda.c diff --git a/reactos/lib/gdi32/makefile b/reactos/lib/gdi32/makefile index db2bee3b387..e944af61166 100644 --- a/reactos/lib/gdi32/makefile +++ b/reactos/lib/gdi32/makefile @@ -1,4 +1,4 @@ -# $Id: makefile,v 1.34 2003/11/15 15:18:05 weiden Exp $ +# $Id: makefile,v 1.35 2003/11/16 22:44:39 sedwards Exp $ PATH_TO_TOP = ../.. @@ -39,6 +39,7 @@ OBJECTS_OBJECTS = \ objects/dc.o \ objects/fillshap.o \ objects/line.o \ + objects/linedda.o \ objects/metafile.o \ objects/pen.o \ objects/region.o \ diff --git a/reactos/lib/gdi32/misc/stubs.c b/reactos/lib/gdi32/misc/stubs.c index b08e3d2b069..11a491ec800 100644 --- a/reactos/lib/gdi32/misc/stubs.c +++ b/reactos/lib/gdi32/misc/stubs.c @@ -1,4 +1,4 @@ -/* $Id: stubs.c,v 1.39 2003/11/08 22:54:26 navaraf Exp $ +/* $Id: stubs.c,v 1.40 2003/11/16 22:44:39 sedwards Exp $ * * reactos/lib/gdi32/misc/stubs.c * @@ -513,26 +513,6 @@ InvertRgn( return FALSE; } - -/* - * @unimplemented - */ -BOOL -STDCALL -LineDDA( - int a0, - int a1, - int a2, - int a3, - LINEDDAPROC a4, - LPARAM a5 - ) -{ - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} - - /* * @unimplemented */ diff --git a/reactos/lib/gdi32/objects/linedda.c b/reactos/lib/gdi32/objects/linedda.c new file mode 100644 index 00000000000..d0cc5237264 --- /dev/null +++ b/reactos/lib/gdi32/objects/linedda.c @@ -0,0 +1,80 @@ +/* + * LineDDA + * + * Copyright 1993 Bob Amstadt + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS GDI32 + * PURPOSE: LineDDA Function + * FILE: lib/gdi32/objects/linedda.c + * PROGRAMER: Steven Edwards + * REVISION HISTORY: 2003/11/15 sedwards Created + * NOTES: Adapted from Wine + */ + +#include +#include +#include +#include + +/********************************************************************** + * LineDDA (GDI32.@) + * @implemented + */ +BOOL STDCALL LineDDA(INT nXStart, INT nYStart, INT nXEnd, INT nYEnd, + LINEDDAPROC callback, LPARAM lParam ) +{ + INT xadd = 1, yadd = 1; + INT err,erradd; + INT cnt; + INT dx = nXEnd - nXStart; + INT dy = nYEnd - nYStart; + + if (dx < 0) { + dx = -dx; xadd = -1; + } + if (dy < 0) { + dy = -dy; yadd = -1; + } + if (dx > dy) { /* line is "more horizontal" */ + err = 2*dy - dx; erradd = 2*dy - 2*dx; + for(cnt = 0;cnt <= dx; cnt++) { + callback(nXStart,nYStart,lParam); + if (err > 0) { + nYStart += yadd; + err += erradd; + } else { + err += 2*dy; + } + nXStart += xadd; + } + } else { /* line is "more vertical" */ + err = 2*dx - dy; erradd = 2*dx - 2*dy; + for(cnt = 0;cnt <= dy; cnt++) { + callback(nXStart,nYStart,lParam); + if (err > 0) { + nXStart += xadd; + err += erradd; + } else { + err += 2*dx; + } + nYStart += yadd; + } + } + return TRUE; +}