Fixed OUTPUT_DEBUG_STRING pointer handling.
[wine.git] / objects / linedda.c
blobb48c2c225cca2bba723e880404bc1a383afede3b
1 /*
2 * LineDDA
4 * Copyright 1993 Bob Amstadt
5 */
7 #include <stdlib.h>
8 #include "windef.h"
9 #include "wingdi.h"
10 #include "wine/wingdi16.h"
12 /**********************************************************************
13 * LineDDA16 (GDI.100)
15 void WINAPI LineDDA16( INT16 nXStart, INT16 nYStart, INT16 nXEnd, INT16 nYEnd,
16 LINEDDAPROC16 callback, LPARAM lParam )
18 LineDDA( nXStart, nYStart, nXEnd, nYEnd,
19 (LINEDDAPROC)callback, lParam );
23 /**********************************************************************
24 * LineDDA32 (GDI32.248)
26 BOOL WINAPI LineDDA(INT nXStart, INT nYStart, INT nXEnd, INT nYEnd,
27 LINEDDAPROC callback, LPARAM lParam )
29 INT xadd = 1, yadd = 1;
30 INT err,erradd;
31 INT cnt;
32 INT dx = nXEnd - nXStart;
33 INT dy = nYEnd - nYStart;
35 if (dx < 0) {
36 dx = -dx; xadd = -1;
38 if (dy < 0) {
39 dy = -dy; yadd = -1;
41 if (dx > dy) { /* line is "more horizontal" */
42 err = 2*dy - dx; erradd = 2*dy - 2*dx;
43 for(cnt = 0;cnt <= dx; cnt++) {
44 callback(nXStart,nYStart,lParam);
45 if (err > 0) {
46 nYStart += yadd;
47 err += erradd;
48 } else {
49 err += 2*dy;
51 nXStart += xadd;
53 } else { /* line is "more vertical" */
54 err = 2*dx - dy; erradd = 2*dx - 2*dy;
55 for(cnt = 0;cnt <= dy; cnt++) {
56 callback(nXStart,nYStart,lParam);
57 if (err > 0) {
58 nXStart += xadd;
59 err += erradd;
60 } else {
61 err += 2*dx;
63 nYStart += yadd;
66 return TRUE;