问题标签 [magick++]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
178 浏览

imagemagick - 图像类无法读取目标文件

我正在尝试使用 Image.read 方法读取 TEMP 文件夹深处的图像以进行转换。

我见过这样的例子

我试过这个

和这个

,但我捕捉到下一个异常。what():app.exe:无法打开图像`↑Ё)':无效参数@error/blob.c/Op enBlob/2674

通过 ImageMagic 进行的转换工作正常,我可以做我想做的所有事情,但是 lib 集成不起作用。

我不明白我做错了什么

0 投票
1 回答
916 浏览

c++ - Examples of Magick++ api and ping (not networking ping)

I'm trying to use the Magick++ API (part of ImageMagick) for c++ and I've been looking around a while now and haven't seen that much documentation or examples on google. There's a lot of good documentation about it, but I can't find anything on how to use the ping() (not networking ping) function to return the size information of an image inside a c++ program. I've tried to make a blob object and use it like I've seen in the error.

I've seen a lot of the same general manual like:

http://web.mit.edu/graphics/share/ImageMagick/www/Magick++/Image.html#Image%20Attributes which is the same as http://www.imagemagick.org/Magick++/Image.html

I was looking at ping under "Image Manipulation Methods" and saw that it took a const Blob &blob_ as input. I tried doing the following, though I'm not really sure what I'm doing with ping(). I've got a lot of other stuff working, just can't figure this out.

I can't even find much in the way of examples for Magick++ stuff or ping.

So I guess ping returns void which it didn't say in the manual. I'm not even sure how I'd get values from it. Should I just take a look at the source code? Does anyone know where I could find more reading on this? Or is anyone familiar with Magick++. I'm sorry for being so clueless but google just isn't turning up much in the way of results for me about this.

Any help would be much appreciated!

0 投票
1 回答
1381 浏览

c++ - 将 BLOB 读入图像时出现 Magick++ 错误

我正在尝试使用 Magick++ 库将图像从原始像素数据导出到 RGBA PNG。

但是,当我尝试运行它时遇到一个奇怪的错误:

这是相关的代码部分(我省略了填充像素向量,但这并没有改变任何东西):

编译:

0 投票
1 回答
764 浏览

c++ - 在 Magick++ 中将 alpha 蒙版应用于图像

我有一个图像,它有两个帧的序列。第二帧应该是第一帧的 alpha 蒙版。

这是一个例子:

http://i.imgur.com/c2M10u7.png

我使用 Magick++ 编写了以下代码,将图像分成两半,并应用 alpha 蒙版:

但是,我无法弄清楚如何将它实际应用为 alpha 蒙版,而不仅仅是混合它。我也无法在任何地方找到解决方案,至少 C++ 没有。

任何帮助将不胜感激。

0 投票
1 回答
932 浏览

c++ - Magick++ C++ 输入 16 位灰度 PNG

我有一系列 PNG 文件,我知道它们是 16 位灰度格式。我用 Magick++ 加载它并访问 8 位格式的数据没有问题(这主要是因为所有代码都在那里,不需要更改)。

请注意,灰色在我们自己的图像容器中,但内存布局只是一块预先分配的内存。

我现在被告知我们需要访问完整的 16 位范围,但我不太确定如何做到这一点。我想我不会使用 Magick::CharPixel,但文档中描述的其他内容没有指定它们实际的位大小。


所以,我需要能够做以下事情:

  • 首先判断是否是16位图像
  • 将 Magick::Image 类读出到内存块中,该内存块将映射到 u_int16_t 的内存块中

有人能帮忙吗?

0 投票
1 回答
1142 浏览

c++ - 尝试使用magick ++在c ++中删除背景并使其透明

我有一个带有红色背景的图像“objects.png”,我正在尝试使背景透明。代码很简单,但不知何故我无法得到想要的结果。我对这个 ImageMagick 业务很陌生,这是我第一个使用 Magick++ 的程序。所以,如果你能详细解释一下,那就太好了。提前致谢。代码是这样的,

图像 objects.png 是 输入图像

我把它作为输出 在此处输入图像描述

0 投票
1 回答
2318 浏览

c++ - 如何使用Magick ++将不透明度设置为具有透明背景的png图像

我正在使用 ImageMagick 来渲染图像。我将png 文件打开为 Magick::Image 并将其绘制在另一个 Magick::Image 上并将不透明度设置为 png 图像。并将其保存为jpg 文件

在保存的文件中透明背景变为黑色。

示例代码:

是否可以将图像的透明度设置为 50% 并将背景设置为完全透明?

0 投票
1 回答
874 浏览

c++ - Magick++ to display an image with CGI

I recently began using Magick++ (C++ API for ImageMagick) with the goal of creating a website that could display randomly generated images. I am trying to write a CGI script which would create a JPEG Image, set the color of its pixels, and then return the image information as Content-type: image/jpg.

Reading through the documentation, I only find functions for writing image files to disk. I do not see one which would do what I am hoping to do, along the lines of std::cout << Image or std::cout << Blob

My goal is to be able to display the image generated by the script in a webpage, without needing to write the image to disk.

I know that PerlMagick has a display function which does what I am trying to do - I am wondering if I can do the same with Magick++.

0 投票
0 回答
127 浏览

c++ - libjpeg-turbo 可以设置像素的颜色吗?

我使用 Magick++ 编写了一个程序,它生成一个 JPEG 文件,其中每个像素设置为随机颜色。它运作良好,但对于我的目的来说有点慢。

我读过 libjpeg-turbo 更快 - 但是通过阅读它的文档,我只能找到从现有图像文件中读取并压缩的函数和示例。是否可以使用 libjpeg-turbo 以编程方式设置 jpeg 的像素值?

有没有其他方法可以尝试更快地创建图像?如果其中一种可以允许更快的算法,我愿意尝试不同的文件类型。我的最终目标是创建一个 CGI 程序,它将在网页上显示随机生成的图像。

这是我在 Magick++ 中使用的代码:

- - 更新 - - -

正如下面所指出的,Magick++ 不会导致该程序运行缓慢。我欢迎任何有关优化此 for 循环其他方面的建议。

0 投票
1 回答
805 浏览

c++ - 相当于 Magick++ 中的随机噪声

我在网上找到了很多关于使用 ImageMagick 的命令行函数来创建随机噪声图像的文档,但还没有弄清楚如何在 Magick++ 中重现它。

ImageMagick 有 +noise 方法 Random:

convert -size 100x100 xc: +noise Random random.png

我希望能够将像素设置为 Color("random"),例如:

sought.extent(Geometry(640,416), Color("random"), CenterGravity);

将较小的图像嵌入到随机噪声的画布中。当然,随机不是 Color 可接受的参数,但我想知道是否存在等价物?理想的情况是,如果还可以限制颜色范围 - 例如仅 12 位 (#000-#FFF)。