add texts and images on an image - ASP.NET

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • papillonhn
    New Member
    • Dec 2007
    • 11

    add texts and images on an image - ASP.NET

    Please, help me.

    I'm using asp.net 2.0.

    I have a problem that: I have an weather background image. I need to add texts (like temperature) and 'icon images' (like rainy, sunny ..) on background image. I don't want to use Graphics object to draw text on background.

    It looks like this page: http://www.metservice.co.nz/default/...php?alias=home

    I'm thinking about using divs on div.
    If is there anyway to do it, or a custom control, please show me.

    Thanks in advances.
    Last edited by jhardman; Feb 19 '08, 07:02 PM. Reason: moved to .Net forum. ASP forum is for "classic" ASP
  • DrBunchman
    Recognized Expert Contributor
    • Jan 2008
    • 979

    #2
    Hi papillonhn,

    This is an ASP forum for classic ASP questions so you should re-post your question in the .NET forum - you'll recieve better technical help over there.

    A simple solution would be to use css positioning to acheive this effect. Use an image tag for each position on the map you wish to display a weather symbol and define it's position over the top of the background image using css. You can then change the ImageURL property of each image depending on your weather data. In this example I've defined each image by the nearest town e.g.

    [HTML]
    <asp:Image ID="imgBG" ImageUrl="MapBa ckground.gif" runat="server" />
    <asp:Image ID="imgQueensto wn" CssClass="imgQu eenstown" runat="server" />

    <asp:Image ID="imgChristch urch" CssClass="imgCh ristchurch" runat="server" />

    <asp:Image ID="imgWellingt on" CssClass="imgWe llington" runat="server" />
    [/HTML]

    Your css file would hold the position of each image:

    [HTML] .imgQueenstown, .imgChristchurc h, .imgWellington
    {
    position:absolu te;
    }
    .imgQueenstown
    {
    top:100px;
    left:20px;
    }
    .imgChristchurc h
    {
    top:90px;
    left:40px;
    }
    .imgWellington
    {
    top:80px;
    left:50px;
    }
    [/HTML]

    And finally, once you had your weather data you would set the url of each image:

    Code:
     Sub DrawWeatherMap() 
     
    'Load your weather data here in whatever format you like (db, xml etc) then set the images e.g
     
    imgQueenstown.ImageURL = "Sun.gif"
    imgChristchurch.ImageURL = "Cloud.gif"
    imgWellington.ImageURL = "Rain.gif"
     
    End Sub
    This is only an example solution and there is probably a more efficient or more powerful way to achieve what you want.

    If you have any further questions on this then please re-post this thread on the .NET forum.

    Hope this helps,

    Dr B

    Comment

    • smoothing
      New Member
      • May 2013
      • 1

      #3
      You want to add text/logo image into images, how about adding watermark to images in .NET,I found that by Google ,and I've tried its trial condition, work well for me.

      Code:
      using System.IO;
      using System.Drawing.Printing;
      using RasterEdge.Imaging;
      using RasterEdge.Imaging.Processing;
      
      RasterEdgeImaging Image = new RasterEdgeImaging();
      
      //Create an instance of Image and load an existing image
      using (Image image= Image.LoadImageFromFile(@"C:\1.bmp"));
                  {
                      Graphics graphics=new Graphics(image);
                      RasterEdgeImaging.Font font = new RasterEdgeImaging.Font("Times New Roman", 16, FontStyle.Bold);
                      RasterEdgeImaging.Brushes.SolidBrush brush=new RasterEdgeImaging.Brushes.SolidBrush();
                      brush.Color=Color.Black;
                      brush.Opacity=100;
                      image.CreateWatermark("watermark", font, brush, new PointF(image.Width/2, image.Height/2));
                      image.Save(@"C:\1-watermark.bmp");
                  }

      Comment

      Working...