Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
C/C++ - Svg2Gdiplus...
Forum - C/C++ - Svg2Gdiplus...

Avatar
AldoBaldo (Member)
Guru


Messaggi: 700
Iscritto: 08/01/2015

Segnala al moderatore
Postato alle 22:46
Giovedì, 28/12/2017
Ciao a te che leggi...

In questi giorni di "pausa natalizia" ho ripreso in mano un programmino che avevo abbozzato qualche tempo fa. L'intenzione è mettere insieme un "attrezzo" che legga un file in formato SVG e ne estragga i dati dei percorsi identificati dai tag <path>.

Al momento, il programma è nel mio "stile", cioè pasticciato, però pare funzionare e genera file con un aspetto di questo tipo...

Codice sorgente - presumibilmente C/C++

  1. // PERCORSO #1 (id: "4_4gs"; punti: 92) ========================================
  2.  
  3. const size_t kQPtCoo_4_4gs_1 = 92;
  4.  
  5. // coordinate dei punti
  6. REAL coo_4_4gs_1[2*kQPtCoo_4_4gs_1] = {
  7.     4.700, -2.959,
  8.     3.235, -2.939,            2.089, -2.674,            1.263, -2.165,
  9.     0.436, -1.655,            0.016, -1.020,            0.001, -0.260,
  10.     -0.015, 0.494,            0.327, 1.136,             1.026, 1.667,
  11.     1.724, 2.198,             2.876, 2.475,             4.480, 2.499,
  12.     6.233, 2.479,             7.461, 2.209,             8.164, 1.690,
  13.     8.867, 1.170,             9.205, 0.520,             9.179, -0.260,
  14.     9.161, -0.778,            8.924, -1.240,            8.467, -1.645,
  15.     8.010, -2.049,            7.441, -2.368,            6.760, -2.602,
  16.     6.078, -2.835,            5.392, -2.954,            4.700, -2.959,
  17.  
  18.     2.419, -1.601,
  19.     2.553, -1.961,            2.785, -2.197,            3.114, -2.309,
  20.     3.444, -2.421,            3.785, -2.472,            4.140, -2.461,
  21.     4.639, -2.450,            5.090, -2.295,            5.493, -1.997,
  22.     5.896, -1.700,            6.217, -1.329,            6.455, -0.884,
  23.     6.694, -0.440,            6.816, 0.009,             6.821, 0.460,
  24.     6.821, 0.531,             6.817, 0.600,             6.809, 0.668,
  25.     6.801, 0.736,             6.792, 0.800,             6.781, 0.861,
  26.     6.731, 1.132,             6.626, 1.359,             6.466, 1.541,
  27.     6.306, 1.723,             6.091, 1.849,             5.821, 1.921,
  28.     5.711, 1.951,             5.601, 1.972,             5.491, 1.984,
  29.     5.380, 1.996,             5.270, 2.002,             5.160, 2.001,
  30.     5.061, 2.002,             4.964, 1.996,             4.870, 1.984,
  31.     4.776, 1.972,             4.679, 1.951,             4.580, 1.921,
  32.     4.399, 1.861,             4.221, 1.782,             4.047, 1.684,
  33.     3.873, 1.586,             3.711, 1.471,             3.559, 1.341,
  34.     3.479, 1.271,             3.400, 1.196,             3.322, 1.116,
  35.     3.244, 1.036,             3.170, 0.951,             3.099, 0.861,
  36.     2.884, 0.604,             2.704, 0.307,             2.561, -0.032,
  37.     2.418, -0.371,            2.344, -0.714,            2.339, -1.060,
  38.     2.338, -1.151,            2.344, -1.241,            2.356, -1.331,
  39.     2.368, -1.421,            2.389, -1.511,            2.419, -1.601
  40. }; // fine REAL coo_4_4gs_1[]
  41.  
  42. // tipologie dei punti
  43. BYTE ppt_4_4gs_1[kQPtCoo_4_4gs_1] = {
  44.     PathPointTypeStart,
  45.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  46.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  47.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  48.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  49.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  50.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  51.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  52.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  53.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  54.  
  55.     PathPointTypeStart,
  56.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  57.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  58.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  59.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  60.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  61.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  62.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  63.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  64.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  65.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  66.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  67.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  68.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  69.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  70.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  71.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  72.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  73.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  74.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  75.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  76.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier
  77. }; // fine BYTE ppt_4_4gs_1[]
  78.  
  79. // fine percorso #1 (id: "4_4gs"; punti: 92)
  80.  
  81.  
  82.  
  83. // PERCORSO #2 (id: "2_4gs"; punti: 83) ========================================
  84.  
  85. const size_t kQPtCoo_2_4gs_2 = 83;
  86.  
  87. // coordinate dei punti
  88. REAL coo_2_4gs_2[2*kQPtCoo_2_4gs_2] = {
  89.     2.239, 2.899,
  90.     3.493, 2.866,             4.452, 2.590,             5.116, 2.072,
  91.     5.781, 1.553,             6.234, 0.992,             6.476, 0.387,
  92.     6.718, -0.218,            6.833, -0.667,            6.819, -0.961,
  93.     6.819, -17.499,
  94.     6.221, -17.499,
  95.     6.221, -2.360,
  96.     6.020, -2.531,            5.777, -2.663,            5.493, -2.757,
  97.     5.210, -2.850,            4.892, -2.898,            4.541, -2.899,
  98.     3.395, -2.873,            2.490, -2.627,            1.825, -2.160,
  99.     1.161, -1.693,            0.689, -1.159,            0.409, -0.559,
  100.     0.129, 0.042,             -0.007, 0.555,            0.001, 0.981,
  101.     0.016, 1.594,             0.231, 2.067,             0.648, 2.397,
  102.     1.064, 2.728,             1.595, 2.895,             2.239, 2.899,
  103.  
  104.     2.780, -1.041,
  105.     3.346, -1.367,            3.819, -1.600,            4.198, -1.739,
  106.     4.577, -1.877,            4.884, -1.945,            5.121, -1.941,
  107.     5.338, -1.939,            5.513, -1.894,            5.646, -1.806,
  108.     5.779, -1.719,            5.884, -1.604,            5.961, -1.461,
  109.     6.002, -1.391,            6.035, -1.320,            6.061, -1.248,
  110.     6.087, -1.176,            6.100, -1.100,            6.101, -1.021,
  111.     6.115, -0.799,            5.967, -0.527,            5.659, -0.205,
  112.     5.350, 0.117,             4.797, 0.539,             4.000, 1.061,
  113.     3.482, 1.406,             3.038, 1.651,             2.667, 1.794,
  114.     2.297, 1.937,             1.987, 2.006,             1.739, 2.001,
  115.     1.501, 1.997,             1.307, 1.945,             1.159, 1.846,
  116.     1.011, 1.747,             0.897, 1.625,             0.819, 1.481,
  117.     0.778, 1.410,             0.745, 1.336,             0.719, 1.258,
  118.     0.693, 1.180,             0.680, 1.101,             0.679, 1.021,
  119.     0.666, 0.773,             0.816, 0.482,             1.129, 0.148,
  120.     1.442, -0.187,            1.992, -0.583,            2.780, -1.041
  121. }; // fine REAL coo_2_4gs_2[]
  122.  
  123. // tipologie dei punti
  124. BYTE ppt_2_4gs_2[kQPtCoo_2_4gs_2] = {
  125.     PathPointTypeStart,
  126.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  127.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  128.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  129.     PathPointTypeLine,
  130.     PathPointTypeLine,
  131.     PathPointTypeLine,
  132.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  133.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  134.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  135.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  136.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  137.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  138.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  139.  
  140.     PathPointTypeStart,
  141.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  142.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  143.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  144.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  145.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  146.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  147.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  148.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  149.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  150.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  151.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  152.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  153.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  154.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  155.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier,
  156.     PathPointTypeBezier,     PathPointTypeBezier,     PathPointTypeBezier
  157. }; // fine BYTE ppt_2_4gs_2[]
  158.  
  159. // fine percorso #2 (id: "2_4gs"; punti: 83)



Gli array possono essere usati direttamente per creare con C++ in Gdi+ degli oggetti di classe GraphicsPath che riproducono i profili descritti dai <path> SVG.

Se qualche anima buona volesse darmi qualche suggerimento, sarei più che lieto di scambiare quattro chiacchiere.

A presto, spero!

P.S. il codice del programma è reperibile qui:

https://dopiest-curtains.000webhostapp.com/

Ultima modifica effettuata da AldoBaldo il 28/12/2017 alle 22:50


ATTENZIONE! Sono un hobbista e l'affidabilità delle mie conoscenze informatiche è molto limitata. Non prendere come esempio il codice che scrivo, perché non ho alcuna formazione accademica e rischieresti di apprendere pratiche controproducenti.
PM Quote