Page 1 of 8 123 ... LastLast
Results 1 to 10 of 71

Thread: Convert text to Ledtriks format

  1. #1

    Default Convert text to Ledtriks format

    I would like to be able to write a utility that would convert text in a file to a .led file but I can't figure out the format of the converted .led files. I attempted to figure it out on my own by creating some simple .led files from Vixen then looking at the format in the file. I know from reading the forum that some people have figured it out and explained it but I'm not quite getting the picture. If anyone who has figured it out and can explain it (LedTriks for dummies version), I would really appreciate it.
    8 Renard 16s (xmus) with Ren-W
    6 Renard SS8 with Ren-W
    3 Renard 16LSDs with Ren-W for RGB Floodlights
    2 Renard 24LSD(Robo) with Ren-W for RGB spotlights
    2 682s Pixel Controllers for GECE lights
    LedTriks (1x2),RDS

  2. #2
    Join Date
    Sep 2008
    Location
    Baulkham Hills, NSW
    Posts
    2,241

    Default Re: Convert text to Ledtriks format

    Welcome to the Club. There are a number of people that would like to create frames ( test or graphics) out side of Vixen.
    the best explanation I have seen to date is found in this thread
    It doesn't sound easy.


    KR
    Matt
    Matt

    You too can become a Supporting member of DIYC.
    Check it out here

    Baulkolites.com is going to close - my new site is MyNoelLights.com

  3. #3
    Join Date
    Nov 2007
    Location
    Melbourne Australia
    Posts
    551

    Default Re: Convert text to Ledtriks format

    For base 64 info try this post.

    Tim

  4. #4
    Join Date
    Aug 2007
    Location
    Medford, ny
    Posts
    614

    Default Re: Convert text to Ledtriks format

    Im not a programmer but if this was written in normal code why is it so hard to convert? I hope someone cracks this thing soon and posts a program its very hard to make images from scratch.

  5. #5

    Default Re: Convert text to Ledtriks format

    Here is some code that I have been playing with to convert base64 to decimal.


    /************************************************** *******************
    *
    * base64conversion
    *
    ************************************************** *******************
    * Based upon:
    * http://users.fmrib.ox.ac.uk/~crodger...ase64-encode.c
    * http://users.fmrib.ox.ac.uk/~crodger...ase64-decode.c
    *
    ************************************************** ******************/

    const unsigned char alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvw xyz0123456789+";
    // "AAAAAA=="
    // "AAAAAAAAAQA="
    // "AAAFAAAAGQAAABEAAAAsAA=="
    // "AQAFAAEAGQABABEAAQAsAA=="
    // "AgAFAAIAGQACABEAAgAsAAAADAAAACMA"
    // "AwAFAAMAGQADABEAAwAsAAEADAABACMAAAABAAAAFgA="
    // "AAAAAAAAAQAAAAIAAAADAA=="

    const unsigned char inputData[] = "AAAAAAAAAQAAAAIAAAADAA==";
    union
    {
    unsigned char outputData[48];
    unsigned long outputWord[24];
    } test;

    unsigned char decoder(unsigned char data);

    void main(void)
    {
    short errorFlag;

    int i, char_count, o, bit_s;
    long long bits;

    for(i=0;i<48;i++)
    test.outputData[i] = 0;

    char_count = 0;
    bits = 0;
    i = 0;
    o = 0;
    errorFlag = FALSE;

    while( inputData[i] != '\0')
    {
    if (inputData[i] == '=')
    break;
    if( !((inputData[i] > '/' && inputData[i] < ':')
    || (inputData[i] > '@' && inputData[i] < '{')) )
    continue;
    bit_s = decoder(inputData[i]);
    bits += bit_s;
    char_count++;
    if (char_count == 4)
    {
    test.outputData[o++] = (bits >> 16);
    test.outputData[o++] = ((bits >> 8) & 0xff);
    test.outputData[o++] = (bits & 0xff);
    bits = 0;
    char_count = 0;
    }
    else
    {
    bits <<= 6;
    }
    i++;
    }
    if (inputData[i] == '\0')
    {
    if (char_count)
    {
    //fprintf(stderr, "base64 encoding incomplete: at least %d bits truncated", ((4 - char_count) * 6));
    errorFlag = TRUE;
    }
    }
    else
    { //c == '='
    switch (char_count)
    {
    case 1:
    //fprintf(stderr, "base64 encoding incomplete: at least 2 bits missing");
    errorFlag = TRUE;
    break;
    case 2:
    test.outputData[o++] = (bits >> 10);
    break;
    case 3:
    test.outputData[o++] = (bits >> 16);
    test.outputData[o++] = ((bits >> 8) & 0xff);
    break;
    }
    }
    while(1)
    delay_cycles(1);
    }

    unsigned char decoder(unsigned char data)
    {
    int t;

    for(t=0;t<64;t++)
    {
    delay_cycles(1);
    if(data == alphabet[t])
    {
    break;
    }
    }
    delay_cycles(1);
    return t;
    }

  6. #6
    Join Date
    Oct 2008
    Location
    San Jose, CA
    Posts
    7,765

    Default Re: Convert text to Ledtriks format

    I found lots of examples of base64 encoding - the issue was the class conversions in C++ - I could not figure them out. The examples I saw on the web always had a particular input/output format but none matched what I needed.

    I talked with KC about this a while back - here's some snippets from that:

    The data is a list of unsigned integers, broken into bytes, and then base-64 encoded so that it can be stored as text. So, you have a couple of options:

    1. Create the data manually: for each pixel that's turned on in the frame, create an unsigned integer with the upper 16 bits being the x coordinate and the lower 16 being the y coordinate. Then take all of the unsigned integers, break them into bytes, and convert the resulting byte array into a base-64 string.

    or

    2. There's a class inside LedTriksUtil.dll called "Frame". It will save a couple of steps, but it doesn't do *everything*. When you create an instance of the Frame class, you specify the length of the frame in milliseconds. It doesn't do anything to create the frame data for you, but it exposes its list (named "Cells") which holds the unsigned integers I spoke of earlier. But it will handle the base-64 encoding and decoding for you -- SaveToXml() takes the XML node that will be the parent of the frame node (like the "Frames" list element in the .LED file), and there is a constructor that will take an XML node that was a node that was previously saved with SaveToXml.

    Let me know if I can be of any more help.

    K.C.

    It looks like that code assumes that what you're wanting to encode/decode is already a string. If you're going to be using Visual Studio or Express, take a look into Convert.ToBase64String() and Convert.FromBase64String(). Both of those make use of byte arrays. You can use BitConverter.ToUInt32() to create an unsigned integer from the bytes in the array.

    I don't think the tool will be too difficult for anyone with any C++/## skills - it's just beyond me for the moment. Also - keep in mind you have to convert the incoming stream - that is where ImageMagick came in. I created PGM/PBM format files sized to the appropriate resolution. What I did was set an adjustable contrast limit where depending on the level I would make it either on or off. As I said before, the results depend greatly on the starting material - the more contrast/definition - the better. Note that this only creates a single frame in the .led file. The tool should allow different LEDTrik panel configurations (1x1, 2x1, 1x2, 4x4, etc).

    Ideally, you can then use another tool to take a video and create snapshots every second or so from that and then convert those individual files using the tool from above and combine them to make a true .led animation. Again - the results will obviously not be hi-res video - but with some editing might be quite passable.
    Last edited by budude; 10-02-2009 at 11:57 AM.
    Brian

    Christmas in San Jose! - WEB - FB - VIDEOS
    Halloween in San Jose! - FB
    2013 Halloween Show - Homemade tombstones, Grave Crawler, 2x 3-axis skulls, Video Projection
    2013 Christmas Show - 5x E681-12, 1x Ren48LSD, 30x 42 TLS3001 pixels, 4x 50 GECE C9, 4x Rainbow Floods, 2x DIYC Floods, SuperPixelStar... - no AC stuff!

    Ignorance is Temporary - Stupidity is Forever...

  7. #7

    Default Re: Convert text to Ledtriks format

    RE: Conversions to/from Base 64....

    MSXML makes it VERY easy to convert back and forth from Base64 and Bytes (which is what you would probably need for this).

    I know you guys are talking C+/C#, but here is some VB6 code that will do the conversions back and forth. You should be able to add calls to the MSXML DLL in any language.

    I know these work since they are from my AD to VIX conversion pgm. I can't take full credit for these (I found the idea somewhere and modified):

    In your project, add a reference to MSXML (I used V6)....

    This function takes an array of bytes (8 bit unsigned), and returns it as a base64 string


    Code:
     
    Function EncodeBase64(ByRef arrData() As Byte) As String
     
        Dim objXML As MSXML2.DOMDocument ' declare a new document
        Dim objNode As MSXML2.IXMLDOMElement ' declare an element
     
        ' help from MSXML
        Set objXML = New MSXML2.DOMDocument ' create the document
     
        ' byte array to base64
        Set objNode = objXML.createElement("b64") 'create a new node
        objNode.dataType = "bin.base64" ' make it base64
        objNode.nodeTypedValue = arrData 'assign the byte data
        EncodeBase64 = objNode.Text ' get it back as a string
     
        ' thanks, bye
        Set objNode = Nothing
        Set objXML = Nothing
     
    End Function

    This does the DEcoding. If you look, it's identical except it assigns to
    the 'text' part of the node, and gets data back from the 'typed value' (bytes). MSXML does ALL the conversions for you.

    Code:
     
    Function DecodeBase64(ByVal strData As String) As Byte()
        Dim objXML As MSXML2.DOMDocument
        Dim objNode As MSXML2.IXMLDOMElement
     
        ' help from MSXML
        Set objXML = New MSXML2.DOMDocument
        Set objNode = objXML.createElement("b64")
        objNode.dataType = "bin.base64"
        objNode.Text = strData 'this time, take the string data that was passed in
        DecodeBase64 = objNode.nodeTypedValue 'and output the byte values
     
        ' thanks, bye
        Set objNode = Nothing
        Set objXML = Nothing
     
    End Function
    Last edited by oldcqr; 10-02-2009 at 12:06 PM.
    -Mike
    www.LandoLights.com
    www.SequenceCenter.com --> Vixen/LOR Sequences and More

  8. #8
    Join Date
    Aug 2007
    Location
    Medford, ny
    Posts
    614

    Default Re: Convert text to Ledtriks format

    So if thats all it is can someone make an easy to use program for non programmers to use to convert images or other thing to led files?

  9. #9

    Default Re: Convert text to Ledtriks format

    Quote Originally Posted by boarder3 View Post
    So if thats all it is can someone make an easy to use program for non programmers to use to convert images or other thing to led files?
    It's easy to convert to/from Base64, but getting the data in the first place... well... that's another story !
    -Mike
    www.LandoLights.com
    www.SequenceCenter.com --> Vixen/LOR Sequences and More

  10. #10
    Join Date
    Oct 2008
    Location
    San Jose, CA
    Posts
    7,765

    Default Re: Convert text to Ledtriks format

    As I mentioned above - if you use ImageMagick you can convert the image to 48x16, 48x32, 96x16, etc resolution and to multi-level Grey (basically 0-255 black) and the output will be PBM/PGM (don't recall which one I used) which is just a text file with the pixel values of the picture you started with. You then read this in to your tool (ImageMagick has an API so you could put this in that tool also), apply the level of contrast on/off, create the byte arrays, convert to base64 and finally encode to the correct XML .led file format.

    It sounds like a lot but it's not really - I was 95% there - just could not get the byte array to base 64 correct. I got output but when I loaded it into the Vixen LedTriks editor it always puked on it and I just had too many other things to do so I left it...

    It could certainly be done with VB too - the same base64 encoding tools are there also. I think you would get lots of hugs and kisses if you got this tool running!
    Brian

    Christmas in San Jose! - WEB - FB - VIDEOS
    Halloween in San Jose! - FB
    2013 Halloween Show - Homemade tombstones, Grave Crawler, 2x 3-axis skulls, Video Projection
    2013 Christmas Show - 5x E681-12, 1x Ren48LSD, 30x 42 TLS3001 pixels, 4x 50 GECE C9, 4x Rainbow Floods, 2x DIYC Floods, SuperPixelStar... - no AC stuff!

    Ignorance is Temporary - Stupidity is Forever...

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •