Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
镜像模式后如何在qt中合并两个图像?_Qt_Qpainter_Qimage - Fatal编程技术网

镜像模式后如何在qt中合并两个图像?

镜像模式后如何在qt中合并两个图像?,qt,qpainter,qimage,Qt,Qpainter,Qimage,我需要镜像一个图像。我已经完成了这一部分,但是调用此函数时,原始图像会消失在图像区域中。我保存了原始图像,并使用QPaint绘制了原始图像,然后镜像,我认为这两个图像将被合成。我仍然只得到镜像图像。我希望镜像图像和原始图像都位于同一图像区域。这是我到目前为止所拥有的 QImage* Original= mImage; //original image QImage reflection = mImage->mirrored(true,false);//mirror the original

我需要镜像一个图像。我已经完成了这一部分,但是调用此函数时,原始图像会消失在图像区域中。我保存了原始图像,并使用QPaint绘制了原始图像,然后镜像,我认为这两个图像将被合成。我仍然只得到镜像图像。我希望镜像图像和原始图像都位于同一图像区域。这是我到目前为止所拥有的

QImage* Original= mImage; //original image
QImage reflection = mImage->mirrored(true,false);//mirror the original image

QPainter painter(mImage);

painter.CompositionMode_DestinationOver;
painter.drawImage(0, 0, *mImage);
painter.drawImage(0, 0, reflection);
painter.end();
QPainter::合成模式\目标版本

目标的alpha用于将其混合到源的顶部 像素

如果您的图像没有alpha通道,您将看不到任何差异

此外,代码中还有其他问题

不需要在图像本身上绘制图像 结束,;没有必要 使用painter.setCompositionMode设置合成模式; 在图形之间设置合成模式
谢谢,我创建了一个alpha通道,但现在镜像不起作用了:QImage mask=mImage->createAlphaMask;QPainter painter&mask;您还需要具有明显透明度的像素。
QPainter painter(mImage);
painter.setCompositionMode(QPainter::CompositionMode_DestinationOver);
painter.drawImage(0, 0, reflection);