简体   繁体   English

如何在 C++ Win32 API 中光栅化矢量图像

[英]How to rasterize a vector image in C++ Win32 API

recently I have been trying to experiment with vector graphics in C++.最近我一直在尝试在 C++ 中尝试矢量图形。 I want to make a Win32 app that reads an svg file and shows it on the screen.我想制作一个读取 svg 文件并将其显示在屏幕上的 Win32 应用程序。 The program currently is simple.目前的程序很简单。 A window opens using the Win32 API and a .svg file is selected.使用 Win32 API 将打开一个窗口,并选择一个 .svg 文件。 This svg file's data is then converted to a struct data of my own.这个 svg 文件的数据然后被转换为我自己的结构数据。 The conversion is good.转换是好的。 The code of struct is as follows: 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;
};

Now, the next step is show the svg image.现在,下一步是显示 svg 图像。 How can I rasterize the vector data that I have, to give me HBITMAP that I can show on the screen?我怎样才能光栅化我拥有的矢量数据,给我可以在屏幕上显示的HBITMAP If you know any resources, please put up a link.如果您知道任何资源,请提供链接。

Thanks in advance.提前致谢。

I found two very interesting links redirecting to "similar" issues that might help you :我发现两个非常有趣的链接重定向到“类似”的问题,可能会帮助你:

  1. Convert Vector Unsigned char to HBITMAP in C 在 C 中将 Vector Unsigned char 转换为 HBITMAP
  2. Creating HBITMAP from Memory Buffer 从内存缓冲区创建 HBITMAP

Also have a look at GDI+ docs .另请查看GDI+ 文档

Keep us in touch.让我们保持联系。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM