簡體   English   中英

如何在 C++ Win32 API 中光柵化矢量圖像

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

最近我一直在嘗試在 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 如果您知道任何資源,請提供鏈接。

提前致謝。

我發現兩個非常有趣的鏈接重定向到“類似”的問題,可能會幫助你:

  1. 在 C 中將 Vector Unsigned char 轉換為 HBITMAP
  2. 從內存緩沖區創建 HBITMAP

另請查看GDI+ 文檔

讓我們保持聯系。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM