bool FileFormatInstance::WriteRGBWS( const RGBColorSystem& rgbws ) { try { if ( (*API->FileFormat->BeginRGBWSEmbedding)( handle ) == api_false ) return false; float gamma = rgbws.Gamma(); api_bool issRGB = rgbws.IsSRGB(); FVector x = rgbws.ChromaticityXCoordinates(); FVector y = rgbws.ChromaticityYCoordinates(); FVector Y = rgbws.LuminanceCoefficients(); bool ok = (*API->FileFormat->SetImageRGBWS)( handle, gamma, issRGB, x.Begin(), y.Begin(), Y.Begin() ) != api_false; if ( rgbws.Gamma() != gamma || rgbws.IsSRGB() != (issRGB != api_false) || rgbws.ChromaticityXCoordinates() != x || rgbws.ChromaticityYCoordinates() != y || rgbws.LuminanceCoefficients() != Y ) { APIHackingAttempt( "WriteRGBWS" ); } (*API->FileFormat->EndRGBWSEmbedding)( handle ); return ok; } catch ( ... ) { (*API->FileFormat->EndRGBWSEmbedding)( handle ); throw; } }
void NewImageInterface::UpdateReadout( const View& v, const DPoint&, double R, double G, double B, double A ) { if ( GUI != 0 && IsVisible() ) { if ( ISCOLOR || !v.IsColor() ) { instance.v0 = R; instance.v1 = G; instance.v2 = B; } else { RGBColorSystem rgb; v.Window().GetRGBWS( rgb ); instance.v0 = instance.v1 = instance.v2 = rgb.Lightness( R, G, B ); } GUI->V0_NumericControl.SetValue( instance.v0 ); GUI->V1_NumericControl.SetValue( instance.v1 ); GUI->V2_NumericControl.SetValue( instance.v2 ); if ( HASALPHA ) { instance.va = A; GUI->VA_NumericControl.SetValue( instance.va ); } GUI->ColorSample_Control.Update(); } }
bool FileFormatInstance::ReadRGBWS( RGBColorSystem& rgbws ) { try { rgbws = RGBColorSystem(); if ( (*API->FileFormat->BeginRGBWSExtraction)( handle ) == api_false ) return false; float gamma = rgbws.Gamma(); api_bool issRGB = rgbws.IsSRGB(); FVector x = rgbws.ChromaticityXCoordinates(); FVector y = rgbws.ChromaticityYCoordinates(); FVector Y = rgbws.LuminanceCoefficients(); bool ok = (*API->FileFormat->GetImageRGBWS)( handle, &gamma, &issRGB, x.Begin(), y.Begin(), Y.Begin() ) != api_false; if ( ok ) rgbws = RGBColorSystem( gamma, issRGB, x, y, Y ); (*API->FileFormat->EndRGBWSExtraction)( handle ); return ok; } catch ( ... ) { (*API->FileFormat->EndRGBWSExtraction)( handle ); throw; } }
RGBWorkingSpaceInstance::RGBWorkingSpaceInstance( const MetaProcess* P, const RGBColorSystem& rgbws ) : ProcessImplementation( P ), Y( rgbws.LuminanceCoefficients() ), x( rgbws.ChromaticityXCoordinates() ), y( rgbws.ChromaticityYCoordinates() ), gamma( rgbws.Gamma() ), sRGB( rgbws.IsSRGB() ), applyGlobalRGBWS( false ) { }
void BinarizeInterface::UpdateReadout( const View& v, const DPoint&, double R, double G, double B, double /*A*/ ) { if ( GUI != 0 && IsVisible() ) { if ( instance.isGlobal ) { RGBColorSystem rgbws; v.Window().GetRGBWS( rgbws ); instance.level[0] = instance.level[1] = instance.level[2] = rgbws.Lightness( R, G, B ); } else { instance.level[0] = R; instance.level[1] = G; instance.level[2] = B; } UpdateControls(); if ( !RealTimePreview::IsUpdating() ) RealTimePreview::Update(); } }
static void ToRGB( int colorSpace, const RGBColorSystem& rgbws, RGBColorSystem::sample& r, RGBColorSystem::sample& g, RGBColorSystem::sample& b, RGBColorSystem::sample ch0, RGBColorSystem::sample ch1, RGBColorSystem::sample ch2 ) { switch ( colorSpace ) { case ColorSpaceId::CIEXYZ: rgbws.CIEXYZToRGB( r, g, b, ch0, ch1, ch2 ); break; case ColorSpaceId::CIELab: rgbws.CIELabToRGB( r, g, b, ch0, ch1, ch2 ); break; case ColorSpaceId::CIELch: rgbws.CIELchToRGB( r, g, b, ch0, ch1, ch2 ); break; case ColorSpaceId::HSV: rgbws.HSVToRGB( r, g, b, ch0, ch1, ch2 ); break; case ColorSpaceId::HSI: rgbws.HSIToRGB( r, g, b, ch0, ch1, ch2 ); break; } }
static void FromRGB( int colorSpace, const RGBColorSystem& rgbws, RGBColorSystem::sample& ch0, RGBColorSystem::sample& ch1, RGBColorSystem::sample& ch2, RGBColorSystem::sample r, RGBColorSystem::sample g, RGBColorSystem::sample b ) { switch ( colorSpace ) { case ColorSpaceId::CIEXYZ: rgbws.RGBToCIEXYZ( ch0, ch1, ch2, r, g, b ); break; case ColorSpaceId::CIELab: rgbws.RGBToCIELab( ch0, ch1, ch2, r, g, b ); break; case ColorSpaceId::CIELch: rgbws.RGBToCIELch( ch0, ch1, ch2, r, g, b ); break; case ColorSpaceId::HSV: rgbws.RGBToHSV( ch0, ch1, ch2, r, g, b ); break; case ColorSpaceId::HSI: rgbws.RGBToHSI( ch0, ch1, ch2, r, g, b ); break; } }