Post Reply 
TEXTOUT_P : width ?
10-03-2015, 07:45 PM
Post: #6
RE: TEXTOUT_P : width ?
This is the fastest way I found to calculacte the width and height of the text.

The following functions should take less than 2ms.

Width:
Code:
TEXTW_P(t,s)
BEGIN
 local x,a=0,b=511,m;
 DIMGROB_P(G9,512,1);
 TEXTOUT_P(t,G9,0,0,s,0,511,0);
 FOR x FROM 1 TO 10 DO
   IP((a+b)/2)▶m;
   IFTE(GETPIX_P(G9,m,0)=#FFFFFFh,m▶b,m▶a);
 END;
 RETURN m;
END;

Height:
Code:
TEXTH_P(t,s)
BEGIN
 local x,a=0,b=31,m;
 DIMGROB_P(G9,1,32);
 TEXTOUT_P(t,G9,0,0,s,0,1,0);
 FOR x FROM 1 TO 6 DO
   IP((a+b)/2)▶m;
   IFTE(GETPIX_P(G9,0,m)=#FFFFFFh,m▶b,m▶a);
 END;
 RETURN m;
END;

as before:
t - text for check the width or height
s - font size (0 = default from Home settings)

During the performance tests when I created this solution I think I detected a bug (very little) in the function TEXTOUT_P, but I will write about this in a separate thread.

Piotr Kowalewski
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
TEXTOUT_P : width ? - primer - 10-02-2015, 08:41 AM
RE: TEXTOUT_P : width ? - xset - 10-02-2015, 09:17 AM
RE: TEXTOUT_P : width ? - komame - 10-02-2015, 12:51 PM
RE: TEXTOUT_P : width ? - komame - 10-03-2015, 08:56 AM
RE: TEXTOUT_P : width ? - eried - 10-03-2015, 05:42 PM
RE: TEXTOUT_P : width ? - komame - 10-03-2015 07:45 PM
RE: TEXTOUT_P : width ? - komame - 10-04-2015, 04:21 PM
RE: TEXTOUT_P : width ? - primer - 10-05-2015, 03:04 PM
RE: TEXTOUT_P : width ? - Tyann - 10-12-2015, 11:58 AM
RE: TEXTOUT_P : width ? - hpfx - 10-14-2015, 10:02 PM



User(s) browsing this thread: 1 Guest(s)