summaryrefslogtreecommitdiffstats
path: root/src/trace/potrace
diff options
context:
space:
mode:
authorbulia byak <buliabyak@gmail.com>2006-11-20 05:26:29 +0000
committerbuliabyak <buliabyak@users.sourceforge.net>2006-11-20 05:26:29 +0000
commitc61a6c1b8eeeaae18538ed82b9abed7c5f9066ff (patch)
tree5be14d78a41f702211721f4dc7e388ba565abfa0 /src/trace/potrace
parentpatch for Preview out of the tabs and other fixes (diff)
downloadinkscape-c61a6c1b8eeeaae18538ed82b9abed7c5f9066ff.tar.gz
inkscape-c61a6c1b8eeeaae18538ed82b9abed7c5f9066ff.zip
patch 1598684: better trace quantization
(bzr r1994)
Diffstat (limited to 'src/trace/potrace')
-rw-r--r--src/trace/potrace/inkscape-potrace.cpp52
1 files changed, 15 insertions, 37 deletions
diff --git a/src/trace/potrace/inkscape-potrace.cpp b/src/trace/potrace/inkscape-potrace.cpp
index d1aa357fc..c27309eb9 100644
--- a/src/trace/potrace/inkscape-potrace.cpp
+++ b/src/trace/potrace/inkscape-potrace.cpp
@@ -20,6 +20,7 @@
#include <gtkmm.h>
#include "trace/filterset.h"
+#include "trace/quantize.h"
#include "trace/imagemap-gdk.h"
#include <inkscape.h>
@@ -284,39 +285,21 @@ filterIndexed(PotraceTracingEngine &engine, GdkPixbuf * pixbuf)
IndexedMap *newGm = NULL;
- /*### Color quant multiscan ###*/
- if (engine.getTraceType() == TRACE_QUANT_COLOR)
+ RgbMap *gm = gdkPixbufToRgbMap(pixbuf);
+ if (engine.getMultiScanSmooth())
{
- RgbMap *gm = gdkPixbufToRgbMap(pixbuf);
- if (engine.getMultiScanSmooth())
- {
- RgbMap *gaussMap = rgbMapGaussian(gm);
- newGm = rgbMapQuantize(gaussMap, (int)log2(engine.getMultiScanNrColors())+2, engine.getMultiScanNrColors());
- gaussMap->destroy(gaussMap);
- }
- else
- {
- newGm = rgbMapQuantize(gm, (int)log2(engine.getMultiScanNrColors())+2, engine.getMultiScanNrColors());
- }
- gm->destroy(gm);
- }
-
- /*### Quant multiscan ###*/
- else if (engine.getTraceType() == TRACE_QUANT_MONO)
+ RgbMap *gaussMap = rgbMapGaussian(gm);
+ newGm = rgbMapQuantize(gaussMap, engine.getMultiScanNrColors());
+ gaussMap->destroy(gaussMap);
+ }
+ else
{
- RgbMap *gm = gdkPixbufToRgbMap(pixbuf);
- if (engine.getMultiScanSmooth())
- {
- RgbMap *gaussMap = rgbMapGaussian(gm);
- newGm = rgbMapQuantize(gaussMap, (int)log2(engine.getMultiScanNrColors())+2, engine.getMultiScanNrColors());
- gaussMap->destroy(gaussMap);
- }
- else
- {
- newGm = rgbMapQuantize(gm, (int)log2(engine.getMultiScanNrColors())+2, engine.getMultiScanNrColors());
- }
- gm->destroy(gm);
+ newGm = rgbMapQuantize(gm, engine.getMultiScanNrColors());
+ }
+ gm->destroy(gm);
+ if (engine.getTraceType() == TRACE_QUANT_MONO)
+ {
//Turn to grays
for (int i=0 ; i<newGm->nrColors ; i++)
{
@@ -571,14 +554,9 @@ PotraceTracingEngine::traceQuant(GdkPixbuf * thePixbuf)
{
int indx = (int) iMap->getPixel(iMap, col, row);
if (indx == colorIndex)
- {
gm->setPixel(gm, col, row, GRAYMAP_BLACK); //black
- }
- else
- {
- if (!multiScanStack)
- gm->setPixel(gm, col, row, GRAYMAP_WHITE);//white
- }
+ else if (!multiScanStack)
+ gm->setPixel(gm, col, row, GRAYMAP_WHITE); //white
}
}