measure

Calculate exact character\\string height in javascript

淺唱寂寞╮ 提交于 2019-11-29 18:07:44
I'm working with canvases and i can't think of any solution, or find answer on line to my problem. I have a font that contains symbols\characters from varies sizes - heights and width. I want to draw some characters (Symbols) from the font and some on top\down of the symbol. The problem is that I can't figure out a way to have the exact height in pixels of the character that i'm drawing, and it's causes unwanted spaces between the center symbol to the one on top\down (for getting the width of a string there is the function context.measureText(theText) ). for ex. lets say that i want 'X' to be

Measure time, milliseconds or microseconds for Windows C++ [duplicate]

做~自己de王妃 提交于 2019-11-29 14:37:34
问题 This question already has answers here : How to Calculate Execution Time of a Code Snippet in C++ (16 answers) Closed 5 years ago . How do you measure the execution time in milliseconds or microseconds in Windows C++? I found many method one calling time(NULL), but it measures time in seconds only and the seconds clock() (clock_t) measure CPU time, not the actual time. I found the function gettimeofday(Calendar time) mentioned in this paper: dropbox.com/s/k0zv8pck7ydbakz/1_7-PDF_thesis_2.pdf

Measure String inside RichTextBox Control

蹲街弑〆低调 提交于 2019-11-29 09:48:53
Can somebody please explain how I would go about measuring the string inside a richtextbox control so that the I can automatically resize the richtextbox control according to its content? Thank you Edit: I've thought about it, and since the below answer won't work if there are different fonts in the RichTextBox Control, what if, I could get the upper-left coords of the richtextbox control and then get the bottom-right coords of the very last line of text inside the rtb. That would essentially give me the Width and Height of the string inside the RichTextBox Control. Is this possible? Or is

Programmatically determining max fit in textbox (WP7)

帅比萌擦擦* 提交于 2019-11-29 04:48:12
I'm currently writing an eBook reader for Windows Phone Seven, and I'm trying to style it like the Kindle reader. In order to do so, I need to split my books up into pages, and this is going to get a lot more complex when variable font sizes are added. To do this at the moment, I just add a word at a time into the textblock until it becomes higher than its container. As you can imagine though, with a document of over 120,000 words, this takes an unacceptable period of time. Is there a way I can find out when the text would exceed the bounds (logically dividing it into pages), without having to

Measure execution time in C#

半城伤御伤魂 提交于 2019-11-28 18:36:26
I want to measure the execution of a piece of code and I'm wondering what the best method to do this is? Option 1: DateTime StartTime = DateTime.Now; //Code TimeSpan ts = DateTime.Now.Subtract(StartTime); string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10); Console.WriteLine(elapsedTime, "RunTime"); Option 2: using System.Diagnostics; Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); //Code stopWatch.Stop(); // Get the elapsed time as a TimeSpan value. TimeSpan ts = stopWatch.Elapsed; // Format and display the

getMeasuredWidth returns totally wrong value

妖精的绣舞 提交于 2019-11-28 17:10:43
问题 I have to measure a View for spacing others. I use this code for that: ViewGroup view = ...; view.setPadding(10, 0, 10, 0); int wrapContent = RelativeLayout.LayoutParams.WRAP_CONTENT; int specWidth = MeasureSpec.makeMeasureSpec(wrapContent, MeasureSpec.AT_MOST); view.measure(specWidth, specWidth); int questionWidth = view.getMeasuredWidth(); This works as expected on an Android 4.3 emulator. However the returned measured width on a Samsung Galaxy XCover 2 (S7710) Android 4.1.2 phone, is

Measuring Download Speed Java

故事扮演 提交于 2019-11-28 09:28:20
I'm working on downloading a file on a software, this is what i got, it sucesfully download, and also i can get progress, but still 1 thing left that I dont know how to do. Measure download speed. I would appreciate your help. Thanks. This is the current download method code public void run() { OutputStream out = null; URLConnection conn = null; InputStream in = null; try { URL url1 = new URL(url); out = new BufferedOutputStream( new FileOutputStream(sysDir+"\\"+where)); conn = url1.openConnection(); in = conn.getInputStream(); byte[] buffer = new byte[1024]; int numRead; long numWritten = 0;

Measure String inside RichTextBox Control

試著忘記壹切 提交于 2019-11-28 03:11:29
问题 Can somebody please explain how I would go about measuring the string inside a richtextbox control so that the I can automatically resize the richtextbox control according to its content? Thank you Edit: I've thought about it, and since the below answer won't work if there are different fonts in the RichTextBox Control, what if, I could get the upper-left coords of the richtextbox control and then get the bottom-right coords of the very last line of text inside the rtb. That would essentially

View's getWidth() and getHeight() returning 0

三世轮回 提交于 2019-11-27 14:59:48
I have looked at the similar questions and tried their solutions but it did not work for me. I try to take width of an imageView, but it returns 0. Here is the code: public class MainActivity extends Activity { private ImageView image1; float centerX,centerY; private ImageView image2; private boolean isFirstImage = true; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.rotate); image1 = (ImageView) findViewById(R.id.ImageView01); image2 = (ImageView) findViewById(R.id.ImageView02); image2.setVisibility(View.GONE); if

Measure execution time in C#

北城以北 提交于 2019-11-27 11:30:20
问题 I want to measure the execution of a piece of code and I'm wondering what the best method to do this is? Option 1: DateTime StartTime = DateTime.Now; //Code TimeSpan ts = DateTime.Now.Subtract(StartTime); string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10); Console.WriteLine(elapsedTime, "RunTime"); Option 2: using System.Diagnostics; Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); //Code stopWatch.Stop(); // Get