Click to See Complete Forum and Search --> : Polygon fill
xargon
April 26th, 2003, 09:06 AM
Hi everyone,
I have a GDI question. I have an array of points representing a wave data that I want to display. However, I want to display it as a filled polygon. I do not know if you have played with CoolEdit or such wave editing software, but it displays the wave file as a filled polygon. Is there a WINAPI to achieve something like this. I tried Polygon(HDC, POINT *, numPoints) but I did not get the desired result.
Thanks for any help you might give me.
Xargon
xargon
April 26th, 2003, 09:16 AM
Hi all,
Just explaining the query more clearly:
I am trying to port a VB application (Playwave.exe) that can be downloaded from the microsoft website to C++. I am basically done, but there is just one small thing:
The GDI routine in VB calls a function called
Line (lastX, leftYOffset + lastLeftY)-(x, curLeftY + leftYOffset)
I translated it to C++ as follows:
pDc->MoveTo(lastX, leftYOffset + lastLeftY);
pDc->LineTo(x, curLeftY + leftYOffset);
However, the outputs that I get are quite different. The VB call paints the wave as a filled polygon while I get a bunch of interconnected lines, of course. Is there an equivalant to this Line function in C++. The Line method is defined as in MSDN:
I tried using methods like Polygon and Polyline but to no avail. BTW: i am not using MFC. Since, I am still in the learning stage, I thought it would be nice to be comfortable with core WINAPI and get a hang of how things work behind the scenes.
Syntax
object.Line [Step] (x1, y1) [Step] - (x2, y2), [color], [B][F]
You can also download the Playwave.exe from
http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B182983
Thanks for any help that you might give me.
Pankaj
rsmemphis
April 28th, 2003, 05:14 AM
I downloaded the code you linked to, but I could not really find the lines you referred to.
Couple of things:
pDc->MoveTo(lastX, leftYOffset + lastLeftY);
pDc->LineTo(x, curLeftY + leftYOffset);
IS MFC code. The WinAPI code is MoveTo(HWND hwnd, int x, int y);
Seeing as you have a pDC pointer, your code must be MFC. Not that there is anything wrong with that, though. WinAPI coding is pretty tough, I have extensive MFC knowledge, but writing WinAPI can still be challenging at times.
Anyway, I think the function you may want to use is:
BOOL ExtFloodFill(
HDC hdc, // handle to DC
int nXStart, // starting x-coordinate
int nYStart, // starting y-coordinate
COLORREF crColor, // fill color
UINT fuFillType // fill type
);
or w/o the HDC hdc if you want to stay with MFC code.
xargon
April 28th, 2003, 08:09 AM
Hi,
Thanks for the reply. My code is WINAPI. I have classes that wrap the HDCs. I did not want to post all the classes, since that would make everything messy. So, I had just changed the variables to MFC like syntax.
I found the problem though. The problem was rather in conception. Software like CoolEdit and others take the minimum and maximum values over the range/per pixel and draw that. I was taking the scaleValue and drawing it. It was not wrong, just a different representation.
Thanks for taking the time :) I sincerely appreciate it.
Regards,
Pankaj
rsmemphis
April 28th, 2003, 09:19 AM
I see.
Well, that's good. Glad it finally worked.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.