473,498 Members | 1,737 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to get co-ordinates to write on image

I am writing Hello on the image i am able to write it sucessfully now I want
to

write it at bottom right corner

How can I calculate the co-ordinates(suppose my image is 600*450)

string str="Hello";

Bitmap tempImage=new
System.Drawing.Bitmap(Server.MapPath("/Photos/21/Normal/1.jpg"));

Graphics graphicImage=System.Drawing.Graphics.FromImage(tem pImage);

graphicImage.DrawString(str,new Font("Arial", 10,FontStyle.Regular),new
SolidBrush(Color.Black),new Point(0,0));

Response.ContentType="image/jpeg";

tempImage.Save("D:/test.jpg",ImageFormat.Jpeg);

graphicImage.Dispose();

tempImage.Dispose();
Jun 20 '06 #1
3 1569
Hi Vikas,

Thanks for your post!

The Point you passed to DrawString method specifies which point to draw the
string. To draw in the bottom right corner of the image, you may pass the
bottom right point coordinate as the point parameter, and then pass an
extra StringFormat parameter to DrawString method. You should set
StringFormat.Alignment and LineAlignment properties to StringAlignment.Far
so that the string drawing start with a different alignment. Sample code
snippet is listed below:

Bitmap tempImage=new
System.Drawing.Bitmap(600, 450);
Graphics graphicImage=System.Drawing.Graphics.FromImage(tem pImage);
string str="Hello";

StringFormat sf=new StringFormat();
sf.Alignment=StringAlignment.Far;
sf.LineAlignment=StringAlignment.Far;

graphicImage.DrawString(str,new Font("Arial", 10,FontStyle.Regular),new
SolidBrush(Color.Black),new Point(600,450), sf);

tempImage.Save(@"C:\test.jpg");
graphicImage.Dispose();
tempImage.Dispose();

Note:
1. in the code, I create an empty memory bitmap for drawing, and then save
it to disk. You can open this bitmap in disk to see the final effect.
2. the default StringFormat for DrawString method is StringAlignment.Near
which uses the (600, 450) point as the top-left drawing point, so draws the
string out of your image rectangle. By changing the alignment to
StringAlignment.Far, it will use (600, 450) point as the bottom-right
drawing point

You may modify the code snippet a little to use it in Asp.net HttpResponse
class.

Hope this helps!

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 20 '06 #2
thanks
""Jeffrey Tan[MSFT]"" <je***@online.microsoft.com> wrote in message
news:P5**************@TK2MSFTNGXA01.phx.gbl...
Hi Vikas,

Thanks for your post!

The Point you passed to DrawString method specifies which point to draw
the
string. To draw in the bottom right corner of the image, you may pass the
bottom right point coordinate as the point parameter, and then pass an
extra StringFormat parameter to DrawString method. You should set
StringFormat.Alignment and LineAlignment properties to StringAlignment.Far
so that the string drawing start with a different alignment. Sample code
snippet is listed below:

Bitmap tempImage=new
System.Drawing.Bitmap(600, 450);
Graphics graphicImage=System.Drawing.Graphics.FromImage(tem pImage);
string str="Hello";

StringFormat sf=new StringFormat();
sf.Alignment=StringAlignment.Far;
sf.LineAlignment=StringAlignment.Far;

graphicImage.DrawString(str,new Font("Arial", 10,FontStyle.Regular),new
SolidBrush(Color.Black),new Point(600,450), sf);

tempImage.Save(@"C:\test.jpg");
graphicImage.Dispose();
tempImage.Dispose();

Note:
1. in the code, I create an empty memory bitmap for drawing, and then save
it to disk. You can open this bitmap in disk to see the final effect.
2. the default StringFormat for DrawString method is StringAlignment.Near
which uses the (600, 450) point as the top-left drawing point, so draws
the
string out of your image rectangle. By changing the alignment to
StringAlignment.Far, it will use (600, 450) point as the bottom-right
drawing point

You may modify the code snippet a little to use it in Asp.net HttpResponse
class.

Hope this helps!

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.

Jun 20 '06 #3
You are welcome

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 21 '06 #4

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

Similar topics

0
1755
by: melledge | last post by:
Mozilla Foundation Co-Hosts Europe's Leading XML and Web Developer Conference XTech 2005 Conference to Bring Together XML and Web Technology Thought Leaders
3
1782
by: Steve Keanie | last post by:
We're running into a _big_ problem with the embedded co-processor for both COBOL and PL/I ... we can't get either compiler to recognize the VERSION option, which means that all DBRMs get created...
3
2010
by: Richard W Collens | last post by:
Hey folks! Before I spend any money on Access 2003, is it co-habitable with Office XP? Also, can I use the XP Developers Edition to package and deploy and Access 2003 project? Thanks in...
44
5751
by: Nicolas | last post by:
On most implementations of the standard C library, the functions that copy characters in a previously allocated buffer, like strcpy or strcat, are returning the pointer to that buffer. On my...
2
1428
by: Steve | last post by:
Error message: "Unable to start debugging on the web server. Unable to map the debug start page to a machine name." I can no longer run the debugger from my local PC for a project on our web...
0
1058
by: | last post by:
I could find no group as to how to find/start a programmers co-op within the uk, preferably the south west of the uk. Does anyone know where I may start to hunt out this sort of idea? I have...
1
2168
by: relisoft | last post by:
SEATTLE, Washington. - July 12, 2006: Reliable Software® announces the upcoming release of Code Co-op® version 5.0. Code Co-op is an affordable peer-to-peer version control system for distributed...
8
2173
by: john | last post by:
To test a new piece of software designed to help with (among other things) eCommerce WWW site development. The software is fairly easy to use but you must fit a profile. Retail price is 120 GBP and...
1
1462
by: kailashchandra | last post by:
Hello Everybody i am trying to get co-ordinate position of mouse using java script using the following code.it works fine on IE and other but it is not working on mozilla.i couldn't...
0
7205
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...
1
6887
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
7379
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
5462
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,...
0
4590
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3093
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1419
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
291
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.