View Single Post
Old 7th December 2016, 19:12   #4  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
DDigit has frame and string formatting (eg "\n" frame and "%.6.2f" string), and color, vertical print, character and pixel coords.

Info.h and sister header InfoF.h (also both available in DDigit zip [dont use old bugged versions of Info.h, IanB did a refactor a few years back])
also provide frame/string formatting using eg this code snippet from to 'CPP for C Proggers' thread.

Code:
void __stdcall INTERNALNAME::DrawFStr(PVideoFrame &dst,int x,int y,const char *format, ...)
{
  // This member function added in v0.2, adds BOTH string and screen formatting, eg '%f' for string and '\n' for screen.

  // Firstly, string formatting, into the buffer implemented in the class instance, formatted_buf[FMT_BUFSZ].
  va_list args;
  va_start(args, format);
  _vsnprintf(formatted_buf,FMT_BUFSZ-1, format, args);
  va_end(args);

  // The DrawFStrXXX fn's are implemented in the InfoF.h file and provide screen formatting, eg '\n' and '\t'.
  // As string formatting has already been done above (eg floats etc turned to character strings), and the below
  // DrawFStrXXX functions provide screen formatting, so full formatting is achieved on the video frame.
  //
  //   Formatting control codes (as provided by InfoF.h):-
  //   '\n', Newline, positioning cursor 1 line down and at left edge of screen.
  //   '\r', Newline Special, moves 1 line down and positions cursor at on-entry X position.
  //   '\b', Backspace, obvious, not sure how useful this will be.
  //   '\f', Forward Space, again obvious, re-uses formfeed code for this. Again, maybe not so useful.
  //   '\t', Tab, @ character positions, every 4 characters.(relative screen LHS).
  //  
  if(vi.IsPlanar())     DrawFStrPlanar(dst,x,y,formatted_buf);
  else if(vi.IsYUY2())  DrawFStrYUY2(dst,x,y,formatted_buf);
  else if(vi.IsRGB32()) DrawFStrRGB32(dst,x,y,formatted_buf);
  else if(vi.IsRGB24()) DrawFStrRGB24(dst,x,y,formatted_buf);
}
See the graphic in this post, http://forum.doom9.org/showthread.ph...64#post1539764
that chunk of text at bottom is result of a single DrawFStr() call using Info.h (white only text).
DDigit can do all of that + color + vertical print. I use DDigit all of the time (occasionally Info/InfoF.h),
only other plug that has used it (to my knowledge) is Frustrum's AutoLevels.

EDIT:
DDigitTest (in Developer folder in MediaFire below this post in sig), is a source code library, but has a demo function
called DDigitTest, so you can see what it can do. Info/InfoF.h is separately available in Developer folder and also in
DDigit zip.
If you have seen GamMac plugin images, then you have already seen DDigit in action (also used in many other
of my plugins).

EDIT: Not much of a demo but below shows colored text in GamMac() metrics using DDigit:-


Info/InfoF.h combo can do same, but not in color.
RT_Subtitle() also uses DDigit library, and can also print in color for Script metrics (way faster than Subtitle in ScriptClip).
EDIT: Also either Info.h or DDigit in GetFrame() would be well faster than Subtitle.

EDIT:
From InfoF.H header giving frame formatted output (RGB24 only shown)
Code:
void  __stdcall DrawFStringRGB24(PVideoFrame &dst,int x,int y,const char *s,bool pix = true)
{ // Draw formatted string at pixel or character coords, pix == false = character coords
    if(pix == false) {x *= 10;  y *= 20;}                       // To Chars
    int in_x = x;                                               // REM x for '\r'
    const unsigned char *se=(unsigned char*)s;                  // unsigned
    while(*se) {                                                // while, some to do
        int n;
        for(s=(char*)se; n = *se, n>=' ' && n <= 223; ++se);    // Find end+1 of printable
        int len = (char*)se - s;                                // Len of printable
        if (len) {                                              // Some to print
            DrawStringRGB24(dst,x,y,s,len);                     // do the biz # EDIT: Call Info.h
            x += len * 10;                                      // update x coord
        } else {                                                // Ctrl code OR nonsense;
            if(n == '\n') {
                x = 0;      y+=20;                          // Newline, down 1, LHS
            } else if (n == '\r') {
                x = in_x;   y +=20;                         // Newline Special, Down 1, orig x coord
            } else if(n == '\b') {
                x -= 10;                                    // Backward Space
            } else if (n == '\f') {
                x += 10;                                    // Forward Space
            } else if (n == '\t') {
                x+= ((4*10)-(x%(4*10)));                    // H-Tab (step 4)
            }
            ++se;   // skip ctrl code (and unknowns, outer loop detects nul sentinel)
        }
    }
}

void  __stdcall DrawFStrRGB24(PVideoFrame &dst,int x,int y,const char *s)
{   // Formatted Print @ character coords
    DrawFStringRGB24(dst,x,y,s,false);
}
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 30th November 2018 at 11:48.
StainlessS is offline   Reply With Quote