Share via

Why doesn't this gdiplus GraphicsPath code work?

william 21 Reputation points
2022-03-15T20:48:31.627+00:00

Hi! I am trying to learn to use the gdiplus GraphicsPath class and wrote some code to test the setup, but the number of points always returns 0. What is wrong with this code?

#include <windows.h>
#include <gdiplus.h>
#include <iostream>

//use gdiplus library when compiling
#pragma comment( lib, "gdiplus" )

using namespace Gdiplus;

VOID GetPointCountExample()
{
    // Create a path that has one ellipse and one line.
    GraphicsPath path;
    path.AddLine(220, 120, 300, 160);

    // Find out how many data points are stored in the path.
    int count = path.GetPointCount();
    std::cout << count << std::endl;
}

int main()
{
    GetPointCountExample();
}
Windows development | Windows API - Win32
Developer technologies | C++
Developer technologies | C++

A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.

0 comments No comments

Answer accepted by question author

Viorel 127K Reputation points
2022-03-15T21:49:03.353+00:00

Try initialising the engine:

int main()
{
   ULONG_PTR t;
   Gdiplus::GdiplusStartupInput s;
   Gdiplus::GdiplusStartup( &t, &s, nullptr );
   . . .
}

Was this answer helpful?


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.