daily pastebin goal
31%
SHARE
TWEET

Potrace problem

a guest Feb 14th, 2018 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. #if __APPLE__
  5.     #include "./lib/potracelib.h"
  6.     #include "./lib/bitmap.h"
  7.     #include "./lib_ubuntu/bitmap_io.h"
  8.     #include "./lib/main.h"
  9.     #include "./lib/backend_dxf.h"
  10. #elif __linux__
  11.     //#include "./lib_ubuntu/potracelib.h"
  12.     extern "C"
  13.     {
  14.     #include "./lib_ubuntu/bitmap.h"
  15.     #include "./lib_ubuntu/bitmap_io.h"
  16.     //#include "./lib_ubuntu/main.h"
  17.     #include "./lib_ubuntu/backend_svg.h"
  18.     #include "./lib_ubuntu/backend_dxf.h"
  19.     //#include  "./lib_ubuntu/backend_pdf.h"
  20.     }
  21. #endif
  22.  
  23. int main()
  24. {
  25.     std::ofstream myfile;
  26.     myfile.open ("example.eps");
  27.     FILE *bmfile;
  28.     bmfile = fopen("bm.pgm", "wb");
  29.  
  30.     FILE *my_file = new FILE;
  31.     my_file = fopen("example.svg", "wb");
  32.     int x, y, i;
  33.     potrace_param_t *param = potrace_param_default();
  34.     potrace_bitmap_t *bm = new potrace_bitmap_t;
  35.     potrace_path_t *p = new potrace_path_t;
  36.     potrace_state_t *st = new potrace_state_t;
  37.     imginfo_t *imginfo = new imginfo_t;
  38.     int n, *tag;
  39.     potrace_dpoint_t (*c)[3];
  40.     bm = bm_new(1000, 1000);
  41.     for (y=0; y<1000; y++) {
  42.         for (x=0; x<1000; x++) {
  43.             BM_PUT(bm, x, y, ((x*x + y*y*y) % 10000 < 5000) ? 1 : 0);
  44.         }
  45.     }
  46.  
  47.     //param ->alphamax = 0.0;
  48.     //param ->opticurve =;
  49.     //param ->opttolerance = 0.0;
  50.     //param ->progress =;
  51.     //param ->turdsize = 1000;
  52.     //param ->turnpolicy =;
  53.     bm_writepbm(bmfile, bm);
  54.     fclose(bmfile);
  55.     imginfo->width = 1000;
  56.     imginfo->height = 1000;
  57.     imginfo->pixwidth = 1000;
  58.     imginfo->pixheight = 1000;
  59.     imginfo->lmar = 1;
  60.     imginfo->rmar = 1;
  61.     imginfo->tmar = 1;
  62.     imginfo->bmar = 1;
  63.     imginfo->trans.bb[0] = 1000;
  64.     imginfo->trans.bb[1] = 1000;
  65.     imginfo->trans.orig[0] = 0;
  66.     imginfo->trans.orig[1] = 0;
  67.     imginfo->trans.x[0] = 1;
  68.     imginfo->trans.x[1] = 2;
  69.     imginfo->trans.y[0] = 2;
  70.     imginfo->trans.y[1] = 1;
  71.     imginfo->trans.scalex = 1;
  72.     imginfo->trans.scaley = 1;
  73.     st = potrace_trace(param, bm);
  74.     //bm_free(bm);
  75.     p = st->plist;
  76.    
  77.     printf("page begin\n");
  78.  
  79.     //init_ps(my_file);
  80.     page_svg(my_file, p, imginfo);
  81.  
  82.     printf("%s",potrace_version());
  83.     myfile.close();
  84.     fclose(my_file);
  85.     potrace_state_free(st);
  86.     return 0;
  87. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top