473,395 Members | 1,987 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Obtaining Graphics Object

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!!

Jul 18 '06 #1
2 1533
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" <wa*****@gmail.comwrote in message
news:11*********************@s13g2000cwa.googlegro 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!!

Jul 18 '06 #2
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" <wa*****@gmail.comwrote in message
news:11*********************@s13g2000cwa.googlegro 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!!

Jul 19 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Charlie | last post by:
Hi, I'm looking for a way to obtain the width of a string, either in actual inches/centimeters, or pixels will also work. Unfortunately this seems difficult as I'd like to keep things as close to...
2
by: JBiagio | last post by:
Hello All, I am attempting to learn a bit about the GDI+ transforms and charting data and I feel like I'm getting a handle on how the transforms work. My chart object has a large "canvas" bitmap...
12
by: Sanjay | last post by:
hi, We are currently porting our project from VB6 to VB .NET. Earlier we used to make scale transformations on objects like pictureBox , forms etc.Now Such transformations are made on the...
6
by: Chris Dunaway | last post by:
The method for printing documents in .Net can be confusing, especially for newer users. I would like to create a way to simplify this process. My idea would be implemented using a PrintDocument...
6
by: active | last post by:
I have an image and a graphics object created (FromImage) from that image. I need to create a new image and create a new graphics object from the new image. I want the new graphics object have...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.