如何将图像放在图像上

问题描述:

我正在开发一个网站。并且想要将图像放在图像上。

任何人都可以知道怎么做...

i我正在使用visual studio 2010.

i am developing a website. and wants to place image over an image.
can anybody have any idea how to do it...
i am using visual studio 2010.

在服务器端,您可以使用 System.Drawing.Bitmap 动态准备合成图像。创建适当大小的新位图。然后你需要获得一个 System.Drawing.Graphics 的实例,你可以使用它来绘制位图。方法如下:

http:// msdn。 microsoft.com/en-us/library/system.drawing.graphics.fromimage.aspx [ ^ ]。



参见:

http://msdn.microsoft.com/en-us/library/system.drawing .bitmap.aspx [ ^ ],

http:// msdn .microsoft.com / zh-cn / library / system.drawing.graphics.aspx [ ^ ]。



使用此实例,绘制一个位图和另一位在所需位置上方的地图。您可以从可以存储在服务器端的文件中读取这两个位图。这两个位图将在结果位图上绘制。然后,您可以将结果位图保存在文件中并通过其URI显示,或者使用类 System.Web.HttpResponse

http://msdn.microsoft.com/en-us/library /system.web.httpresponse.aspx [ ^ ]。



您将在上面引用的MSDN页面上找到基本代码示例。



-SA
On server side, you can prepare a composite image on the fly using System.Drawing.Bitmap. Create a new bitmap of appropriate size. Then you need to obtain an instance of System.Drawing.Graphics which you can use to draw on a bitmap. Here is how:
http://msdn.microsoft.com/en-us/library/system.drawing.graphics.fromimage.aspx[^].

See also:
http://msdn.microsoft.com/en-us/library/system.drawing.bitmap.aspx[^],
http://msdn.microsoft.com/en-us/library/system.drawing.graphics.aspx[^].

Using this instance, draw one bitmap and another bitmap on top of it, in required position. You can read those two bitmaps from files you can store on the server side. Those two bitmaps will be drawn on a resulting bitmap. Then you can either save resulting bitmap in a file and show it by its URI, or draw the bitmap on the fly, using the class System.Web.HttpResponse:
http://msdn.microsoft.com/en-us/library/system.web.httpresponse.aspx[^].

You will find rudimentary code sample on the MSDN page referenced above.

—SA


您可以使用html< div>标签和CSS风格。



Image1.jpg =背景图片

Image2.jpg =放在Image1上



You can use html <div> tag and css style for this.

Image1.jpg = background image
Image2.jpg = to be placed on Image1

<div style="width: 400px; height: 80px; background-image: removed(Images/LMTG-LOGO.gif); background-repeat: no-repeat; background-removed: center; text-align: center;">
        <img src="Images/ltmhilogo.bmp" alt="Image1" />
    </div>





您可以通过应用样式属性和边距属性来调整Image2的位置。调整< div>的高度和宽度根据你的形象大小标记。





希望这对你有帮助。



You can adjust location of your Image2 by applying "style" property and "margin" attribute. Adjust height and width of the <div> tag based on the size of your image.


Hope this will help you.