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());
}
Beispiel #2
0
void ZoomImage(Magick::Image& dst, const Magick::Image& src, int width, int height)
{
    MagickLib::ExceptionInfo exceptionInfo;
    MagickLib::GetExceptionInfo( &exceptionInfo );

    MagickLib::Image* newImage = MagickLib::ZoomImage( src.constImage(), width, height,
    //MagickLib::Image* newImage = Img::ZoomImage( src.constImage(), width, height,
                 &exceptionInfo);

    dst.replaceImage( newImage );
    Magick::throwException( exceptionInfo );
}