Click here to Skip to main content
16,019,109 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
hi all,
i have completed code to overlap images but what i want is with these overlapped image text in textbox should also overlap on image so below is my code where we have to implement it i cant understand so any body helpme or give my any examples

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Data;
using System.Data.SqlClient;



public partial class upload_site : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {

        string CS = "Data Source=HOME;Initial Catalog=Registration;Integrated Security=True";
        SqlConnection con = new SqlConnection(CS);

        SqlCommand cmd = new SqlCommand();
        string impath = TextBox2.Text+".png";
      // string ip = @"~\Upload\" + TextBox2.Text.Trim();
        string filename = FileUpload1.FileName;
        string pc = @"~\Upload\" + filename.Trim();
        FileUpload1.PostedFile.SaveAs(Server.MapPath(@"~\Upload\" + filename.Trim()));

        cmd = new SqlCommand("insert into imagepath(ID,ImageName,CurrentDate,OldImagePath,newimagepath)values('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "','" + pc + "','"+impath+"')", con);
        cmd.CommandType = CommandType.Text;
        con.Open();
        cmd.ExecuteNonQuery();
        con.Close();
        lblStatus.Text = " Uploaded Successfully ";
        ChangeBackground(filename, pc);





    }
    private void ChangeBackground(string filename, string pc)
    {
        //string CS = "Data Source=HOME;Initial Catalog=Registration;Integrated Security=True";
        System.Drawing.Image imageBackground = System.Drawing.Image.FromFile(@"C:\temp\images.jpg");
        System.Drawing.Image imageOverlay = System.Drawing.Image.FromFile(@"C:\Users\admin\Documents\Visual Studio 2012\WebSites\uploadsite\Upload\" + filename.Trim() + "");
      
       // System.Drawing.Image imageOverlay = System.Drawing.Image.FromFile(@"~\Upload\" + filename.Trim() + "");

        System.Drawing.Image img = new Bitmap(imageBackground.Width, imageBackground.Height);
        using (Graphics gr = Graphics.FromImage(img))
        {
            gr.DrawImage(imageBackground, new Point(0, 0));
            gr.DrawImage(imageOverlay, new Point(0, 0));
        }
        //    img.Save(@"~\Upload\output.png", ImageFormat.Png);
        img.Save(@"C:\Users\admin\Documents\Visual Studio 2012\WebSites\uploadsite\Upload\" + TextBox2.Text + ".png", ImageFormat.Png);
        //img.Save(Server.MapPath(@"~\Upload\"+ ImageFormat.Png));
        img.Save(@"C:\temp\" + TextBox2.Text + ".jpeg", ImageFormat.Jpeg);
        //string impath = @"C:\Users\admin\Documents\Visual Studio 2012\WebSites\uploadsite\Upload\" + TextBox2.Text + ".png";

       // string ip = @"~\Upload\" + TextBox2.Text.Trim();
       //using (SqlConnection con = new SqlConnection(CS))
       // {
       //    FileUpload1.PostedFile.SaveAs(Server.MapPath(@"~\Upload\" + TextBox2.Text.Trim()));
       //     SqlCommand cmd = new SqlCommand("update imagepath set newimagepath= '"+TextBox2.Text+"'.png", con);

       //     cmd.CommandType = CommandType.Text;
       //     con.Open();
       //     cmd.ExecuteNonQuery();
       //     con.Close();
            Label6.Text = "scucess";
        //}
    }

    protected void Button2_Click(object sender, EventArgs e)
    {
        Response.Redirect("separate.aspx");
    }
}
Posted
Updated 23-Jul-15 19:13pm
v2
Comments
What is the issue exactly?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900