Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Creating Image on basis of space used

Creating Image on basis of space used

Scheduled Pinned Locked Moved ASP.NET
csharphelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Bajrang Singh
    wrote on last edited by
    #1

    Hi All, I want to create an Image to show the used space of each user. I explain it in details. Each user can login and can upload its document on the web. I want to calculate that space and want to show the space used from of Image like attached. I have calculated the space for logged in user but unable to create Image on basis of this calculated space. Any help is appreciated. Thanks

    Bajrang Singh Using .net 2.0 (VS2005)

    C 1 Reply Last reply
    0
    • B Bajrang Singh

      Hi All, I want to create an Image to show the used space of each user. I explain it in details. Each user can login and can upload its document on the web. I want to calculate that space and want to show the space used from of Image like attached. I have calculated the space for logged in user but unable to create Image on basis of this calculated space. Any help is appreciated. Thanks

      Bajrang Singh Using .net 2.0 (VS2005)

      C Offline
      C Offline
      Covean
      wrote on last edited by
      #2

      I would add a new webpage. In this webpage you have to query how many space is left or used by this user. Now you should create a new Bitmap, make the drawings on it and then write the new bitmap to the response stream (you also have to adjust the ContentType of the response). Here is some sample code (not tested!) that should create an 100x40 (24bit color depth) bitmap. The red part is the used and the green part is the free space. ShowImage.aspx.cs

      public partial class ShowImage : System.Web.UI.Page
      {
          protected void Page\_Load(object sender, EventArgs e)
          {
              try
              {
                  Response.Clear();
      
                  int nUsedSpaceInPercent = 70; // % <- here you should determine how many space is used
      
                  Bitmap bmp = new Bitmap(100, 40, PixelFormat.Format24bppRgb);
                  Graphics gfx = Graphics.FromImage(bmp);
                  gfx.FillRectangle(Brushes.Green, new Rectangle(0, 0, 100, 40));
                  gfx.FillRectangle(Brushes.Red, new Rectangle(0, 0, nUsedSpaceInPercent, 40));
                  gfx.DrawRectangle(Pens.Black, new Rectangle(0, 0, 100, 40));
                  Response.ContentType = "image/png";
                  Response.BufferOutput = true;
                  bmp.Save(Response.OutputStream, ImageFormat.Png);
              }
              catch (Exception ex)
              {
                  // do some exception handling
              }
          }
      }
      

      ShowImage.aspx (this is the full file!)

      <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ShowImage.aspx.cs" Inherits="SomeNamespace.Display.ShowImage" %>
      <%@ OutputCache Location="None" %>

      Hope that helps.

      Greetings Covean

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups