Creating Image on basis of space used
-
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)
-
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)
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