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


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

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


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

示例1: 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

示例2: AddImage

bool ResourceManager::AddImage(const boost::filesystem::path& path,
							   const std::string& imgname,
							   const float width,
							   const float height,
							   const std::string& key) {
	if(!boost::filesystem::is_regular_file(path/imgname)) {
		Logger::Critical(LogOrigin::RESOURCEMANAGER, "Tried loading image path'"+(path/imgname).string()+"' but this image path doesn't exist!");
		exit(1);
	}

    // create Original file path
    std::string originalFile = (path / imgname).string();


    // if the optional param key is not given, use the basename as key
    std::string image_key = "";
    if(key == "") {
        image_key = boost::filesystem::basename(originalFile);
    } else {
        image_key = key;
    }

    // Create Cache Paths
	boost::filesystem::path cacheDir = (path / "cached").string();
    std::string cacheFile = (cacheDir / image_key ).string()+".png";

    // if an image with that key already exists in the dictionary, return
    if(mImages.count(image_key) != 0) {
        return true;
    }

	// Log output
	Logger::Debug(LogOrigin::RESOURCEMANAGER, "Caching image " + originalFile);

	// Create cache directory
	boost::filesystem::create_directory(cacheDir.string());

	// Load, convert and save image (originalFile > cacheFile)
	Magick::Image mimage;
	mimage.backgroundColor(Magick::Color(0, 0, 0, 65535));
	mimage.density(Magick::Geometry(144, 144));
	mimage.read(originalFile);
	// Conver floats to view pixels so that images will always be at the same scale
	const Vector2D vec(Coordinates::WorldFloatToWorldPixel(Vector2D(width, height)));
	mimage.zoom(Magick::Geometry(vec.x, vec.y));
	mimage.depth(8);
	mimage.write(cacheFile);

	// Load cached file
	sf::Image sfimage;
	sfimage.LoadFromFile(cacheFile);
	sfimage.SetSmooth(true);

	// Save loaded Image in Dictionary
	// mImages.insert(new std::pair<std::string, sf::Image>(image_key, sfimage));
	mImages[image_key] = sfimage;

    return true;
}
开发者ID:svenstaro,项目名称:NoisyHunter,代码行数:59,代码来源:ResourceManager.cpp

示例3: copyImage

void copyImage(yarp::sig::ImageOf<yarp::sig::PixelRgb>& src,
               Magick::Image& dest) {
    int h = src.height();
    int w = src.width();
    dest.size(Magick::Geometry(w,h));
    dest.depth(8);
    for (int i=0; i<h; i++) {
        // must transfer row by row, since YARP may use padding in representation
        Magick::PixelPacket *packet = dest.setPixels(0,i,w,1);
        dest.readPixels(Magick::RGBQuantum,(unsigned char *)(&src.pixel(0,i)));
    }
    dest.syncPixels();
}
开发者ID:robotology,项目名称:yarp,代码行数:13,代码来源:main.cpp

示例4: WriteGif

void DrvSDL::WriteGif() {
    std::list<Magick::Image> gif;

    int num = 0;
    for(std::list<Magick::Blob>::iterator it = image_.begin(); it != image_.end(); it++) {
        Magick::Image image;
        image.magick("RGB");
        image.depth(32);
        image.size(Magick::Geometry(cols_ * pixels.x, rows_ * pixels.y));
        Magick::PixelPacket *pixel_cache = image.getPixels(0, 0, cols_ * pixels.x, rows_ * pixels.y);
        for(int n = 0; n < rows_ * pixels.y * cols_ * pixels.x; n++) {
            int col = ((int *)(*it).data())[n];
            uint8_t *rgb = (uint8_t *) &col;
            Magick::PixelPacket *gif_pixel = pixel_cache + n;
            *gif_pixel = Magick::ColorRGB(rgb[0] / 256.0, rgb[1] / 256.0, rgb[2] / 256.0);
        }
        image.syncPixels();
        gif.push_back(image);
        LCDInfo("Image %d", num++);
    }
    LCDInfo("Writing GIF image...");
    for_each(gif.begin(), gif.end(), Magick::animationDelayImage(ani_speed_ / 10));
    Magick::writeImages(gif.begin(), gif.end(), gif_file_);
}
开发者ID:Chelovecheggg,项目名称:libvisual,代码行数:24,代码来源:DrvSDL.cpp

示例5: AddTexture

bool ResourceManager::AddTexture(const boost::filesystem::path& path,
							   const std::string& imgname,
							   const float width,
							   const float height) {

	if(!boost::filesystem::is_regular_file(path/imgname)) {
		std::cerr << "Tried loading image path '" << (path/imgname).string() << "' but this image path doesn't exist!" << std::endl;
		exit(1);
	}

	// convert coords
	const Vector2D size(Coordinates::WorldFloatToWorldPixel(Vector2D(width, height)));

    // create Original file path
    std::string originalFile = (path / imgname).string();

    // if the optional param key is not given, use the basename as key
	std::string image_key = boost::filesystem::basename(originalFile);

    // Create Cache Paths
	boost::filesystem::path cacheDir = (path / "cached").string();
    std::string cacheFile = (cacheDir / image_key ).string()+".png";

    // if an image with that key already exists in the dictionary, return
    if(mTextures.count(image_key) != 0) {
        return true;
    }

	sf::Texture sftexture;
	bool cache = true;

	if(boost::filesystem::is_regular_file(cacheFile)) {
		// Load cached file
		bool success = sftexture.LoadFromFile(cacheFile);
		if (success && (int)sftexture.GetHeight() == (int)size.x && (int)sftexture.GetWidth() == (int)size.y) {
			cache = false;
			std::cout << "Texture " << originalFile << " already exists. Not caching. "<< std::endl;
		} else if (success) {
			std::cout << "Texture " << originalFile << " does not exist in the resolution "
					<< size.x << "x" << size.y << " but in " << sftexture.GetHeight() << "x" << sftexture.GetWidth() << "." << std::endl;
		}
	}

	if(cache){
		std::cout << ":: Caching image " << originalFile << std::endl;

		// Create cache directory
		boost::filesystem::create_directory(cacheDir.string());

		// Load, convert and save image (originalFile > cacheFile)
		Magick::Image mimage;
		mimage.backgroundColor(Magick::Color(0, 0, 0, 65535));
		mimage.density(Magick::Geometry(144, 144));
		mimage.read(originalFile);


		mimage.zoom(Magick::Geometry(std::max(size.x,size.y), std::max(size.x,size.y)));
		mimage.depth(8);
		mimage.write(cacheFile);

		// Load cached file
		sftexture.LoadFromFile(cacheFile);
	}


	sftexture.SetSmooth(true);


	//std::cout << "  Added image: "<<image_key << std::endl;
	// Save loaded Texture in Dictionary
	mTextures[image_key] = sftexture;

    return true;
}
开发者ID:Blarget2,项目名称:gamejam,代码行数:74,代码来源:ResourceManager.cpp

