~ubuntu-branches/ubuntu/utopic/inkscape/utopic-proposed

« back to all changes in this revision

Viewing changes to src/svg/svg-color.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:
36
36
#include "svg-color.h"
37
37
#include "svg-icc-color.h"
38
38
 
 
39
#if ENABLE_LCMS
 
40
#include <lcms.h>
 
41
#include "color.h"
 
42
#include "color-profile.h"
 
43
#include "document.h"
 
44
#include "inkscape.h"
 
45
#include "profile-manager.h"
 
46
#endif // ENABLE_LCMS
 
47
 
39
48
using std::sprintf;
40
49
 
41
50
struct SPSVGColor {
341
350
     * this check wrapper. */
342
351
    gchar const *end = str;
343
352
    guint32 const ret = internal_sp_svg_read_color(str, &end, dfl);
344
 
    assert(ret == dfl && end == str
 
353
    assert(((ret == dfl) && (end == str))
345
354
           || (((ret & 0xff) == 0)
346
 
               && str < end));
 
355
               && (str < end)));
347
356
    if (str < end) {
348
357
        gchar *buf = (gchar *) g_malloc(end + 1 - str);
349
358
        memcpy(buf, str, end - str);
454
463
    return colors;
455
464
}
456
465
 
 
466
#if ENABLE_LCMS
 
467
//helper function borrowed from src/widgets/sp-color-icc-selector.cpp:
 
468
void getThings( DWORD space, gchar const**& namers, gchar const**& tippies, guint const*& scalies );
 
469
 
 
470
void icc_color_to_sRGB(SVGICCColor* icc, guchar* r, guchar* g, guchar* b){
 
471
    guchar color_out[4];
 
472
    guchar color_in[4];
 
473
    if (icc){
 
474
g_message("profile name: %s", icc->colorProfile.c_str());
 
475
        Inkscape::ColorProfile* prof = SP_ACTIVE_DOCUMENT->profileManager->find(icc->colorProfile.c_str());
 
476
        if ( prof ) {
 
477
            cmsHTRANSFORM trans = prof->getTransfToSRGB8();
 
478
            if ( trans ) {
 
479
                gchar const** names = 0;
 
480
                gchar const** tips = 0;
 
481
                guint const* scales = 0;
 
482
                getThings( prof->getColorSpace(), names, tips, scales );
 
483
 
 
484
                guint count = _cmsChannelsOf( prof->getColorSpace() );
 
485
                if (count>4) count=4; //do we need it? Should we allow an arbitrary number of color values? Or should we limit to a maximum? (max==4?)
 
486
                for (guint i=0;i<count; i++){
 
487
                    color_in[i] = (guchar) ((((gdouble)icc->colors[i])*256.0) * (gdouble)scales[i]);
 
488
g_message("input[%d]: %d",i, color_in[i]);
 
489
                }
 
490
 
 
491
                cmsDoTransform( trans, color_in, color_out, 1 );
 
492
g_message("transform to sRGB done");
 
493
            }
 
494
            *r = color_out[0];
 
495
            *g = color_out[1];
 
496
            *b = color_out[2];
 
497
        }
 
498
    }
 
499
}
 
500
#endif //ENABLE_LCMS
 
501
 
457
502
/*
458
503
 * Some discussion at http://markmail.org/message/bhfvdfptt25kgtmj
459
504
 * Allowed ASCII first characters:  ':', 'A'-'Z', '_', 'a'-'z'
536
581
            while ( g_ascii_isspace(*str) ) {
537
582
                str++;
538
583
            }
539
 
            good &= *str == ')';
 
584
            good &= (*str == ')');
540
585
        }
541
586
    }
542
587
 
554
599
    return good;
555
600
}
556
601
 
 
602
 
 
603
bool sp_svg_read_icc_color( gchar const *str, SVGICCColor* dest )
 
604
{
 
605
    return sp_svg_read_icc_color(str, NULL, dest);
 
606
}
 
607
 
 
608
 
557
609
/*
558
610
  Local Variables:
559
611
  mode:c++