How to overlay two images in c#?
Thanks

this exactly does that :

protected void Page_Load(object sender, EventArgs e)
{

string s = Server.MapPath("original.jpg");
string s2 = Server.MapPath("ikon.gif");

System.Drawing.Image original= Bitmap.FromFile(s);
Graphics gra = Graphics.FromImage(original);
Bitmap logo = new Bitmap(s2);
gra.DrawImage(logo, new Point(70, 70));

Response.ContentType = "image/JPEG";
big.Save(Response.OutputStream, ImageFormat.Jpeg);

}

can u show me how the code in vb.net too please

there are tools available to convert C# to VB and visa versa, search google with C# to VB converter.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) 
    
    Dim s As String = Server.MapPath("original.jpg") 
    Dim s2 As String = Server.MapPath("ikon.gif") 
    
    Dim original As System.Drawing.Image = Bitmap.FromFile(s) 
    Dim gra As Graphics = Graphics.FromImage(original) 
    Dim logo As New Bitmap(s2) 
    gra.DrawImage(logo, New Point(70, 70)) 
    
    Response.ContentType = "image/JPEG" 
    big.Save(Response.OutputStream, ImageFormat.Jpeg) 
    
End Sub

How to overlay two images in c#?
Thanks

some text is undefined should i have to imports something???

Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) 
    
    Dim s As String = Server.MapPath("original.jpg") 
    Dim s2 As String = Server.MapPath("ikon.gif") 
    
    Dim original As System.Drawing.Image = Bitmap.FromFile(s) 
    Dim gra As Graphics = Graphics.FromImage(original) 
    Dim logo As New Bitmap(s2) 
    gra.DrawImage(logo, New Point(70, 70)) 
    
    Response.ContentType = "image/JPEG" 
    big.Save(Response.OutputStream, ImageFormat.Jpeg) 

    
End Sub

- big.Save(Response.OutputStream, ImageFormat.Jpeg) >> this code is undeclared variable although i've try to put some imports like :
imports system
imports system.drawing
what supposed to do to make this code is work

- big.Save(Response.OutputStream, ImageFormat.Jpeg) >>can u
give me some explanation about this code,if i use the PNG should
i have to change this part of code??

i think there will be no "big" there, replace it with the "original".

original.Save(Response.OutputStream, ImageFormat.Jpeg)>>in this part still not declared..what is the main function of ImageFormat.Jpeg??

ok for such cases you can right click in visual studio code page and select resolve from the menu. it will add the namespace for you.
it will be an import statement added to the top of your code page.
import System.Imaging.Image or something like this i dont remember, just resolve it.

How to overlay or put a fire in your hand using C# language?thank you for the reply.

Hi,

Its a nice topic and dreamztechUSA LLC want to join in it.
You can try it.

To open an image

AtalaImage botImage = new AtalaImage("bottomImage.png");
AtalaImage topImage = new AtalaImage("topImage.png");

To overlay one on top of another

Point pos = new Point(0,0); // or whatever you need
OverlayCommand cmd = new OverlayCommand(topImage, pos);
ImageResults res = cmd.Apply(botImage);
If you need the resulting image to be a different size, look at the CanvasCommand. You could also create an AtalaImage of the size you need, then overlay each image onto it.

To save

botImage.Save("newImage.png", new PngEncoder(), null);

Thanks & regards,

Greg Christofolo

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.