示例6:

void Magick::depthImage::operator()( Magick::Image &image_ ) const
{
  image_.depth( _depth );
}
开发者ID:0xPr0xy,项目名称:ImageMagick,代码行数:4,代码来源:STL.cpp

示例7: scan_image

void scan_image (const char *filename)
{
    scanner.reset();
    // normally scanner would reset associated decoder,
    // but this debug program connects them manually
    // (to make intermediate state more readily available)
    // so decoder must also be reset manually
    decoder.reset();

    Magick::Image image;
    image.read(filename);
    string file = image.baseFilename();
    size_t baseidx = file.rfind('/');
    if(baseidx != string::npos)
        file = file.substr(baseidx + 1, file.length() - baseidx - 1);
    ofstream svg((file + ".svg").c_str());

    unsigned inwidth = image.columns();
    unsigned flush1 = inwidth / 32;
    unsigned flush0 = 2;
    unsigned width = inwidth + flush1 + flush0;
    unsigned height = image.rows();
    unsigned midy = (height + 1) / 2 + 2;
    image.crop(Magick::Geometry(inwidth, 1, 0, midy));
    image.size(Magick::Geometry(width, 1, 0, 0));

    svg << "<?xml version='1.0'?>" << endl
        << "<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN'"
        << " 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'>" << endl
        << "<svg version='1.1' id='top'"
        << " width='10in' height='6in' preserveAspectRatio='xMinYMid slice'"
        << " overflow='visible' viewBox='0,0 " << width * 2 << ",384'"
        << " xmlns:xlink='http://www.w3.org/1999/xlink'"
        << " xmlns='http://www.w3.org/2000/svg'>" << endl
        << "<defs><style type='text/css'><![CDATA[" << endl
        << "  * { stroke-linejoin: round; stroke-linecap: round;"
        <<      " stroke-width: .1; text-anchor: middle;"
        <<      " image-rendering: optimizeSpeed;"
        <<      " font-size: 6; font-weight: bold }" << endl
        << "  path { fill: none }" << endl
        << "  #zero { stroke: #00f }" << endl
        << "  #edges { stroke: #f00 }" << endl
        << "  #cur-edge { stroke: #f44 }" << endl
        << "  #raw { stroke: orange }" << endl
        << "  #y0 { stroke: yellow }" << endl
        << "  #y1 { stroke: #0c0 }" << endl
        << "  #y2 { stroke: #0aa }" << endl
        << "  .y1thr { stroke: #f0f }" << endl
        << "  rect.bar { fill: black }" << endl
        << "  text.bar { fill: white }" << endl
        << "  rect.space { fill: white }" << endl
        << "  text.space { fill: black }" << endl
        << "  text.data { fill: #44f; font-size: 16 }" << endl
        << "]]></style></defs>" << endl
        << "<image width='" << width * 2 << "' height='384'"
        << " preserveAspectRatio='none'"
        << " xlink:href='" << file << ".png'/>" << endl
        << "<g transform='translate(1,384) scale(2,-.5)'>" << endl;

    // brute force
    unsigned raw[width];
    {
        // extract scan from image pixels
        image.modifyImage();
        Magick::Pixels view(image);
        Magick::PixelPacket *pxp = view.get(0, 0, width, 1);
        Magick::ColorYUV y;
        double max = 0;
        svg << "<path id='raw' d='M";
        unsigned i;
        for(i = 0; i < inwidth; i++, pxp++) {
            y = *pxp;
            if(max < y.y())
                max = y.y();
            raw[i] = (unsigned)(y.y() * 0x100);
            svg << ((i != 1) ? " " : " L ") << i << "," << raw[i];
            y.u(0);
            y.v(0);
            *pxp = y;
        }
        y.y(max); /* flush scan FIXME? */
        for(; i < inwidth + flush1; i++) {
            raw[i] = (unsigned)(y.y() * 0x100);
            svg << " " << i << "," << raw[i];
            *pxp++ = y;
        }
        y.y(0);
        for(; i < width; i++) {
            raw[i] = (unsigned)(y.y() * 0x100);
            svg << " " << i << "," << raw[i];
            *pxp++ = y;
        }
        view.sync();
        svg << "'/>" << endl
            << "</g>" << endl;
    }
    image.depth(8);
    image.write(file + ".png");

    // process scan and capture calculated values
//.........这里部分代码省略.........
开发者ID:krunalsoni01,项目名称:yocto-zbar,代码行数:101,代码来源:dbg_scan.cpp


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