-1

recently I have been trying to experiment with vector graphics in C++. I want to make a Win32 app that reads an svg file and shows it on the screen. The program currently is simple. A window opens using the Win32 API and a .svg file is selected. This svg file's data is then converted to a struct data of my own. The conversion is good. The code of struct is as follows:

#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. How can I rasterize the vector data that I have, to give me HBITMAP that I can show on the screen? If you know any resources, please put up a link.

Thanks in advance.

1 Answers1

1

I found two very interesting links redirecting to "similar" issues that might help you :

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

Also have a look at GDI+ docs.

Keep us in touch.

R. Théo
  • 74
  • 1
  • 7
  • @ R. Theo thanks for the answer, the resource will prove really useful to me but if you or anyone knows how to rasterize the struct from the question, please help me! – Hitarth Padaliya Nov 14 '21 at 09:05