Image Magick++ equivalent to convert -fill
Image Magick++ equivalent to convert -fill
我有一个convert命令,需要将其转换为Image Magick函数调用。
convert.exe bar.jpg-fuzz 40%-fill"rgb(5344563520930583)"-opaque"rgb"(65535,65535,65535)"foo2.jpg
我想知道是否有人能给我一个例子,说明我需要应用哪些方法才能获得同样的效果?
谢谢你的帮助!
Magick++的文档非常清晰,但有更多使用c&魔杖。在大多数情况下,-fill只是设置一个可以应用于各种操作的颜色属性。在Magick++中,您可以使用Image.fillColor;但是,Image.opaque方法会将一种颜色交换为另一种颜色。除了不透明方法外,还可以通过使用Image.colorFuzz.设置-fuzz选项来调整颜色阈值
C++&Magick++示例
#include <Magick++.h>
#include <iostream>
using namespace std;
using namespace Magick;
int main(int argc, char **argv)
{
InitializeMagick(*argv);
// Setup items
Image image;
/*
Remember to read & understand Magick++/Color.h to
ensure you are initializing the correct color constructor.
*/
Color target = Color("rgb(65535, 65535, 65535)");
Color fill = Color("rgb(53456, 35209, 30583)");
// Convert 40% to double
const double fuzz = 40*QuantumRange/100;
// Read image object
image.read("bar.jpg");
// Set fuzz threshold
image.colorFuzz(fuzz);
// Apply opaque paint
image.opaque(target,fill);
// Save image
image.write("foo2.jpg");
return 0;
}
C&MagickWand示例
#include <stdio.h>
#include <wand/MagickWand.h>
int main(int argc, char **argv) {
// MagickWand items
MagickWand *image = NULL;
PixelWand *target = NULL;
PixelWand *fill = NULL;
// Convert 40% to double
const double fuzz = 40*QuantumRange/100;
MagickWandGenesis();
// Setup Wand
target = NewPixelWand();
fill = NewPixelWand();
image = NewMagickWand();
// Load image
MagickReadImage(image,"bar.jpg");
// Set Colors
PixelSetColor(target,"rgb(65535, 65535, 65535)");
PixelSetColor(fill,"rgb(53456, 35209, 30583)");
// Apply effect(wand,0.40);
MagickOpaquePaintImage(image,target,fill,fuzz,MagickFalse);
// Save image
MagickWriteImages(image,"foo2.jpg",MagickTrue);
// Clean up
image=DestroyMagickWand(image);
MagickWandTerminus();
return 0;
}
相关文章:
- C++:如何将 unix 时间的字符串转换为 *tm?(使用时间错误:"cannot convert 'String' to 'tm*' ")
- 您可以使用 setfill() 来设置 fill 2 位数字吗?
- 如何在 C++ 中将双精度数组中的值"force convert"到字符串输出中?
- "Cannot convert Python object argument to type '<typename>'" - 使用 Cython 包装 C++ 类时出错
- 如何在使用 make_unique<T[]>() 制作的模板类型数组上使用 std::fill?
- 为什么C++ "fill"可以初始化可变大小的数组?
- 我不能将 'fill' std::vector 构造函数与 unique_ptrs 一起使用
- 我一直收到错误"cannot convert 'float*' to 'float' in return"
- 在 2D 整数矢量上使用 std::fill
- 地图'Cannot convert from _Ty2 to T*'错误
- cout.width和cout.fill返回不同的输出
- 将 2D 数组插入 std::vector 时"cannot convert from 'const GLfloat [12]' to '_Objty'"错误消息
- 如何修复C++中的'cannot convert char to char*'错误?
- 返回"Cannot convert from 'std::ofstream {aka std::basic_ofstream<char>}' to bool"错误
- 列表插入"Cannot convert argument from Class<T>* to Class<T> &&"
- 使用 'std::generate' 或 'std::fill' 来填充 'arma::mat'
- "Cannot convert parameter 1 from double to float"虽然没有更改参数
- 为什么 std::fill 使用 ForwardIterator,而不是 OutputIterator?
- 将静态参数克隆到 std::fill 导致链接器失败
- Image Magick++ equivalent to convert -fill