473,657 Members | 2,475 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Overlapping Images in ASP.NET

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?
Nov 19 '05 #1
3 4537
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?

Nov 19 '05 #2
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?


Nov 19 '05 #3
Hi Fahad,
This is all done via ASP.NET dynamically.... no HTML of CSS is involved...Here

?! That's just plain naive. I don't know how you expect to write an ASP.Net
application at all if you think there's no HTML or CSS involved. You can't
display an image (or anything else) in a page without HTML! HTML is the
bread an butter of the client-side aspect of ASP. If you don't understand
that, you're wasting your time.

And from the looks of it, I would have to say that you are indeed wasting
your time. If you want to position an image over another image in a web
page, and have the top image fade, you're going to need some help on the
client side. You could do this with an animated GIF file, SWF, or a Java
applet or ActiveX Control on the client.

--
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:CE******** *************** ***********@mic rosoft.com... 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-jo
lie8.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?


Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
4670
by: Max M | last post by:
I am writing a "find-free-time" function for a calendar. There are a lot of time spans with start end times, some overlapping, some not. To find the free time spans, I first need to convert the events into a list of non overlapping time spans "meta-spans". This nice ascii graph should show what I mean. 1) --- 2) ---
3
12807
by: Phil Sandler | last post by:
All, I have a table with start and end dates/times in it, and would like to be able to calculate the number of hours represented, accounting for overlapping records. Note that I am looking for an answer on HOW to do this--I don't necessarily need it to be written for me (although it would not go unappreciated!).
2
12021
by: Catherine Lynn Wood | last post by:
I need to know how to overlap DIV content within 'relative' associated rendering. I am building div layers in the middle of a page and when I set positioning to absolute in the CSS, it references back to 0,0 on the entire page. If I set it to relative, the div layers will not overlap as needed. I prefer to avoid javascripting an 'innerHTML' re-write of a single div and would instead like to build two layers that can reside at the same...
1
12892
by: Mitch | last post by:
I have 2 rectangle images. 1 with a box in the upper left corner and the other with a box in the lower right hand corner. Both images are the same size. I would like to display these 2 images so that it looks like 1 image by overlapping them using css. I have tried creating a seperate div for each image and setting the top/left the same on both and changing the layer on each. This only made the 2nd one display directly below the first...
4
3233
by: Charlie Brown | last post by:
I have a form with 2 custom controls that can be dragged around by a user. How can I check if they overlap each other without performing some kind of Collision detection on them? Is there anything in GDI to check for overlapping controls?
4
4863
by: =?ISO-8859-15?Q?Jean=2DFran=E7ois?= Lemaire | last post by:
Hello all, I'm learning C and I still am struggling to understand some basic concepts. For example, I read in the standard that with functions such as strcpy, 'If copying takes place between objects that overlap, the behavior is undefined.' But how can I be sure that they don't overlap? For example, if I write this: char string1 = "overlap";
1
2575
by: Daimz | last post by:
I am making a blog and as part of my template I am wanting to have my header and then another image on the side of that using the z-index: 2; to make it that layer about. so here is the css. .splash { z-index: 2; width: 135px; height: 386px; margin: 0 auto; position: relative; left: 450px;
2
14067
by: thephatp | last post by:
I'm having a problem with IE rendering correctly. I'm experimenting with using all div's in my pages now, and I'm not very familiar with the quirks of IE. I have created a sample page, and I'm really confused as to what is going on in IE. FF renders the page exactly as I expect. IE renders the page with everything in the correct location, but it seems to double the background image for a sub-div section that is moved up using a negative...
0
2840
by: richard12345 | last post by:
Hi Guys I have problem with site I am building. The sidebar with menu and other thinks is overlapping footer. The footer move with the content and but it dos it dos not move with the sidebar. Here is the website: holtz-realty And also the html file and css file. Anny help will by mostly appreciated. I did try everything I can think of. HTML:
0
8323
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8838
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8739
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8613
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2740
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1969
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1732
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.