C# 如何重叠图像?
可能的重复:
如何将两个图像合并为单个 Jpeg < /p>
我有 2 个图像,
Image.FromFile("images/1.png");
Image.FromFile("images/2.png");
我想重叠这些图像并构建一个新图像,我该怎么做?
谢谢
Possible Duplicate:
How to merge two images into a single Jpeg
I have 2 images,
Image.FromFile("images/1.png");
Image.FromFile("images/2.png");
i want to overlap these images and construct a new image how do i do it?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您不想缩放或平移任何图像,这是最简单的方法。结果将存储在 image1 中。您还可以创建一个新图像来执行此操作、偏移图像、缩放图像、更改透明度等。
Is the simplest way, if you don't want to scale or translate either image. The result will be stored in image1. You can also create a new image to do this, offset the images, scale them, change transparency, etc..
好吧,这取决于您正在寻找什么类型的效果,但您没有给我们太多信息,因此您可以从简单的附加例程开始。循环遍历两个图像的共享区域中的每个像素,并将像素分量值加在一起,限制在最大值以避免溢出(假设每个分量只有一个字节,则可能为 255)。
您可以使用 GDI+ 位图方法
GetPixel
和SetPixel
来执行此操作,或者如果事实证明这太慢,您可以调用LockBits
并直接获取内存中的图像数据。Well, it depends on what type of effect you are looking for, but you haven't given us much info, so you could start with a simple additive routine. Loop through each pixel in the shared area of the two images and add the pixel component values together, clamping at the maximum to avoid overflow (probably 255 assuming a single byte per component).
You can use the GDI+ bitmap methods
GetPixel
andSetPixel
to do this, or if that proves too slow you can callLockBits
and get directly at the image data in memory.