Click here to Skip to main content
15,914,406 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi ,


I have a well designed image which is named as MainImage. Now when I upload a new image using fileupload control(image will be passport photo size copy type) ,here on button click I want to make new image(uploaded image) slightly transparent on the top of MainImage (here MainImage acts as background for the uploaded image) and should be stored in db.



My form looks as below

Name : TextBox

Date : TextBox

Upload Image : fileuploadcontrol browse

Button


Please let me know how do I do it in c#. Thank you!
Posted
Updated 16-Jul-15 2:07am
v2
Comments
Andy Lanng 15-Jul-15 6:34am    
Please explain what you mean by "merged with MainImage". Do you want to actually merge the images or just have one image slightly transparent on top of the other image?
raviram123 15-Jul-15 12:33pm    
sir when i click on file upload ctrl ie browse some images in folder wil appear and when i selected it i want to edit the image like crop,inserting another image in it, i want to write text any where
raviram123 16-Jul-15 8:06am    
I want to make new image(uploaded image) slightly transparent on the top of MainImage and save in db
SohaibX 15-Jul-15 11:24am    
It'll be a lot more easier if you just post the relevant code of yours.
raviram123 15-Jul-15 12:27pm    
sir this the code below
.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="upload site.aspx.cs" Inherits="upload_site" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<%-- <style type="text/css">
.auto-style1 {
width: 647px;
background-color: #00FF00;
}
.auto-style2 {
height: 323px;
width: 406px;
color: #FF0066;
background-color: #0066FF;
}
/*.auto-style3 {
color: #000000;
background-color: #FFFF99;*/
}
.auto-style4 {
width: 407px;
color: #00FF00;
height: 320px;
}
</style>--%>
<style type="text/css">
#Form1 {
width: 743px;
background-color: #33CCFF;
height: 388px;
}
.auto-style2 {
color: #FF33CC;
height: 387px;
width: 749px;
}
.auto-style3 {
color: #0000FF;
}
.auto-style4 {
background-color: #0000FF;
}
.auto-style5 {
background-color: #0000FF;
color: #FFFFFF;
}
.auto-style6 {
color: #CC3300;
}
.auto-style7 {
color: #FFFFFF;
background-color: #0000FF;
}
.auto-style8 {
color: #FFFFFF;
background-color: #0000FF;
}
.auto-style9 {
color: #FFFFFF;
}
</style>
</head>
<body>
<form id="Form1" runat="server" class="auto-style4">
<table border="0" color:"blue" cellspacing="5" cellpadding="5" class="auto-style2">
<tbody><tr>
<td class="auto-style1">
<span class="auto-style9">ID</span><span class="auto-style3">        </span>
<asp:TextBox ID="TextBox1" runat="server" CssClass="auto-style3">
<span class="auto-style3">                   
<asp:Label ID="Label1" runat="server" CssClass="auto-style4" ForeColor="#FFFFCC" Text="ADD/DEL">
 
<asp:CheckBox ID="Add" runat="server" Text="ADD" CssClass="auto-style7" />
    
<asp:CheckBox ID="Delete" runat="server" Text="DEL" CssClass="auto-style8" />
          </span>
<asp:Button ID="Button2" runat="server" CssClass="auto-style5" Height="23px" OnClick="Button2_Click" Text="GO" Width="58px" />
</td>
</tr>
<tr>
<td class="auto-style1">
<span class="auto-style9">name</span><span class="auto-style3">    </span> <asp:TextBox ID="TextBox2" runat="server" CssClass="auto-style3">
<span class="auto-style3">
<br />
<br />
</span>
<span class="auto-style9">
date</span><span class="auto-style3">      </span>
<asp:TextBox ID="TextBox3" runat="server" CssClass="auto-style3">
</td>
</tr>
<tr>
<td class="auto-style1">
<span class="auto-style9">image</span><span class="auto-style6">  </span>
<asp:FileUpload ID="FileUpload1" runat="server" CssClass="auto-style3" />
<asp:Label ID="lblStatus" runat="server" CssClass="auto-style3">

1 solution

First you need to place an Image element (tag) in your aspx page.
<asp:image id="Image1" runat="server" xmlns:asp="#unknown" />

after you uploaded your image file successfully. You need to assign this image URL to that image element.
(imageElementID).ImageURL="../Upload/"+pc.Trim();


And also, you need to check the directory whether its exists or not before save file into it. so it'll be something like.

if(!Directory.Exists(Server.MapPath(@"~/Upload")))
        Directory.CreateDirectory(Server.MapPath(@"~/Upload"));
    FileUpload1.PostedFile.SaveAs(Server.MapPath(@"~/Upload/" + pc.Trim()));


does that solve your problem?
 
Share this answer
 

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