Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Obtaining Graphics Object

Reply
Thread Tools

Obtaining Graphics Object

 
 
jediknight
Guest
Posts: n/a
 
      07-18-2006
Hi,

I am designing a web form which as an imagemap. I need to obtain a
graphics object so I can draw on this imagemap.

Can anyone tell me how to do this?

I have tried creating a bitmap object and doing Graphics.FromImage call
but the image on the imagemap disappears leaving a black background.


Many thanks in advance!!

 
Reply With Quote
 
 
 
 
Marina Levit [MVP]
Guest
Posts: n/a
 
      07-18-2006
I'm not sure how you intend to draw on a web page? You are talking about
the server generating a bunch of HTML to send to the client. The server
cannot draw something in the client browser drawing surface.

Perhaps I am misunderstanding what you are trying to do.

"jediknight" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> Hi,
>
> I am designing a web form which as an imagemap. I need to obtain a
> graphics object so I can draw on this imagemap.
>
> Can anyone tell me how to do this?
>
> I have tried creating a bitmap object and doing Graphics.FromImage call
> but the image on the imagemap disappears leaving a black background.
>
>
> Many thanks in advance!!
>



 
Reply With Quote
 
 
 
 
Kelly Herald
Guest
Posts: n/a
 
      07-19-2006
Do the following:

System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(50, 100,
System.Drawing.Imaging.PixelFormat.Format24bppRgb) ;
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bmp);


What you will most likely want to do is create a Generic Handler (*.ashx) to
do the drawing. If you use the ASHX approach then when you are done drawing
then just output the bitmap to the OutputStream.

bmp.Save(context.Response.OutputStream,
System.Drawing.Imaging.ImageFormat.Jpeg);

On your ASPX page the source URL for the image will be the path to the ASHX
file.

Sample code:

Image.ashx
using System;
using System.Web;


public class Image : IHttpHandler
{

public void ProcessRequest (HttpContext context)
{
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(50, 100,
System.Drawing.Imaging.PixelFormat.Format24bppRgb) ;
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bmp);

g.Clear(System.Drawing.Color.Blue);

bmp.Save(context.Response.OutputStream,
System.Drawing.Imaging.ImageFormat.Jpeg);
}

public bool IsReusable
{
get
{
return false;
}
}

}

Default.aspx
<img src="Image.ashx" />


"jediknight" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> Hi,
>
> I am designing a web form which as an imagemap. I need to obtain a
> graphics object so I can draw on this imagemap.
>
> Can anyone tell me how to do this?
>
> I have tried creating a bitmap object and doing Graphics.FromImage call
> but the image on the imagemap disappears leaving a black background.
>
>
> Many thanks in advance!!
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
help - obtaining the type of the object usingtp_name Mrinalini Kulkarni Python 0 12-25-2011 11:28 AM
Problem obtaining an object reference... SamG Python 1 08-07-2008 07:36 PM
Obtaining a callable class method object from a specific class Nathan Duran Python 1 04-10-2008 08:08 PM
Obtaining member function/function object's operator() signature psujkov@gmail.com C++ 1 02-14-2007 12:59 PM
Obtaining SSL certificate info from SSL object - BUG? John Nagle Python 11 12-14-2006 11:31 PM



Advertisments