I am using GDI+ to generate buttons in my application. Because I want the
left and right edges of the buttons to be a certain number of pixels from
the start and end of the text, I need to know (or be able to calculate) the
left and rightmost pixels of the text. However, this is a problem because
not all letters have their leftmost pixel at the same X position. For
example, when using the following font:
Dim buttonfont As New Font("Arial", 19, FontStyle.Bold, GraphicsUnit.Po int)
and using the following lines to draw text:
For i As Integer = 65 To 90
testgraphics.Dr awString(Chr(i) , buttonfont, Brushes.White, 0, 35 + (i - 64)
* 20)
Next
The characters 'A' and 'J' start 2 pixels farther to the left than most
other characters (there are also a couple other characters that are offset
by 1 or 2 pixels). Is there any easy way to determine what X position the
first and last pixel of a character is at? Because this depends on the font,
the only way to do it manually would be to test each pixel. Is there a
method that can be used to do this? Thanks.
--
Nathan Sokalski nj********@hotm ail.com http://www.nathansokalski.com/ 3 1013
If this is an offline process, testing each column of pixels should be
enough.
You could also try http://msdn.microsoft.com/library/de...ntext_52at.asp
and in particular the GLYPHMETRICS structure that should allow to get the
"box" in which the character is drawn...
Patrice
--
"Nathan Sokalski" <nj********@hot mail.com> a écrit dans le message de
news:OC******** ********@TK2MSF TNGP15.phx.gbl. .. I am using GDI+ to generate buttons in my application. Because I want the left and right edges of the buttons to be a certain number of pixels from the start and end of the text, I need to know (or be able to calculate)
the left and rightmost pixels of the text. However, this is a problem because not all letters have their leftmost pixel at the same X position. For example, when using the following font:
Dim buttonfont As New Font("Arial", 19, FontStyle.Bold,
GraphicsUnit.Po int)
and using the following lines to draw text:
For i As Integer = 65 To 90
testgraphics.Dr awString(Chr(i) , buttonfont, Brushes.White, 0, 35 + (i -
64) * 20)
Next
The characters 'A' and 'J' start 2 pixels farther to the left than most other characters (there are also a couple other characters that are offset by 1 or 2 pixels). Is there any easy way to determine what X position the first and last pixel of a character is at? Because this depends on the
font, the only way to do it manually would be to test each pixel. Is there a method that can be used to do this? Thanks. -- Nathan Sokalski nj********@hotm ail.com http://www.nathansokalski.com/
Do you know of anywhere where I can see an example? Thanks.
--
Nathan Sokalski nj********@hotm ail.com http://www.nathansokalski.com/
"Patrice" <no****@nowhere .com> wrote in message
news:Oc******** ******@TK2MSFTN GP09.phx.gbl... If this is an offline process, testing each column of pixels should be enough.
You could also try http://msdn.microsoft.com/library/de...ntext_52at.asp and in particular the GLYPHMETRICS structure that should allow to get the "box" in which the character is drawn...
Patrice --
"Nathan Sokalski" <nj********@hot mail.com> a écrit dans le message de news:OC******** ********@TK2MSF TNGP15.phx.gbl. .. I am using GDI+ to generate buttons in my application. Because I want the left and right edges of the buttons to be a certain number of pixels from the start and end of the text, I need to know (or be able to calculate) the left and rightmost pixels of the text. However, this is a problem because not all letters have their leftmost pixel at the same X position. For example, when using the following font:
Dim buttonfont As New Font("Arial", 19, FontStyle.Bold, GraphicsUnit.Po int)
and using the following lines to draw text:
For i As Integer = 65 To 90
testgraphics.Dr awString(Chr(i) , buttonfont, Brushes.White, 0, 35 + (i -
64) * 20)
Next
The characters 'A' and 'J' start 2 pixels farther to the left than most other characters (there are also a couple other characters that are offset by 1 or 2 pixels). Is there any easy way to determine what X position the first and last pixel of a character is at? Because this depends on the font, the only way to do it manually would be to test each pixel. Is there a method that can be used to do this? Thanks. -- Nathan Sokalski nj********@hotm ail.com http://www.nathansokalski.com/
Try around : http://cvs.sourceforge.net/viewcvs.p...rm1.cs?rev=1.2
I've done a search using gmBlackBoxX (you could use any other name that
belongs to this structure) on Google...
Good luck.
--
Patrice
"Nathan Sokalski" <nj********@hot mail.com> a écrit dans le message de
news:%2******** ********@TK2MSF TNGP10.phx.gbl. .. Do you know of anywhere where I can see an example? Thanks. -- Nathan Sokalski nj********@hotm ail.com http://www.nathansokalski.com/
"Patrice" <no****@nowhere .com> wrote in message news:Oc******** ******@TK2MSFTN GP09.phx.gbl... If this is an offline process, testing each column of pixels should be enough.
You could also try http://msdn.microsoft.com/library/de...ntext_52at.asp and in particular the GLYPHMETRICS structure that should allow to get
the "box" in which the character is drawn...
Patrice --
"Nathan Sokalski" <nj********@hot mail.com> a écrit dans le message de news:OC******** ********@TK2MSF TNGP15.phx.gbl. .. I am using GDI+ to generate buttons in my application. Because I want
the left and right edges of the buttons to be a certain number of pixels
from the start and end of the text, I need to know (or be able to calculate) the left and rightmost pixels of the text. However, this is a problem
because not all letters have their leftmost pixel at the same X position. For example, when using the following font:
Dim buttonfont As New Font("Arial", 19, FontStyle.Bold, GraphicsUnit.Po int)
and using the following lines to draw text:
For i As Integer = 65 To 90
testgraphics.Dr awString(Chr(i) , buttonfont, Brushes.White, 0, 35 + (i -
64) * 20)
Next
The characters 'A' and 'J' start 2 pixels farther to the left than most other characters (there are also a couple other characters that are offset by 1 or 2 pixels). Is there any easy way to determine what X position
the first and last pixel of a character is at? Because this depends on the font, the only way to do it manually would be to test each pixel. Is there a method that can be used to do this? Thanks. -- Nathan Sokalski nj********@hotm ail.com http://www.nathansokalski.com/
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Pallavi |
last post by:
Hello,
Suppose I want to highlight a piece of text. I get the x & y
co-ordinates on the screen. And using dhtml I am able to highlight the
text. Then I try on another machine with different resolution. I am
unable to get the relative position on the screen. Can anyone guide me
how to find the relative position on different screen resolutions?
Suppose i get the position on 1024 X 768. What would be that position
on 800 X 600 or 640 X 480?
|
by: Bob Palank |
last post by:
I think the ability to set a pixel on a graphics surface ought to be
straightforward and I tried to illict Dr. Guis opinion but he was too busy
to respond. So I think he must agree with me but fears authority ;-}
What do others think ? ? ? My original email and Dr. Gui's assistants reply
is shown below.
I'm worried about Dr. GUI and honestly believe he is hoarding the T-Shirts !
In fun
|
by: TomHL |
last post by:
hello,
- I have a Bitmap Object named: bmp1
- I already have the numerical values of:red,blue and green colors + I have
the X and Y cordinates.
How do I set the pixel value via safe code on the bmp1 object?
(the pixel location based on the X & Y values and it's color based on the
red,blue and green values the I already have)
|
by: Nathan Sokalski |
last post by:
I am using GDI+ to generate buttons in my application. Because I want the
left and right edges of the buttons to be a certain number of pixels from
the start and end of the text, I need to know (or be able to calculate) the
left and rightmost pixels of the text. However, this is a problem because
not all letters have their leftmost pixel at the same X position. For
example, when using the following font:
Dim buttonfont As New...
|
by: **Developer** |
last post by:
Seems that Dot.net can not handle files of Indexed Pixel Format as well as
other types of formats.
Given a file or and Image of type Indexed Pixel Format is there a method to
convert it to some other pixel format?
Thanks
| |
by: Carsten Schmitt |
last post by:
Hello,
I want to draw a simple pixel (i.e. a red pixel in the center of the
screen), which is always in the foreground - even when running a fullscreen
application like a DirectX game.
I need this as an easy entry for programming later a HUD, which shows
several informations, like date, time, company logo, etc.
Any help or just a simple code example would be appreciated.
|
by: sklett |
last post by:
I have a situation where I'm getting in Image that has a gray (solid, same
color) background with a smaller white rectangle inside. The position is
not always the same. What I need to do is locate the postion and determine
the size fo the white rectangle and then crop the image to leave only the
white rectangle remaining.
I'm very new to GDI+ and have really no idea where to start. Can anyone
suggest a good way to accomplish this?
...
|
by: Martijn Mulder |
last post by:
When I zoom in on an image, GDI+ automatically smoothens the edges
between the pixels. I am looking for a way to see the individual pixels
as squares in the enlarged image, like in MSPaint. I searched in vain in
the enumerations System.Drawing.Drawing2D.SmoothingMode and
System.Drawing.Drawing2D.InterpolationMode to find the constant that
does just that. How?
Some code to illustrate the problem:
using System.Drawing;
|
by: harryos |
last post by:
hi
i am reading thru a book on digitizing text lines using c code.They
use a font data file containing unsigned char fonts with
elements like 0x00,0x7e,0x81 etc to represent each character .After a
text line is scanned 16 times the equivalent codes are stored in an
unsigned char bitImage.
Now the digitized line stored in bitImage is taken 1 character at a
time(ie 8 bits) and color of each is to be determined whether black or
white.
The...
|
by: ofiras |
last post by:
Hi,
I made a "Paint" program, but I couldn't find a method to paint 1
pixel using graphic state ("Graphics g =
Graphics.FromHwnd(this.Handle);")
How can I paint 1 pixel?
I guess I can make a Bitmap, change one pixel color and show it, but
I'm sure there is another way of doing it.
Please help,
Ofir.
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |