我怎么能使用C#和asp.net定位多个透明的PNG到JPG? [英] How could I position multiple transparent PNGs onto a JPG using c# and asp.net?
问题描述
我想编写一个应用程序,将允许网络用户上传JPG和位置透明的PNG上上传的图像的顶部。层的数目,各层的定位,并且该实际的图像文件的信息将被收集并使用JavaScript和CSS操纵
I would like to write an application that would allow a web user to upload a jpg and position transparent pngs on top of that uploaded image. The number of layers, positioning of the layers, and that actual image file information will be collected and manipulated using javascript and CSS.
在我的图像文件和透明的PNG图像的X-Y-Z坐标,我怎么能创造这些映像的单个JPG?难道你们有一个很好的起点,我可以去研究?
After I have the image files and the x-y-z coordinates for the transparent pngs, how can I create a single jpg from these images? Do you guys have a good starting point that I can go to for research?
嘿,
前两个答案,我似乎都做的工作。什么是使用 System.Drawing.Graphics
,并使用为System.Drawing.Image
???之间的差异
Hey there,
The first two answers I got both seem to do the job. What are the differences between using System.Drawing.Graphics
and using System.Drawing.Image
???
推荐答案
下面是一些code我使用(修改,以显示原理):
Here's some code i use (modified to show the principle):
private void ProcessPhoto()
{
System.Drawing.Image imgThumb = System.Drawing.Image.FromFile("some.jpg");
// 43w, 35h = offset in frame
System.Drawing.Image imgFrame = System.Drawing.Image.FromFile("transparent_something.png");
Bitmap bmImage = new Bitmap(imgThumb);
bmImage.SetResolution(72, 72);
Graphics gFrame = Graphics.FromImage(imgFrame);
gFrame.DrawImage(bmImage, new Point(38, 44)); // offset point of where you want to draw
gFrame.Dispose();
SavePhoto(imgFrame, "dest.png");
imgFrame.Dispose();
imgThumb.Dispose();
}
private void SavePhoto(System.Drawing.Image img, string fileName)
{
string ext = Path.GetExtension(fileName);
fileName = fileName.Replace(ext, ".png");
img.Save(fileName, GetImageEncoder("PNG"), null);
}
编辑:
阅读所有关于 Graphics类这里
这篇关于我怎么能使用C#和asp.net定位多个透明的PNG到JPG?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!