locked
Want to draw a custome image-might be challenging. . . RRS feed

  • Question

  • User-653688788 posted

    Hi;

    I want to draw an image as follows at runtime. Values will be taken as integer. And then a grid will be drawn as given below (i.e. print A-B-C-...... horizentally, and print 1-2-3-.... vertically).

    _____________________________________________________________________________________________________________________________________________________________ 

    No. Boxes in Horizental <input type="text" value="15" />
    No. Boxes in Vertical <input type="text" value="20" />

    <input type="button" value="Draw" />

    Grid

    Tuesday, October 17, 2006 3:26 AM

All replies

  • User2128074059 posted
    You can use the DrawLine method in Graphics class to draw the above table, then write some characters on it with DrawString method.
    Tuesday, October 17, 2006 10:03 PM
  • User-653688788 posted
    Can I use photosprite for this purpose and will it be feasible?
    Wednesday, October 18, 2006 6:14 AM
  • User2128074059 posted

    Maybe no, I think. PhotoSprite only process some effects online, and it's very perfect as far as I know. I don't use it to draw diagram(or table).

    You can drawing the table by yourself simply with .NET freamwork.

    Wednesday, October 18, 2006 9:43 PM
  • User-1372641848 posted

    with little bit of twicking following code might do trick.

    Check this url for working sample 

     

    ----- Copy following code to table.ashx file and run.

    <!--WebHandler Language="C#" Class="table"-->

    <%@ WebHandler Language="C#" Class="table" %> using System; using System.Web; using System.Drawing; public class table : IHttpHandler { public void ProcessRequest (HttpContext context) { int spacing = 30; int margin = 20; string[] alphabets = new string[] { "A", "B", "C", "D", "E", "F", "G", "H" }; Bitmap bmp = new Bitmap(alphabets.Length * spacing + margin * 2, alphabets.Length * spacing + margin * 2); Graphics g = Graphics.FromImage(bmp); g.Clear(Color.White); for (int i = 1; i <= alphabets.Length; i++) { int y1 = margin; int y2 = margin + alphabets.Length * spacing; int x1 = margin + i * spacing; int x2 = x1; g.DrawLine(Pens.Black, x1, y1, x2, y2); g.DrawString(alphabets[i - 1], new Font(FontFamily.GenericMonospace, 10), Brushes.Black, x1, y1); int yh1 = margin + i * spacing; int yh2 = yh1; int xh1 = margin; int xh2 = margin + alphabets.Length * spacing; g.DrawLine(Pens.Black, xh1, yh1, xh2, yh2); g.DrawString(i.ToString(), new Font(FontFamily.GenericMonospace, 10), Brushes.Black, xh1, yh1); } context.Response.ContentType = "image/jpeg"; bmp.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg); } public bool IsReusable { get { return false; } } }

      

     

    Monday, October 23, 2006 7:41 PM