~ubuntu-branches/ubuntu/precise/inkscape/precise-updates

« back to all changes in this revision

Viewing changes to src/trace/quantize.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alex Valavanis
  • Date: 2010-09-12 19:44:58 UTC
  • mfrom: (1.1.12 upstream) (45.1.3 maverick)
  • Revision ID: james.westby@ubuntu.com-20100912194458-4sjwmbl7dlsrk5dc
Tags: 0.48.0-1ubuntu1
* Merge with Debian unstable (LP: #628048, LP: #401567, LP: #456248, 
  LP: #463602, LP: #591986)
* debian/control: 
  - Ubuntu maintainers
  - Promote python-lxml, python-numpy, python-uniconvertor to Recommends.
  - Demote pstoedit to Suggests (universe package).
  - Suggests ttf-dejavu instead of ttf-bitstream-vera (LP: #513319)
* debian/rules:
  - Run intltool-update on build (Ubuntu-specific).
  - Add translation domain to .desktop files (Ubuntu-specific).
* debian/dirs:
  - Add usr/share/pixmaps.  Allow inkscape.xpm installation
* drop 50-poppler-API.dpatch (now upstream)
* drop 51-paste-in-unwritable-directory.dpatch (now upstream) 

Show diffs side-by-side

added added

removed removed

Lines of Context:
545
545
    assert(rgbmap);
546
546
    assert(ncolor > 0);
547
547
 
 
548
    IndexedMap *newmap = 0;
 
549
 
548
550
    pool<Ocnode> pool;
549
551
 
550
 
    Ocnode *tree;
 
552
    Ocnode *tree = 0;
551
553
    try {
552
 
      tree = octreeBuild(&pool, rgbmap, ncolor);
553
 
    }
554
 
    catch (std::bad_alloc& ex) {
555
 
      return NULL; //should do smthg else?
556
 
    }
557
 
 
558
 
    RGB *rgbpal = new RGB[ncolor];
559
 
    int indexes = 0;
560
 
    octreeIndex(tree, rgbpal, &indexes);
561
 
 
562
 
    octreeDelete(&pool, tree);
563
 
 
564
 
    // stacking with increasing contrasts
565
 
    qsort((void *)rgbpal, indexes, sizeof(RGB), compRGB);
566
 
 
567
 
    // make the new map
568
 
    IndexedMap *newmap = IndexedMapCreate(rgbmap->width, rgbmap->height);
569
 
    if (!newmap) { delete rgbpal; return NULL; }
570
 
 
571
 
    // fill in the color lookup table
572
 
    for (int i = 0; i < indexes; i++) newmap->clut[i] = rgbpal[i];
573
 
    newmap->nrColors = indexes;
574
 
 
575
 
    // fill in new map pixels
576
 
    for (int y = 0; y < rgbmap->height; y++)
577
 
        {
578
 
        for (int x = 0; x < rgbmap->width; x++)
579
 
            {
580
 
            RGB rgb = rgbmap->getPixel(rgbmap, x, y);
581
 
            int index = findRGB(rgbpal, ncolor, rgb);
582
 
            newmap->setPixel(newmap, x, y, index);
 
554
        tree = octreeBuild(&pool, rgbmap, ncolor);
 
555
    }
 
556
    catch (std::bad_alloc &ex) {
 
557
        //should do smthg else?
 
558
    }
 
559
 
 
560
    if ( tree ) {
 
561
        RGB *rgbpal = new RGB[ncolor];
 
562
        int indexes = 0;
 
563
        octreeIndex(tree, rgbpal, &indexes);
 
564
 
 
565
        octreeDelete(&pool, tree);
 
566
 
 
567
        // stacking with increasing contrasts
 
568
        qsort((void *)rgbpal, indexes, sizeof(RGB), compRGB);
 
569
 
 
570
        // make the new map
 
571
        newmap = IndexedMapCreate(rgbmap->width, rgbmap->height);
 
572
        if (newmap) {
 
573
            // fill in the color lookup table
 
574
            for (int i = 0; i < indexes; i++) {
 
575
                newmap->clut[i] = rgbpal[i];
 
576
            }
 
577
            newmap->nrColors = indexes;
 
578
 
 
579
            // fill in new map pixels
 
580
            for (int y = 0; y < rgbmap->height; y++) {
 
581
                for (int x = 0; x < rgbmap->width; x++) {
 
582
                    RGB rgb = rgbmap->getPixel(rgbmap, x, y);
 
583
                    int index = findRGB(rgbpal, ncolor, rgb);
 
584
                    newmap->setPixel(newmap, x, y, index);
 
585
                }
583
586
            }
584
587
        }
 
588
        delete[] rgbpal;
 
589
    }
585
590
 
586
 
    delete rgbpal;
587
591
    return newmap;
588
592
}