【问题标题】:How to rasterize a vector image in C++ Win32 API如何在 C++ Win32 API 中光栅化矢量图像
【发布时间】:2021-12-25 21:34:18
【问题描述】:

最近我一直在尝试在 C++ 中使用矢量图形。我想制作一个读取 svg 文件并将其显示在屏幕上的 Win32 应用程序。该程序目前很简单。使用 Win32 API 打开一个窗口并选择一个 .svg 文件。然后将此 svg 文件的数据转换为我自己的结构数据。转换很好。 struct的代码如下:

#pragma once

#include <vector>
#include "Rect.h"

class VectorTexture
{
public:
    enum ShapeType
    {
        // Circle: x, y, r
        Circle,
        // Line: x1, y1, x2, y2, width
        Line,
        // Rectangle: x, y, width, height
        Rectangle,
        // Square: x, y, a
        Square,
        // Polygon: x[n], y[n]
        Polygon
    };

    struct Shape
    {
    public:
        ShapeType type;
        float data[];
    };

    Rect rect;
    std::vector<Shape> shapes;
};

现在,下一步是显示 svg 图像。如何栅格化我拥有的矢量数据,给我HBITMAP,我可以在屏幕上显示?如果您知道任何资源,请提供链接。

提前致谢。

【问题讨论】:

    标签: c++ vector-graphics rasterizing bresenham


    【解决方案1】:

    我发现了两个非常有趣的链接,它们重定向到“类似”问题,可能会对您有所帮助:

    1. Convert Vector Unsigned char to HBITMAP in C
    2. Creating HBITMAP from Memory Buffer

    也可以看看 GDI+ docs.

    与我们保持联系。

    【讨论】:

    • @ R. Theo 感谢您的回答,该资源对我来说非常有用,但如果您或任何人知道如何从问题中光栅化结构,请帮助我!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-09
    • 1970-01-01
    • 2012-03-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多