This is a header only C++ library which creates polygons (arrays of vertices) from input PNG sprites.
SFML-2.4.2 or later is required as this library makes use of SFML's sf::Image class for loading, reading, and modifying input images.
Simply copy VerticesFromBitmap.hpp to your project and #include the header.
Create a VerticesFromBitmap object and call VerticesFromBitmap::generateIslands(image) where image is of type sf::Image .
The function will return an array of Island ; each Island is an array of Vec2 positions representing vertices of a closed polygon.
This repo comes with a demo to try out before usage:
- Place any
.pngfile namedtest.pnginto the same directory as the.exe. - Open the
.exefile and the polygon will automatically be rendered.
Reload image: R
Display .png image in background: D
Switch between aliased and original image: S
Double minimum distance between vertices: Num1
Halve minimum distance between vertices: Num2
Double vertex rendered size: PgUp
Halve vertex rendered size: PgDn
Increase co-linear threshold: L
Decrease co-linear threshold: K