当前位置: 首页>>代码示例>>C++>>正文


C++ Image::columns方法代码示例

本文整理汇总了C++中magick::Image::columns方法的典型用法代码示例。如果您正苦于以下问题:C++ Image::columns方法的具体用法?C++ Image::columns怎么用?C++ Image::columns使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在magick::Image的用法示例。


在下文中一共展示了Image::columns方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: FromImage

BOOL CSBitmap::FromImage(Magick::Image & image)
{
	if(image.columns() > 0 && image.rows() > 0) {
		m_Column = image.columns();
		m_Row    = image.rows();
		if(NULL != m_pBuffer) {
			free(m_pBuffer);
			m_pBuffer = NULL;
		}

		m_pBuffer = (Pixel *)malloc(3 * m_Column * m_Row);
		if(NULL == m_pBuffer) {
			m_Column = m_Row = 0;
			return FALSE;
		}

		try {
			image.write(0,0,m_Column, m_Row, "RGB", MagickCore::CharPixel, m_pBuffer);
		}
		catch (const Magick::Error & err ) {
			free(m_pBuffer);
			m_Column = m_Row = 0;
			return FALSE; 	
		}

		return TRUE;

	}

	return FALSE;
}
开发者ID:sTeeLM,项目名称:shadowpack,代码行数:31,代码来源:SBitmap.cpp

示例2: switch

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());
}
开发者ID:CamiloBenavides,项目名称:SnoutPoint-Web,代码行数:53,代码来源:Pixels.cpp

示例3: DoYourJob

int SingleMaskConvolutionAlgorithm::DoYourJob(Magick::Image& image)
{
  image.modifyImage();
  Magick::Pixels pixelCache(image);
  Magick::PixelPacket* pixels;
  for(int x=0;x<image.columns();x++)
    {
      int rectangleWidth=ConvolutionMask.Width;
      int maskX=x-ConvolutionMask.Width/2;
      if(maskX<0)
        {
          rectangleWidth+=maskX;
          maskX=0;
        }
      if(maskX+rectangleWidth>image.columns())
        rectangleWidth=image.columns()-maskX;

      for(int y=0;y<image.rows();y++)
        {
          int rectangleHeight=ConvolutionMask.Height;
          int maskY=y-ConvolutionMask.Height/2;
          if(maskY<0)
            {
              rectangleHeight+=maskY;
              maskY=0;
            }
          if(maskY+rectangleHeight>image.rows())
            rectangleHeight=image.rows()-maskY;
          
          pixels=pixelCache.get(maskX,maskY,rectangleWidth,rectangleHeight);
          Magick::PixelPacket maskResult;
          maskResult.red=maskResult.green=maskResult.blue=0;

          for(int mx=0;mx<rectangleWidth;mx++)
            for(int my=0;my<rectangleHeight;my++)
              {
                maskResult.red+=ConvolutionMask[mx][my]*pixels[mx+rectangleWidth*my].red;
                maskResult.green+=ConvolutionMask[mx][my]*pixels[mx+rectangleWidth*my].green;
                maskResult.blue+=ConvolutionMask[mx][my]*pixels[mx+rectangleWidth*my].blue;
              }

          maskResult.red/=ConvolutionMask.Weight;
          maskResult.green/=ConvolutionMask.Weight;
          maskResult.blue/=ConvolutionMask.Weight;
          
          OperationPerPixel(pixels,x,y,&maskResult);
        }
    }
  pixelCache.sync();
  return 0;
}
开发者ID:ydxt25,项目名称:IM-2,代码行数:51,代码来源:basealgorithm.cpp

示例4: init

  void PipelineStabDetect::init(Magick::Image img) {
    width = img.columns();
    height = img.rows();

    if (!vsFrameInfoInit(&fi, width, height, PF_RGB24)) {
      throw runtime_error("Failed to initialize frame info");
    }
    fi.planes = 1; // I don't understand vs frame info... But later is assert for planes == 1

    if (vsMotionDetectInit(&md, &stabConf->mdConf, &fi) != VS_OK) {
      throw runtime_error("Initialization of Motion Detection failed, please report a BUG");
    }
    vsMotionDetectGetConfig(&stabConf->mdConf, &md);

    *verboseOutput << "Video stabilization settings (pass 1/2):" << endl;
    *verboseOutput << "     shakiness = " << stabConf->mdConf.shakiness << endl;
    *verboseOutput << "      accuracy = " << stabConf->mdConf.accuracy << endl;
    *verboseOutput << "      stepsize = " << stabConf->mdConf.stepSize << endl;
    *verboseOutput << "   mincontrast = " << stabConf->mdConf.contrastThreshold << endl;
    *verboseOutput << "        tripod = " << stabConf->mdConf.virtualTripod << endl;
    *verboseOutput << "          show = " << stabConf->mdConf.show << endl;
    *verboseOutput << "        result = " << stabConf->stabStateFile->fileName() << endl;


    //f = fopen(stabStateFile->fileName().toStdString(), "w");
    f = stabConf->openStabStateFile("w");
    if (vsPrepareFile(&md, f) != VS_OK) {
      throw runtime_error(QString("cannot write to transform file %1").arg(stabConf->stabStateFile->fileName()).toStdString());
    }

    initialized = true;
  }
