本文整理汇总了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));
}
}
示例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;
}
示例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);
}
示例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");
}
}
示例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;
}
示例6:
void Magick::densityImage::operator()( Magick::Image &image_ ) const
{
image_.density( _geomery );
}
示例7:
void Magick::densityImage::operator()( Magick::Image &image_ ) const
{
image_.density( _point );
}