aspose file tools
The moose likes Swing / AWT / SWT / JFace and the fly likes How to find Pixels info from a text String Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT / JFace
Reply Bookmark "How to find Pixels info from a text String" Watch "How to find Pixels info from a text String" New topic
Author

How to find Pixels info from a text String

arun mahajan
Ranch Hand

Joined: Dec 07, 2001
Posts: 304
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.
regards,
Arun
 
 
subject: How to find Pixels info from a text String
 
Threads others viewed
How does canvas, an exteded JPanel obj have methods getSize(), createImage(size.width, size.height)?
Structure Size
jpeg problems
Drawing Canvas
Pixel Transparency
developer file tools