开发者ID:Karry,项目名称:TimeLapse,代码行数:32,代码来源:pipeline_stab.cpp

示例5: glTexParameterf

void texture_t::load_2d( const string & file_name )
{
   Magick::Image img;

   img.read(file_name);

   glTexEnvf      (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
   glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
   glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

   int res_y = img.rows()
      ,res_x = img.columns();

   scoped_array<unsigned char> data(new unsigned char[res_x * res_y * 3]);

   img.write   (0, 0, res_x, res_y, "RGB", CharPixel, data.get());

   glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB16, res_x, res_y, 0, GL_RGB, GL_UNSIGNED_BYTE
                ,data.get());

   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

   glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
   glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
}
开发者ID:fedotovav,项目名称:test_engine,代码行数:26,代码来源:textures.cpp

示例6: load

//----------------------------------------------------------------------------------------------------------------------
// Image Magick Image loading routines
//----------------------------------------------------------------------------------------------------------------------
bool Image::load( const std::string &_fname  ) noexcept
{
  #ifdef IMAGE_DEBUG_ON
  std::cerr<<"loading with ImageMagick"<<std::endl;
  #endif
  Magick::Image image;
  Magick::Blob blob;

  try
  {
    image.read(_fname);
    // need to flip image as OpenGL uses textures starting the other way round.
    image.flip();
    image.write(&blob, "RGBA");
  }
  catch (Magick::Error& Error)
  {
  std::cout << "Error loading texture '" << _fname << "': " << Error.what() << std::endl;
  return false;
  }
  m_width=image.columns();
  m_height=image.rows();
  m_channels=4;
  m_format=GL_RGBA;
  m_data.reset(new unsigned char[ m_width*m_height*m_channels]);
  // simple memcpy of the blob data to our internal data, not worrying about RGB/RGBA
  // here (as OpenGL doesn't really either).
  memcpy(m_data.get(),blob.data(),blob.length());
  return true;
}
开发者ID:Aries-Project,项目名称:NGL,代码行数:33,代码来源:Image.cpp

示例7: load

/////////////////////////////////////////////////////////
// really open the file ! (OS dependent)
//
/////////////////////////////////////////////////////////
bool imageMAGICK :: load(std::string filename, imageStruct&result, gem::Properties&props)
{
  Magick::Image image;
  try {
    ::verbose(2, "reading '%s' with ImageMagick", filename.c_str());
    // Read a file into image object
    try {
      image.read( filename );
    } catch (Magick::Warning e) {
      verbose(1, "magick loading problem: %s", e.what());
    }

    result.xsize=static_cast<GLint>(image.columns());
    result.ysize=static_cast<GLint>(image.rows());
    result.setCsizeByFormat(GL_RGBA);
    result.reallocate();

    result.upsidedown=true;

    try {
      image.write(0,0,result.xsize,result.ysize,
                  "RGBA",
                  Magick::CharPixel,
                  reinterpret_cast<void*>(result.data));
    } catch (Magick::Warning e) {
      verbose(1, "magick decoding problem: %s", e.what());
    }
  }catch( Magick::Exception e )  {
    verbose(1, "magick loading image failed with: %s", e.what());
    return false;
  }
  return true;
}
开发者ID:Jackovic,项目名称:Gem,代码行数:37,代码来源:MagickPlusPlus.cpp

示例8: load

bool CubemapTexture::load() {
    Magick::Image *img;
    Magick::Blob blob;

    glGenTextures(1, &_tex);
    glBindTexture(GL_TEXTURE_CUBE_MAP, _tex);
    for (uint i=0; i < sizeof(types) / sizeof(types[0]); i++) {
        img = new Magick::Image(_fs[i]);
        try {
            img->write(&blob, "RGBA");
        } catch (Magick::Error &err) {
            std::cerr << "Could not load texture " << _fs[i] << ": " << err.what() << std::endl;
            delete (img);
            return false;
        }
        std::cout << "Cubemap texture loaded: " << _fs[i] << std::endl;
        glTexImage2D(types[i], 0, GL_RGB, img->columns(), img->rows(), 0, GL_RGBA, GL_UNSIGNED_BYTE, blob.data());
        glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
        glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
        glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
        delete img;
    }
    return true;
}
开发者ID:Nekony,项目名称:opengl-test,代码行数:26,代码来源:cubemap_texture.cpp

