在 C# 中组合图像
我在 Photoshop 中有一张大图像,有很多层。我有位图格式的所有图层。对于可视化过程的每一步,我都会隐藏和显示一些图层,移动一些图层,旋转一些图层,并编辑一些文本。所有这些都基于我当前在 Excel 中拥有的数据(但它可能位于数据库或其他任何位置)。
我想要的是根据我可以编程的规则自动执行此操作。我的问题是:如何最好地根据位图资源绘制图像,然后从 C# 将其保存为 jpg?
我觉得 GDI+ 对此有点低级,但如果没有其他免费解决方案就其本身而言,我必须尝试一下......
I have a large image in photoshop, with many layers. I have all the layers in Bitmap format. For each step of a visualization process I hide and show some layers, I move some, I rotate some, and I edit some texts. All based on data I currently have in excel (but it could be in a database or whatever).
What I want, is to automate this based on rules I can program. My question is: how can I best draw an image based on bitmap resources then save it to a jpg from C#?
I feel GDI+ is a bit low-level for this, but if no other free solution presents itself, I'll have to try that...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,GDI和GDI+是两个截然不同的东西。您可能想使用 GDI+。我自己在 GDI+ 中制作了几个照片处理程序,因此您拥有所需的所有工具。
您要做的就是获取每个位图的 Graphics 对象。使用这个你可以使用对象的变换矩阵或旋转矩阵来达到你想要的效果。 DrawString 方法应该可以满足您的文本需求。
如果需要混合图像(使用混合模式),可以使用 Lockbits 方法并手动迭代像素。这非常简单。
这应该为您提供解决当前问题所需的所有指示。
First of all, GDI and GDI+ are two very different things. You probably want to work with GDI+. I have myself made several photo-manipulation programs in GDI+, so you have all the tools you need right there.
What you want to do is to get hold of the Graphics object of each bitmap. Using this you can use the object's transformation matrix or rotation matrix to achieve the effects you want. The DrawString method should accomplish your text needs.
If you need to blend images (using blending modes), you can use the Lockbits method and iterate over the the pixels manually. It's pretty straightforward.
This should give you all the pointers you need to solve the problem at hand.