Пример #1
0
bool ProcessInstance::CanExecuteOn( const ImageVariant& image, String& whyNot ) const
{
   if ( !image.IsSharedImage() || !image.IsCompletelySelected() )
   {
      ImageVariant tmp;
      tmp.CreateSharedImageAs( image ).AssignImage( image );
      return CanExecuteOn( tmp, whyNot );
   }

   image.PushSelections();
   image.ResetSelections();

   ImageInfo info1( *image );

   image.PopSelections();

   whyNot.Clear();
   whyNot.Reserve( WHYNOT_MAXLENGTH );

   bool ok = (*API->Process->ValidateImageExecution)( handle, image.SharedImageHandle(), whyNot.c_str(), WHYNOT_MAXLENGTH ) != api_false;

   image.PushSelections();
   image.ResetSelections();

   ImageInfo info2( *image );

   image.PopSelections();

   if ( info1 != info2 )
      APIHackingAttempt( "ValidateImageExecution" );

   return ok;
}
Пример #2
0
bool FileFormatInstance::Embed( const ICCProfile& icc )
{
   try
   {
      if ( (*API->FileFormat->BeginICCProfileEmbedding)( handle ) == api_false )
         return false;

      bool ok = true;

      if ( icc.IsProfile() ) // ### should allow embedding empty profiles ?
      {
         ICCProfile safeCopy = icc;
         ok = (*API->FileFormat->SetICCProfile)( handle, safeCopy.ProfileData().Begin() ) != api_false;

         if ( !safeCopy.IsSameProfile( icc ) || safeCopy.FilePath() != icc.FilePath() )
            APIHackingAttempt( "SetICCProfile" );
      }

      (*API->FileFormat->EndICCProfileEmbedding)( handle );

      return ok;
   }
   catch ( ... )
   {
      (*API->FileFormat->EndICCProfileEmbedding)( handle );
      throw;
   }
}
Пример #3
0
   static bool WriteImage( FileFormatInstance* instance, const I& image )
   {
      if ( !image.IsShared() || !image.IsCompletelySelected() )
      {
         I tmp( (void*)0, 0, 0 );
         tmp.Assign( image );
         return WriteImage( instance, tmp );
      }

      image.PushSelections();
      image.ResetSelections();

      ImageInfo info1( image );

      image.PopSelections();

      bool ok = (*API->FileFormat->WriteImage)( instance->handle, image.Allocator().Handle() ) != api_false;

      image.PushSelections();
      image.ResetSelections();

      ImageInfo info2( image );

      image.PopSelections();

      if ( info1 != info2 )
         APIHackingAttempt( "WriteImage" );

      return ok;
   }
Пример #4
0
bool FileFormatInstance::WriteColorFilterArray( const ColorFilterArray& cfa )
{
   try
   {
      if ( (*API->FileFormat->BeginColorFilterArrayEmbedding)( handle ) == api_false )
         return false;

      IsoString pattern = cfa.Pattern();
      pattern.EnsureUnique();
      String name = cfa.Name();
      name.EnsureUnique();

      bool ok = (*API->FileFormat->SetImageColorFilterArray)( handle,
                           pattern.c_str(), cfa.Width(), cfa.Height(), name.c_str() ) != api_false;

      if ( cfa.Pattern() != pattern || cfa.Name() != name )
         APIHackingAttempt( "WriteColorFilterArray" );

      (*API->FileFormat->EndColorFilterArrayEmbedding)( handle );
      return ok;
   }
   catch ( ... )
   {
      (*API->FileFormat->EndColorFilterArrayEmbedding)( handle );
      throw;
   }
}
Пример #5
0
bool FileFormatInstance::WriteDisplayFunction( const DisplayFunction& df )
{
   try
   {
      if ( (*API->FileFormat->BeginDisplayFunctionEmbedding)( handle ) == api_false )
         return false;

      DVector m, s, h, l, r;
      df.GetDisplayFunctionParameters( m, s, h, l, r );

      bool ok = (*API->FileFormat->SetImageDisplayFunction)( handle, m.Begin(), s.Begin(), h.Begin(), l.Begin(), r.Begin() ) != api_false;

      DVector m1, s1, h1, l1, r1;
      df.GetDisplayFunctionParameters( m1, s1, h1, l1, r1 );
      if ( m1 != m || s1 != s || h1 != h || l1 != l || r1 != r )
         APIHackingAttempt( "WriteDisplayFunction" );

      (*API->FileFormat->EndDisplayFunctionEmbedding)( handle );
      return ok;
   }
   catch ( ... )
   {
      (*API->FileFormat->EndDisplayFunctionEmbedding)( handle );
      throw;
   }
}
Пример #6
0
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;
   }
}
Пример #7
0
bool FileFormatInstance::WriteProperty( const IsoString& property, const Variant& value )
{
   try
   {
      if ( (*API->FileFormat->BeginPropertyEmbedding)( handle ) == api_false )
         return false;

      bool ok = true;

      if ( value.IsValid() )
      {
         api_property_value apiValue;
         APIPropertyValueFromVariant( apiValue, value );
         api_property_value safeCopy = apiValue;
         ok = (*API->FileFormat->SetImageProperty)( handle, property.c_str(), &safeCopy ) != api_false;

         if ( safeCopy.data.blockValue != apiValue.data.blockValue ||
              safeCopy.dimX != apiValue.dimX || safeCopy.dimY != apiValue.dimY ||
              safeCopy.dimZ != apiValue.dimZ || safeCopy.dimT != apiValue.dimT || safeCopy.type != apiValue.type )
         {
            APIHackingAttempt( "WriteProperty" );
         }
      }

      (*API->FileFormat->EndPropertyEmbedding)( handle );

      return ok;
   }
   catch ( ... )
   {
      (*API->FileFormat->EndPropertyEmbedding)( handle );
      throw;
   }
}
Пример #8
0
bool FileFormatInstance::Embed( const pcl::UInt8Image& thumbnail )
{
   try
   {
      if ( (*API->FileFormat->BeginThumbnailEmbedding)( handle ) == api_false )
         return false;

      thumbnail.PushSelections();
      thumbnail.ResetSelections();

      ImageInfo info( thumbnail );

      thumbnail.PopSelections();

      bool ok;

      if ( thumbnail.IsShared() )
         ok = (*API->FileFormat->SetThumbnail)( handle, thumbnail.Allocator().Handle() ) != api_false;
      else
      {
         UInt8Image tmp( (void*)0, 0, 0 );
         tmp.Assign( thumbnail );
         ok = (*API->FileFormat->SetThumbnail)( handle, tmp.Allocator().Handle() ) != api_false;
      }

      thumbnail.PushSelections();
      thumbnail.ResetSelections();

      if ( info != ImageInfo( thumbnail ) )
         APIHackingAttempt( "SetThumbnail" );

      thumbnail.PopSelections();

      (*API->FileFormat->EndThumbnailEmbedding)( handle );

      return ok;
   }
   catch ( ... )
   {
      if ( thumbnail.CanPopSelections() )
         thumbnail.PopSelections();
      (*API->FileFormat->EndThumbnailEmbedding)( handle );
      throw;
   }
}