Win a copy of Penetration Testing Basics this week in the Security forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to find Pixels info from a text String

arun mahajan
Ranch Hand
Posts: 305
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI Everybody,
I am in a fix and would like to take some help from you, if possible.
I am working on a project which has a canvas of 100x100 pixel size.I am putting Text using drawString method of graphics to put some text on the canvas. Now after putting this text on canvas I am trying to find follwoing info. Is this possible.
1. What is the total width of the String. e.g. if String is "Hello How Are you" the width of whole String.
2. What will be the height of the String.
3. What are the pixel this string is using for drawing. What I mean say if I am drawing "H" in say using 10x10 pixel rectangle(of course it should depend upon the Font Size and style). Which pixel will be Black(color of the text) and which pixel will be white(color of canvas).
You see the idea for getting this info is that I want to make a string which is in "0" and "1" where "0" stands for Black and "1" stands for white. and once I have this I can use it in other formats.
Do you have any idea
Thanks in advance for the help extended.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic