【发布时间】: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