不存在从"Magick::Color"到"MagickCore::Quantum"的合适转换功能
no suitable conversion function from "Magick::Color" to "MagickCore::Quantum" exists
我已经知道为什么它会给出错误代码。问题是,我今天开始使用库本身,并遵循我发现的教程。
我安装了该库的"ImageMagick-7.09-1-Q16-x64-dll"版本,并试图找到出现该错误的最短代码,即:
#include <Magick++.h>
int main(){
Magick::Quantum result = Magick::Color("black");
}
给定教程(以下教程(,一个从Magick::Color转换为Magic::Quantum的方法应该存在
// Example of using an image pixel cache
Image my_image("640x480", "white"); // we'll use the 'my_image' object in this example
my_image.modifyImage(); // Ensure that there is only one reference to
// underlying image; if this is not done, then the
// image pixels *may* remain unmodified. [???]
Pixels my_pixel_cache(my_image); // allocate an image pixel cache associated with my_image
Quantum* pixels; // 'pixels' is a pointer to a Quantum array
// define the view area that will be accessed via the image pixel cache
int start_x = 10, start_y = 20, size_x = 200, size_y = 100;
// return a pointer to the pixels of the defined pixel cache
pixels = my_pixel_cache.get(start_x, start_y, size_x, size_y);
// set the color of the first pixel from the pixel cache to black (x=10, y=20 on my_image)
*pixels = Color("black");
// set to green the pixel 200 from the pixel cache:
// this pixel is located at x=0, y=1 in the pixel cache (x=10, y=21 on my_image)
*(pixels+200) = Color("green");
// now that the operations on my_pixel_cache have been finalized
// ensure that the pixel cache is transferred back to my_image
my_pixel_cache.sync();
这在的以下行给出了错误(不存在从"Magick::Color"到"MagickCore::Quantum"的合适转换函数(
*pixels = Color("black");
*(pixels+200) = Color("green");
我认为您混淆了数据类型和结构。pixels
表示Quantum
部件的连续列表。
假设我们使用的是RGB颜色空间。您需要设置每个颜色部分。
Color black("black");
*(pixels + 0) = black.quantumRed();
*(pixels + 1) = black.quantumGreen();
*(pixels + 2) = black.quantumBlue();
要设置第200个像素,需要将偏移量乘以每个像素的部分数。
Color green("green");
int offset = 199 * 3; // First pixel starts at 0, and 3 parts (Red, Green, Blue)
*(pixels + offset + 0) = green.quantumRed();
*(pixels + offset + 1) = green.quantumGreen();
*(pixels + offset + 2) = green.quantumBlue();
相关文章:
- 功能样式转换从 'int' 到 'ItemType' 的匹配转换
- 字符转换功能 std::isupper() & std::islower() C++17
- 错误:在尝试检测 std::cout 是否<< t 时,功能强制转换为数组类型;有效
- 为什么从基转换为派生提供此功能?
- 借助功能将 2D 转换为 1D 数组
- 不存在从"Magick::Color"到"MagickCore::Quantum"的合适转换功能
- 模板功能:根据类型名称进行转换
- 组件X86转换为ARM功能呼叫,其中有不同数量的参数为ARM
- 将variadic模板功能转换为许多具体功能
- 不存在从"const std::string"到"time_t"的合适转换功能
- 功能指针参数参数转换为const
- 最佳可行的转换功能
- 为什么在相同大小的功能参数中隐式转换不会发出警告
- 功能采用variadic模板包将std :: strings转换为const char *
- 为什么转换涉及两个用户定义的转换功能/构造函数
- 如何将功能机体转换为lambda
- 如何使转换功能工作?
- 为什么 openCV 的转换功能不起作用?
- 更好的转换功能
- 智能感知:不存在从"std::string"到"char"的合适转换功能,那么我该怎么做?