Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- #if __APPLE__
- #include "./lib/potracelib.h"
- #include "./lib/bitmap.h"
- #include "./lib_ubuntu/bitmap_io.h"
- #include "./lib/main.h"
- #include "./lib/backend_dxf.h"
- #elif __linux__
- //#include "./lib_ubuntu/potracelib.h"
- extern "C"
- {
- #include "./lib_ubuntu/bitmap.h"
- #include "./lib_ubuntu/bitmap_io.h"
- //#include "./lib_ubuntu/main.h"
- #include "./lib_ubuntu/backend_svg.h"
- #include "./lib_ubuntu/backend_dxf.h"
- //#include "./lib_ubuntu/backend_pdf.h"
- }
- #endif
- int main()
- {
- std::ofstream myfile;
- myfile.open ("example.eps");
- FILE *bmfile;
- bmfile = fopen("bm.pgm", "wb");
- FILE *my_file = new FILE;
- my_file = fopen("example.svg", "wb");
- int x, y, i;
- potrace_param_t *param = potrace_param_default();
- potrace_bitmap_t *bm = new potrace_bitmap_t;
- potrace_path_t *p = new potrace_path_t;
- potrace_state_t *st = new potrace_state_t;
- imginfo_t *imginfo = new imginfo_t;
- int n, *tag;
- potrace_dpoint_t (*c)[3];
- bm = bm_new(1000, 1000);
- for (y=0; y<1000; y++) {
- for (x=0; x<1000; x++) {
- BM_PUT(bm, x, y, ((x*x + y*y*y) % 10000 < 5000) ? 1 : 0);
- }
- }
- //param ->alphamax = 0.0;
- //param ->opticurve =;
- //param ->opttolerance = 0.0;
- //param ->progress =;
- //param ->turdsize = 1000;
- //param ->turnpolicy =;
- bm_writepbm(bmfile, bm);
- fclose(bmfile);
- imginfo->width = 1000;
- imginfo->height = 1000;
- imginfo->pixwidth = 1000;
- imginfo->pixheight = 1000;
- imginfo->lmar = 1;
- imginfo->rmar = 1;
- imginfo->tmar = 1;
- imginfo->bmar = 1;
- imginfo->trans.bb[0] = 1000;
- imginfo->trans.bb[1] = 1000;
- imginfo->trans.orig[0] = 0;
- imginfo->trans.orig[1] = 0;
- imginfo->trans.x[0] = 1;
- imginfo->trans.x[1] = 2;
- imginfo->trans.y[0] = 2;
- imginfo->trans.y[1] = 1;
- imginfo->trans.scalex = 1;
- imginfo->trans.scaley = 1;
- st = potrace_trace(param, bm);
- //bm_free(bm);
- p = st->plist;
- printf("page begin\n");
- //init_ps(my_file);
- page_svg(my_file, p, imginfo);
- printf("%s",potrace_version());
- myfile.close();
- fclose(my_file);
- potrace_state_free(st);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement