index 60b55bbe909022d7205d37a264c0a3919645e624..43a2a3cbe7ef7a573aef17ab06cb22e5442976b3 100644 (file)
#if ENABLE_LCMS
_profChangedID = g_signal_connect( G_OBJECT(_profileSel), "changed", G_CALLBACK(_profileSelected), (gpointer)this );
- gtk_widget_set_sensitive( _profileSel, false ); // temporary
#else
gtk_widget_set_sensitive( _profileSel, false );
#endif // ENABLE_LCMS
}
-void ColorICCSelector::_fixupHit( GtkWidget* src, gpointer data )
+void ColorICCSelector::_fixupHit( GtkWidget* /*src*/, gpointer data )
{
- (void)src;
ColorICCSelector* self = reinterpret_cast<ColorICCSelector*>(data);
gtk_widget_set_sensitive( self->_fixupBtn, FALSE );
self->_adjustmentChanged( self->_fooAdj[0], SP_COLOR_ICC_SELECTOR(self->_csel) );
}
#if ENABLE_LCMS
-void ColorICCSelector::_profileSelected( GtkWidget* src, gpointer data )
+void ColorICCSelector::_profileSelected( GtkWidget* /*src*/, gpointer data )
{
- (void)src;
ColorICCSelector* self = reinterpret_cast<ColorICCSelector*>(data);
gint activeIndex = gtk_combo_box_get_active( GTK_COMBO_BOX(self->_profileSel) );
gchar* name = (activeIndex != 0) ? gtk_combo_box_get_active_text( GTK_COMBO_BOX(self->_profileSel) ) : 0;
- //self->_switchToProfile( name );
+ self->_switchToProfile( name );
if ( name ) {
g_free( name );
}
}
#endif // ENABLE_LCMS
+#ifdef ENABLE_LCMS
void ColorICCSelector::_switchToProfile( gchar const* name )
{
bool dirty = false;
if ( name ) {
if ( tmp.icc && tmp.icc->colorProfile == name ) {
- g_message("Already at name [%s]", name );
+#ifdef DEBUG_LCMS
+ g_message("Already at name [%s]", name );
+#endif // DEBUG_LCMS
} else {
- g_message("Need to switch to profile [%s]", name );
+#ifdef DEBUG_LCMS
+ g_message("Need to switch to profile [%s]", name );
+#endif // DEBUG_LCMS
if ( tmp.icc ) {
tmp.icc->colors.clear();
} else {
tmp.icc = new SVGICCColor();
}
tmp.icc->colorProfile = name;
+ Inkscape::ColorProfile* newProf = SP_ACTIVE_DOCUMENT->profileManager->find(name);
+ if ( newProf ) {
+ cmsHTRANSFORM trans = newProf->getTransfFromSRGB8();
+ if ( trans ) {
+ guint32 val = _color.toRGBA32(0);
+ guchar pre[4] = {
+ SP_RGBA32_R_U(val),
+ SP_RGBA32_G_U(val),
+ SP_RGBA32_B_U(val),
+ 255};
+#ifdef DEBUG_LCMS
+ g_message("Shoving in [%02x] [%02x] [%02x]", pre[0], pre[1], pre[2]);
+#endif // DEBUG_LCMS
+ icUInt16Number post[4] = {0,0,0,0};
+ cmsDoTransform( trans, pre, post, 1 );
+#ifdef DEBUG_LCMS
+ g_message("got on out [%04x] [%04x] [%04x] [%04x]", post[0], post[1], post[2], post[3]);
+#endif // DEBUG_LCMS
+ guint count = _cmsChannelsOf( newProf->getColorSpace() );
+
+ gchar const** names = 0;
+ gchar const** tips = 0;
+ guint const* scales = 0;
+ getThings( newProf->getColorSpace(), names, tips, scales );
+
+ for ( guint i = 0; i < count; i++ ) {
+ gdouble val = (((gdouble)post[i])/65535.0) * (gdouble)scales[i];
+#ifdef DEBUG_LCMS
+ g_message(" scaled %d by %d to be %f", i, scales[i], val);
+#endif // DEBUG_LCMS
+ tmp.icc->colors.push_back(val);
+ }
+ cmsHTRANSFORM retrans = newProf->getTransfToSRGB8();
+ if ( retrans ) {
+ cmsDoTransform( retrans, post, pre, 1 );
+#ifdef DEBUG_LCMS
+ g_message(" back out [%02x] [%02x] [%02x]", pre[0], pre[1], pre[2]);
+#endif // DEBUG_LCMS
+ tmp.set(SP_RGBA32_U_COMPOSE(pre[0], pre[1], pre[2], 0xff));
+ }
+ }
+ }
dirty = true;
}
} else {
- g_message("NUKE THE ICC");
+#ifdef DEBUG_LCMS
+ g_message("NUKE THE ICC");
+#endif // DEBUG_LCMS
if ( tmp.icc ) {
delete tmp.icc;
tmp.icc = 0;
dirty = true;
+ _fixupHit( 0, this );
} else {
- g_message("No icc to nuke");
+#ifdef DEBUG_LCMS
+ g_message("No icc to nuke");
+#endif // DEBUG_LCMS
}
}
if ( dirty ) {
+#ifdef DEBUG_LCMS
+ g_message("+----------------");
+ g_message("+ new color is [%s]", tmp.toString().c_str());
+#endif // DEBUG_LCMS
_setProfile( tmp.icc );
- // Set the color now.
-
+ //_adjustmentChanged( _fooAdj[0], SP_COLOR_ICC_SELECTOR(_csel) );
+ setColorAlpha( tmp, _alpha, true );
+#ifdef DEBUG_LCMS
+ g_message("+_________________");
+#endif // DEBUG_LCMS
}
}
+#endif // ENABLE_LCMS
void ColorICCSelector::_profilesChanged( std::string const & name )
{
+#ifdef ENABLE_LCMS
GtkComboBox* combo = GTK_COMBO_BOX(_profileSel);
g_signal_handler_block( G_OBJECT(_profileSel), _profChangedID );
}
g_signal_handler_unblock( G_OBJECT(_profileSel), _profChangedID );
+#endif // ENABLE_LCMS
}
/* Helpers for setting color value */
#ifdef DEBUG_LCMS
g_message( "/^^^^^^^^^ %p::_colorChanged(%08x:%s)", this,
- color.toRGBA32(alpha), ( (color.icc) ? color.icc->colorProfile.c_str(): "<null>" )
+ _color.toRGBA32(_alpha), ( (_color.icc) ? _color.icc->colorProfile.c_str(): "<null>" )
);
#endif // DEBUG_LCMS
#ifdef DEBUG_LCMS
- g_message("FLIPPIES!!!! %p '%s'", color.icc, (color.icc?color.icc->colorProfile.c_str():"<null>"));
+ g_message("FLIPPIES!!!! %p '%s'", _color.icc, (_color.icc ? _color.icc->colorProfile.c_str():"<null>"));
#endif // DEBUG_LCMS
_profilesChanged( (_color.icc) ? _color.icc->colorProfile : std::string("") );
if ( other != _color.toRGBA32(255) ) {
_fixupNeeded = other;
gtk_widget_set_sensitive( _fixupBtn, TRUE );
- //g_message("Color needs to change 0x%06x to 0x%06x", color.toRGBA32(255) >> 8, other >> 8 );
+#ifdef DEBUG_LCMS
+ g_message("Color needs to change 0x%06x to 0x%06x", _color.toRGBA32(255) >> 8, other >> 8 );
+#endif // DEBUG_LCMS
}
}
#else
- (void)color;
+ //(void)color;
#endif // ENABLE_LCMS
_updateSliders( -1 );
@@ -818,10 +879,8 @@ void ColorICCSelector::_adjustmentChanged( GtkAdjustment *adjustment, SPColorICC
#endif // DEBUG_LCMS
}
-void ColorICCSelector::_sliderGrabbed( SPColorSlider *slider, SPColorICCSelector *cs )
+void ColorICCSelector::_sliderGrabbed( SPColorSlider */*slider*/, SPColorICCSelector */*cs*/ )
{
- (void)slider;
- (void)cs;
// ColorICCSelector* iccSelector = (ColorICCSelector*)(SP_COLOR_SELECTOR(cs)->base);
// if (!iccSelector->_dragging) {
// iccSelector->_dragging = TRUE;
@@ -830,10 +889,8 @@ void ColorICCSelector::_sliderGrabbed( SPColorSlider *slider, SPColorICCSelector
// }
}
-void ColorICCSelector::_sliderReleased( SPColorSlider *slider, SPColorICCSelector *cs )
+void ColorICCSelector::_sliderReleased( SPColorSlider */*slider*/, SPColorICCSelector */*cs*/ )
{
- (void)slider;
- (void)cs;
// ColorICCSelector* iccSelector = (ColorICCSelector*)(SP_COLOR_SELECTOR(cs)->base);
// if (iccSelector->_dragging) {
// iccSelector->_dragging = FALSE;
@@ -842,10 +899,12 @@ void ColorICCSelector::_sliderReleased( SPColorSlider *slider, SPColorICCSelecto
// }
}
+#ifdef DEBUG_LCMS
void ColorICCSelector::_sliderChanged( SPColorSlider *slider, SPColorICCSelector *cs )
+#else
+void ColorICCSelector::_sliderChanged( SPColorSlider */*slider*/, SPColorICCSelector */*cs*/ )
+#endif // DEBUG_LCMS
{
- (void)slider;
- (void)cs;
#ifdef DEBUG_LCMS
g_message("Changed %p and %p", slider, cs );
#endif // DEBUG_LCMS