示例9: load_cube_map

void texture_t::load_cube_map( vector<string> const & files_names )
{
   Magick::Image img;

   for (int i = 0; i < files_names.size(); ++i)
   {
      img.read(files_names[i]);

      int res_x = img.rows()
         ,res_y = img.columns();

      scoped_array<unsigned char> data(new unsigned char[res_x * res_y * 3]);

      if (i == 2 || i == 3)
         img.flip();
      else
         img.flop();

      img.write(0, 0, res_x, res_y, "RGB", CharPixel, data.get());

      glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

      glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGB16, res_x, res_y, 0, GL_RGB
                   ,GL_UNSIGNED_BYTE, data.get());
   }

   glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
   glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
   glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
}
开发者ID:fedotovav,项目名称:test_engine,代码行数:30,代码来源:textures.cpp

示例10: Load

bool CubemapTexture::Load()
{
    glGenTextures(1, &m_textureObj);
    glBindTexture(GL_TEXTURE_CUBE_MAP, m_textureObj);

    Magick::Image* pImage = NULL;
    Magick::Blob blob;

    for (unsigned int i = 0 ; i < ARRAY_SIZE_IN_ELEMENTS(types) ; i++) {
        pImage = new Magick::Image(m_fileNames[i]);
        
        try {            
            pImage->write(&blob, "RGBA");
        }
        catch (Magick::Error& Error) {
            cout << "Error loading texture '" << m_fileNames[i] << "': " << Error.what() << endl;
            delete pImage;
            return false;
        }

        glTexImage2D(types[i], 0, GL_RGB, pImage->columns(), pImage->rows(), 0, GL_RGBA, GL_UNSIGNED_BYTE, blob.data());
        
        delete pImage;
    }    
    
    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);           
    
    return true;
}
开发者ID:Eizen,项目名称:ogldev,代码行数:33,代码来源:cubemap_texture.cpp

示例11: onInput

  void PipelineStabDetect::onInput(InputImageInfo info, Magick::Image image) {
    try {
      if (!initialized) {
        init(image);
      }
      if (image.rows() != height || image.columns() != width) {
        throw runtime_error(QString("Not uniform image size! %").arg(info.file.fileName()).toStdString());
      }


      Magick::Blob blob;
      // set raw RGBS output format & convert it into a Blob  
      if (image.depth() > 8)
        *err << "Warning: we lost some information by converting to 8bit depth (now " << image.depth() << ")" << endl;
      image.depth(8);
      image.magick("RGB");
      image.write(&blob);

      LocalMotions localmotions;
      VSFrame frame;
      size_t dataLen = blob.length();

      Q_ASSERT(fi.planes == 1);
      Q_ASSERT(dataLen == image.baseColumns() * image.baseRows() * 3);

      if (stabConf->mdConf.show > 0) { // create copy of blob
        frame.data[0] = new uint8_t[dataLen];
        memcpy(frame.data[0], blob.data(), dataLen);
      } else {
        frame.data[0] = (uint8_t*) blob.data();
      }
      frame.linesize[0] = image.baseColumns() * 3;

      if (vsMotionDetection(&md, &localmotions, &frame) != VS_OK) {
        throw runtime_error("motion detection failed");
      } else {
        if (vsWriteToFile(&md, f, &localmotions) != VS_OK) {
          throw runtime_error("cannot write to transform file");
        }
        vs_vector_del(&localmotions);
      }

      if (stabConf->mdConf.show > 0) {
        // if we want to store transformations, we have to create new image...
        Magick::Geometry g(width, height);
        Magick::Blob oblob(frame.data[0], dataLen);

        Magick::Image oimage;
        oimage.read(oblob, g, 8, "RGB");
        delete[] frame.data[0];
        emit input(info, oimage);
      } else {
        emit input(info, image);
      }

    } catch (exception &e) {
      emit error(e.what());
    }
  }
开发者ID:Karry,项目名称:TimeLapse,代码行数:59,代码来源:pipeline_stab.cpp

