Well, actually yes... the image of the user fades as the time passes by...the
user image is an image recieved from the web and the background is a simple
filled rectangle...I want to make the user image go fade/transparent with
time...and as this happens....the background will be more and more visible.
This is all done via ASP.NET dynamically.... no HTML of CSS is involved...Here
is the code i wrote:
CODE:
====
<%@ Page language="c#" Debug="true" %>
<%@ Import Namespace="Syst em.Drawing" %>
<%@ Import Namespace="Syst em.Drawing.Draw ing2D" %>
<%@ Import Namespace="Syst em.Drawing.Imag ing" %>
<%@ Import Namespace="Syst em.Net" %>
<%@ Import Namespace="Syst em.IO" %>
<script language="C#" runat="server">
Bitmap bkGroundImg = null;
Bitmap userImg = null;
Graphics bkImgGraphics = null;
Graphics userImgGraphics = null;
void Page_Load(objec t sender, EventArgs e)
{
Response.Conten tType = "image/jpeg";
string url = Request.QuerySt ring["url"];
string trans = Request.QuerySt ring["trans"];
// Response.Write( "url: "+url);
// Response.Write( "<userImgr>tran s: "+(float)Douuse rImgle.Parse(tr ans));
WebClient client = new WebClient();
Stream stream =
client.OpenRead (url);//"http://www.n-tv.de/images/200410/5438283_angelin a-jolie8.jpg");
userImg = new Bitmap(stream);
userImg = new Bitmap(userImg, 100, 100);
stream.Close();
bkGroundImg = new Bitmap(100+10, 100+10);
bkImgGraphics = Graphics.FromIm age(bkGroundImg );
userImgGraphics = Graphics.FromIm age(userImg);
// SolidBrush brush = new SolidBrush(Colo r.DarkGoldenrod );
// bkImgGraphics.D rawString("Ange lina Jolie", new Font("Arial
userImglack", 15), userImgrush,3, 3);
Rectangle rect = new Rectangle(0, 0,
(int)bkGroundIm g.PhysicalDimen sion.Width,
(int)bkGroundIm g.PhysicalDimen sion.Height+1);
Brush brush = new LinearGradientB rush(rect, Color.DarkGolde nrod,
Color.Yellow, 90);
// Pen p = new Pen(Color.Red, 10);
// bkImgGraphics.D rawRectangle(p, rect);
bkImgGraphics.F illRectangle(br ush, rect);
// p = new Pen(Color.Green , 10);
// bkImgGraphics.D rawLine(p, 0, 35, (int)userImg.Ph ysicalDimension .Width,
35);
makeTransparent ((float)Double. Parse(trans));
bkImgGraphics.D rawImage(userIm g, 5, 5);
bkGroundImg.Sav e(Response.Outp utStream, ImageFormat.Jpe g);
}
void makeTransparent (float transparencyLev el)
{
ColorMatrix clrMatrix = new ColorMatrix();
clrMatrix.Matri x33 = transparencyLev el;
ImageAttributes imgAtt = new ImageAttributes ();
imgAtt.SetColor Matrix(clrMatri x);
// Response.Write( "<userImgr>clrM atrix.Matrix33: "+clrMatrix.Mat rix33);
// userImgGraphics = Graphics.FromIm age(userImg);
userImgGraphics .DrawImage(user Img, new Rectangle(15, 15, userImg.Width,
userImg.Height) , 0, 0, userImg.Physica lDimension.Widt h,
userImg.Physica lDimension.Heig ht, GraphicsUnit.Pi xel, imgAtt);
// userImgGraphics .Dispose();
// Response.Write( "<userImgr>user Img: "+userImg);
}
</script>
"Kevin Spencer" schrieb:
Okay, the first thing we need to do is narrow down our field. What you
really want to know is how to create overlapping images with HTML, since
HTML is what ASP.Net produces. This can be done using CSS and absolute
positioning. However, when you say "If the upper image gets transparent, the
background image should be visible," how do you expect "the upper image" to
"get transparent?" Do you figure it will fade with age?
--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.
"Fahad Aijaz" <Fa********@dis cussions.micros oft.com> wrote in message
news:08******** *************** ***********@mic rosoft.com... Can any one tell me how can I create overlapping images using ASP.NET.
That is, One rectangle drawn as a background image and then another image is
placed over it. If the upper image gets transparent, the background image
should be visible. Can any one help me in this?