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


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

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


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

示例1: convertImageDpi

void MagickImageLoader::convertImageDpi(Magick::Image& image) {
    if (image.magick() == "PDF" | image.magick() == "SVG" || image.magick() == "DJVU") {
        //change from default 72 dpi
        image.resolutionUnits(Magick::PixelsPerInchResolution);
        image.density(Magick::Geometry(MIN_DPI_FOR_VECTOR_FORMAT, MIN_DPI_FOR_VECTOR_FORMAT));
    }
}
开发者ID:nctan,项目名称:quneiform,代码行数:7,代码来源:magickimageloader.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: convertImageToDib

void MagickImageLoader::convertImageToDib(Magick::Image& image, Magick::Blob& blob) {
    image.magick("DIB");

    if(image.xResolution() == 0 || image.yResolution() == 0) {
        image.resolutionUnits(Magick::PixelsPerInchResolution);
        image.density(Magick::Geometry(75, 75));
    }

    image.write(&blob);
}
开发者ID:nctan,项目名称:quneiform,代码行数:10,代码来源:magickimageloader.cpp

示例4: load

ImagePtr MagickImageLoader::load(const ImageURL& url)
{
    try {
        Magick::Image image;
        image.density(Magick::Geometry(10, 10));
        image.ping(url.path());
        convertImageDpi(image);
        image.read(url.path());
        return load(image);
    } catch (Magick::Exception &e) {
        cfError() << e.what();
        throw Exception("[MagickImageLoader::load] failed");
    }
}
开发者ID:nctan,项目名称:quneiform,代码行数:14,代码来源:magickimageloader.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::densityImage::operator()( Magick::Image &image_ ) const
{
  image_.density( _geomery );
}
开发者ID:0xPr0xy,项目名称:ImageMagick,代码行数:4,代码来源:STL.cpp

示例7:

void Magick::densityImage::operator()( Magick::Image &image_ ) const
{
  image_.density( _point );
}
开发者ID:anorland,项目名称:ImageMagick,代码行数:4,代码来源:STL.cpp


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