Пример #1
0
void Magick::Options::magick ( const std::string &magick_ )
{
  FormatLocaleString(_imageInfo->filename,MaxTextExtent,"%.1024s:",
    magick_.c_str());
  GetPPException;
  SetImageInfo(_imageInfo,1,&exceptionInfo);
  if (*_imageInfo->magick == '\0')
    throwExceptionExplicit(OptionWarning,"Unrecognized image format",
      magick_.c_str());
  (void) DestroyExceptionInfo(&exceptionInfo);
}
Пример #2
0
void Magick::PixelData::init(Magick::Image &image_,const ::ssize_t x_,
  const ::ssize_t y_,const size_t width_,const size_t height_,
  std::string map_,const StorageType type_)
{
  size_t
    size;

  _data=(void *) NULL;
  _length=0;
  _size=0;
  if ((x_ < 0) || (width_ == 0) || (y_ < 0) || (height_ == 0) ||
      (x_ > image_.columns()) || ((width_ + x_) > image_.columns())
      || (y_ > image_.rows()) || ((height_ + y_) > image_.rows())
      || (map_.length() == 0))
    return;

  switch(type_)
  {
    case CharPixel:
      size=sizeof(unsigned char);
      break;
    case DoublePixel:
      size=sizeof(double);
      break;
    case FloatPixel:
      size=sizeof(float);
      break;
    case IntegerPixel:
    case LongPixel:
      size=sizeof(unsigned int);
      break;
    case QuantumPixel:
      size=sizeof(Quantum);
      break;
    case ShortPixel:
      size=sizeof(unsigned short);
      break;
    default:
      throwExceptionExplicit(OptionError,"Invalid type");
      return;
  }

  _length=width_*height_*map_.length();
  _size=_length*size;
  _data=AcquireMagickMemory(_size);

  GetPPException;
  MagickCore::ExportImagePixels(image_.constImage(),x_,y_,width_,height_,
    map_.c_str(),type_,_data,exceptionInfo);
  if (exceptionInfo->severity != UndefinedException)
    relinquish();
  ThrowPPException(image_.quiet());
}
Пример #3
0
void Magick::Options::magick ( const std::string &magick_ )
{
  ExceptionInfo exception;

  FormatString( _imageInfo->filename, "%.1024s:", magick_.c_str() );
  GetExceptionInfo(&exception);
  SetImageInfo( _imageInfo, MagickTrue, &exception);
  if ( *_imageInfo->magick == '\0' )
    throwExceptionExplicit( OptionWarning,
			    "Unrecognized image format",
			    magick_.c_str() );
}
Пример #4
0
// Default constructor
Magick::MutexLock::MutexLock(void)
#if defined(MAGICKCORE_HAVE_PTHREAD)
  // POSIX threads
  : _mutex()
{
  ::pthread_mutexattr_t attr;
  int sysError;
  if ( (sysError = ::pthread_mutexattr_init( &attr )) == 0 )
    if ( (sysError = ::pthread_mutex_init( &_mutex, &attr )) == 0 )
      {
        ::pthread_mutexattr_destroy( &attr );
        return;
      }
  throwExceptionExplicit( OptionError, "mutex initialization failed",
                          strerror(sysError) );
}
Пример #5
0
void Magick::Options::magick(const std::string &magick_)
{
  if (magick_.empty())
  {
    _imageInfo->magick[0] = '\0';
    return;
  }

  FormatLocaleString(_imageInfo->filename,MagickPathExtent,"%.1024s:",
    magick_.c_str());
  GetPPException;
  SetImageInfo(_imageInfo,1,exceptionInfo);
  if ( _imageInfo->magick[0] == '\0' )
    throwExceptionExplicit(MagickCore::OptionError,"Unrecognized image format",
      magick_.c_str());
  ThrowPPException(_quiet);
}
Пример #6
0
void Magick::Options::strokeDashArray(const double *strokeDashArray_)
{
  _drawInfo->dash_pattern=(double *) RelinquishMagickMemory(
    _drawInfo->dash_pattern);

  if(strokeDashArray_)
    {
      size_t
        x;
      // Count elements in dash array
      for (x=0; strokeDashArray_[x]; x++) ;
      // Allocate elements
      _drawInfo->dash_pattern=static_cast<double*>(AcquireMagickMemory((x+1)*
        sizeof(double)));
      if (!_drawInfo->dash_pattern)
        throwExceptionExplicit(MagickCore::ResourceLimitError,
          "Unable to allocate dash-pattern memory");
      // Copy elements
      memcpy(_drawInfo->dash_pattern,strokeDashArray_,(x+1)*sizeof(double));
      _drawInfo->dash_pattern[x]=0.0;
    }
}