示例12: Geometry

  //! Returns remaining image size after removing black edges
  Magick::Geometry
  bbox (const Magick::Image& image) const
  {
    const Magick::Color black ("black");

#define is_black(x,y) (black == image.pixelColor (x, y))

    const unsigned int
      cols = image.columns (),
      rows = image.rows ();

    unsigned int x_min, x_max, y_min, y_max;

    bool found;
    unsigned int x, y;

    found = false;
    y = 0;
    do {
      x = 0;
      do {
        found = !is_black (x, y);
      } while (!found && cols != ++x);
    } while (!found && rows != ++y);
    y_min = y;

    found = false;
    y = rows;
    do {
      x = 0;
      do {
        found = !is_black (x, y-1);
      } while (!found && cols != ++x);
    } while (!found && 0 != --y);
    y_max = y;

    found = false;
    x = 0;
    do {
      y = 0;
      do {
        found = !is_black (x, y);
      } while (!found && rows != ++y);
    } while (!found && cols != ++x);
    x_min = x;

    found = false;
    x = cols;
    do {
      y = 0;
      do {
        found = !is_black (x-1, y);
      } while (!found && rows != ++y);
    } while (!found && 0 != --x);
    x_max = x;

    return Magick::Geometry (x_max - x_min, y_max - y_min, x_min, y_min);
  }
开发者ID:utsushi,项目名称:utsushi,代码行数:59,代码来源:doc-locate.cpp

示例13: NessieException

Preprocessor::Preprocessor (const Magick::Image& page, const unsigned int& x, const unsigned int& y, const unsigned int& height, const unsigned int& width)
:	clip_(0),
	clipHeight_(height),
	clipWidth_(width),
	statistics_(),
	regions_(0),
	delimiters_(0),
	inlineRegions_(),
	patterns_(0),
	averageCharacterHeight_(0.0),
	averageCharacterWidth_(0.0),
	averageSpaceBetweenCharacters_(0.0)
{
	if ( (height == 0) && (width == 0) )
		throw NessieException ("Preprocessor::Preprocessor() : Constructor has 0 size.");

	if ( width > page.columns() )
		throw NessieException ("Preprocessor::Preprocessor() : The press clip's width cannot be wider than the underlying page's.");

	if ( height > page.rows() )
		throw NessieException ("Preprocessor::Preprocessor() : The press clip's height cannot be higher than the underlying page's.");

	if ( x >= page.rows() || y >= page.columns() )
		throw NessieException ("Preprocessor::Preprocessor() : The press clip's top leftmost pixel falls outside the page.");

	if( (x + height) > page.rows() || (y + width) > page.columns() )
		throw NessieException ("Preprocessor::Preprocessor() : The clip does not fall completely within the underlying page.");

	// Create a view over the input image
	Magick::Pixels imageView(const_cast<Magick::Image&>(page));
	Magick::PixelPacket *pixels = imageView.get(x, y, clipWidth_, clipHeight_);

	// Traverse the view to get the pixel values
	Magick::ColorGray grayLevel;
	for ( unsigned int i = 0; i < clipHeight_; ++i )
	{
		for ( unsigned int j = 0; j < clipWidth_; ++j )
		{
			grayLevel = *pixels++;
			clip_.push_back( static_cast<unsigned char>(round(grayLevel.shade() * 255.0)) );
		}
	}

	statistics_.clipSize(clip_.size());
}
开发者ID:elitalon,项目名称:nessie-ocr,代码行数:45,代码来源:Preprocessor.cpp

示例14: DoYourJob

int AlgorithmShiftNoise::DoYourJob(Magick::Image& image)
{
    srand(time(NULL));

    image.modifyImage();
    Magick::Pixels pixelCache(image);

    Magick::PixelPacket* pixels=pixelCache.get(0,0,image.columns(), image.rows());

    for (int fromX=0; fromX<image.columns(); fromX++)
        for(int fromY=0; fromY<image.rows(); fromY++)
        {
            int luck=rand()%100;
            if (luck>Percent)
                continue;

            int toX=rand()%image.columns();
            int toY=rand()%image.rows();

            Magick::PixelPacket tmp=pixels[fromX+fromY*image.columns()];
            pixels[fromX+fromY*image.columns()]=pixels[toX+toY*image.columns()];
            pixels[toX+toY*image.columns()]=tmp;
        }

    pixelCache.sync();

    return 0;
}
开发者ID:ydxt25,项目名称:IM-2,代码行数:28,代码来源:algorithms.cpp

示例15: MagickToBitmap

wxBitmap MagickToBitmap(Magick::Image image, int width, int height)
{
    Magick::Geometry geom(width, height);
    geom.aspect(true);
    image.resize(geom);
    unsigned char* rgb = static_cast<unsigned char*>(malloc(sizeof(char) * 3 * width * height));
    image.write(0, 0, image.columns(), image.rows(), "RGB", Magick::CharPixel, rgb);
    return wxBitmap(wxImage(width, height, rgb));
}
开发者ID:llau6,项目名称:World-s-Hardest-Game-Fire-Emblem-Edition,代码行数:9,代码来源:imageutil.cpp


注:本文中的magick::Image::columns方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。