Menu

mkbitmap functionality in libpotrace

2016-03-15
2016-03-15
  • Oscar Kramer

    Oscar Kramer - 2016-03-15

    I am working with greyscale and color rasters that I need to convert to bitmaps before using potrace. I see you provide mkbitmap as an executable. The source file mkbitmap.c has all the relevant functions inline. It would be very useful to include those functions in the potrace lib, or provide a separate small lib so people can access it programmatically. Are you planning to do that or do you have another suggestion? Thanks for a great lib.

     
  • Peter Selinger

    Peter Selinger - 2016-03-15

    Hi Oscar, it is relatively simple to make a library version of mkbitmap. I have made such a library for some clients of Potrace Professional, but I have not yet included it in the GPL version, mainly because nobody has asked for it so far, and also because the current version overwrites the input greymap in place; for a library, it would be better to copy it first, which takes a small amount of additional time and space.

    It would be easy to modify the source code yourself to be able to use it as a library. Just look at the function process_file() in mkbitmap.c. It first reads the greymap from a file into a data structure, doing some error handling. Then the main work is performed, depending on various parameters (all of which are in the "info" data structure). Finally, it writes the output to a file. You could just strip away the file input/output, and turn it into a function that you can call from another program. Of course you'd have to prepare the greymap data in the format defined in greymap.h. And be mindful that the input greymap is going to be overwritten.

     

Log in to post a comment.