Why does Gdiplus::Region::IsEmpty() require a Graphics object as an argument?

81 Views Asked by At

I wrote this function to determine whether a Gdiplus::GraphicsPath intersects a Gdiplus::RectF. It works as expected, but I don't understand why I need to pass a Graphics object to the IsEmpty() method.

bool objects_intersect(Gdiplus::GraphicsPath* path, Gdiplus::Pen* path_pen, Gdiplus::RectF& rectangle) {
    // Get the area covered by the path, including its outline.
    Gdiplus::GraphicsPath* footprint = path->Clone();
    footprint->Widen(path_pen);
    Gdiplus::Region footprint_region(footprint);
    delete footprint;

    // Get the overlap between the path and the rectangle
    footprint_region.Intersect(rectangle);

    // Test if the overlap is nonempty
    Gdiplus::Bitmap blank_image(10, 10);
    Gdiplus::Graphics throwaway_graphics(&blank_image); // Is this necessary?
    return !footprint_region.IsEmpty(&throwaway_graphics);
}
0

There are 0 best solutions below