Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Unified Diff: include/utils/SkPathUtils.h

Issue 16829003: Adding my Bitmap2Path sample for 1on1 meeting. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Closing the book on PathUtils, waiting for plumbing to patch it in with a real font. Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: include/utils/SkPathUtils.h
diff --git a/include/utils/SkPathUtils.h b/include/utils/SkPathUtils.h
new file mode 100644
index 0000000000000000000000000000000000000000..67e48747d9afff486157130bce137a7af56a7d6e
--- /dev/null
+++ b/include/utils/SkPathUtils.h
@@ -0,0 +1,51 @@
+/*
+ * CAUTION: EXPERIMENTAL CODE
+ *
+ * This code is not to be used and will not be supported
+ * if it fails on you. DO NOT USE!
+ *
+ */
+
+#ifndef SkPathUtils_DEFINED
+#define SKPathUtils_DEFINED
+
+#include "SkPath.h"
+
+/*
+ * The following methods return the boundary path given a 1-bit bitmap, specified
+ * by width/height and stride. The bits are interpreted as 1 being "in" the path,
+ * and 0 being "out". The bits are interpreted as MSB on the left, and LSB on the right.
+ */
+
+class SK_API SkPathUtils {
+public:
+ /**
+ This variation iterates the binary data sequentially (as in scanline fashion)
+ and will add each run of 1's to the path as a rectangular path. Upon parsing
+ all binary data the path is simplified using the PathOps::Simplify() method.
+ */
+ static void BitsToPath_Path(SkPath* path, const char* bitmap,
+ int h, int w, int stride);
+
+ /**
+ This variation utilizes the SkRegion class to generate paths, adding
+ each run of 1's to the SkRegion as an SkIRect. Upon parsing the entirety
+ of the binary the SkRegion is converted to a Path via getBoundaryPath().
+ */
+ static void BitsToPath_Region(SkPath* path, const char* bitmap,
+ int h, int w, int stride);
+
+ /**
+ This variation is an implementation of a component labeling algorithm
+ that utilizes contour tracing by Chang et al (2003). The algorithm examines
+ pixels in scanline order until it reaches a contour, traces the contour
+ and labels the on pixels as part of a connected component. Each contour is
+ then encoded as a path by utilizing the path moveTo() and lineTo() functions.
+ */
+ static void BitsToPath_Contour(SkPath* path, const char* bitmap,
+ int h, int w, int stride);
+
+
+};
+
+#endif
« no previous file with comments | « gyp/utils.gyp ('k') | samplecode/SamplePathUtils.cpp » ('j') | src/utils/SkPathUtils.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698