Page 1 of 3 123 LastLast
Results 1 to 10 of 23

Thread: Adjustable Preview Data Format Reverse Engineered

  1. #1
    Join Date
    Dec 2009
    Location
    Gresham, OR (45.483992, -122.453879)
    Posts
    1,591
    Post Thanks / Like

    Default Adjustable Preview Data Format Reverse Engineered

    Okay, after my silly post about some LEDs last night that turned out to be operator error, I want to redeem myself. I am more of a software guy than a hardware guy, anyhow!

    I was able to reverse engineer the data format that the Adjustable Preview uses in Vixen. What this means, is that it will now be possible to write a stand alone Adjustable Preview editor. This was sparked by my other Profile Editor interest forum, and it came to fruition in about an hour today.

    Each channel is base64 encoded, that was obvious. What was not so obvious to me was how this was encoding the X & Y values. Then just for giggles, I tried little endian values and boom there they were. I can draw my Adjustable Preview in .net, it didn't look quite right, so I added the spacing like in preview and BOOM, there it was!

    Maybe I will write an Adjustable Preview editor after all.

    Code for any interested .net Geeks
    Code:
            protected override void OnPaint(PaintEventArgs pe)
            {
                string[] values = new string[216]; // I have 216 channels.
                values[0] = "SwDfAEsA3gBLAN0ASwDcAEsA2wBLANoASwDZAEsA2ABLANcASwDWAEsA1QBKANUASQDVAEkA1wBJANgASQDZAEkA2gBJANYASQDbAEkA3ABJAN0ASQDeAEkA3wBKAN8ASgDeAEoA3QBKANwASgDbAEoA2gBKANkASgDYAEoA1wBKANYA";
    
    <SNIP>            
    
                values[214] = "CQEWAgoBFgILARYCDAEWAggBFgIHARUCBwEUAggBEwI=";
    
                base.OnPaint(pe);
                System.Drawing.Graphics graphics = pe.Graphics;
                Brush brush = new SolidBrush(Color.Green);
    
                foreach (string value in values)
                {
                    if (null != value)
                    {
                        byte[] bytes = Convert.FromBase64String(value);
                        for (int i = 0; i < bytes.Length; i += 4)
                        {
                            uint decode= BitConverter.ToUInt32(bytes, i);
                            int x = (int)(decode >> 0x10) * 2;
                            int y = (int)(decode & 0xFFFF) * 2;
                            graphics.FillRectangle(brush, new Rectangle(x, y, 1, 1));
                        }
                    }
                }
            }

  2. #2
    Join Date
    Dec 2010
    Location
    Avon Lake, OH
    Posts
    479
    Post Thanks / Like

    Default Re: Adjustable Preview Data Format Reverse Engineered

    Quote Originally Posted by macebobo View Post
    Code for any interested .net Geeks
    Code:
            protected override void OnPaint(PaintEventArgs pe)
            {
                string[] values = new string[216]; // I have 216 channels.
                values[0] = "SwDfAEsA3gBLAN0ASwDcAEsA2wBLANoASwDZAEsA2ABLANcASwDWAEsA1QBKANUASQDVAEkA1wBJANgASQDZAEkA2gBJANYASQDbAEkA3ABJAN0ASQDeAEkA3wBKAN8ASgDeAEoA3QBKANwASgDbAEoA2gBKANkASgDYAEoA1wBKANYA";
    
    <SNIP>            
    
                values[214] = "CQEWAgoBFgILARYCDAEWAggBFgIHARUCBwEUAggBEwI=";
    
                base.OnPaint(pe);
                System.Drawing.Graphics graphics = pe.Graphics;
                Brush brush = new SolidBrush(Color.Green);
    
                foreach (string value in values)
                {
                    if (null != value)
                    {
                        byte[] bytes = Convert.FromBase64String(value);
                        for (int i = 0; i < bytes.Length; i += 4)
                        {
                            uint decode= BitConverter.ToUInt32(bytes, i);
                            int x = (int)(decode >> 0x10) * 2;
                            int y = (int)(decode & 0xFFFF) * 2;
                            graphics.FillRectangle(brush, new Rectangle(x, y, 1, 1));
                        }
                    }
                }
            }
    Nice work! I see a memory leak. Make sure to call dispose on the brush, or put it a using construct. If you are always going to use a green colored brush, you could make it a static reference.

    Erik

  3. #3
    Join Date
    Dec 2009
    Location
    Gresham, OR (45.483992, -122.453879)
    Posts
    1,591
    Post Thanks / Like

    Default Re: Adjustable Preview Data Format Reverse Engineered

    Erik. Thanks. This was just a spike to see if it could be done. My first foray into graphics. Which other objects in System.Drawing must I call dispose on? -- John

  4. #4
    Join Date
    Dec 2010
    Location
    Avon Lake, OH
    Posts
    479
    Post Thanks / Like

    Default Re: Adjustable Preview Data Format Reverse Engineered

    Quote Originally Posted by macebobo View Post
    Erik. Thanks. This was just a spike to see if it could be done. My first foray into graphics. Which other objects in System.Drawing must I call dispose on? -- John
    Anything that implements the IDisposable interface that you create. The graphics object is disposable, but the system owns that object (it is passed in the event args parameters), so the caller in the system will call dispose. Be careful as well, as once dispose it called, the object is not really usable. Here is a long, but good read: http://www.codeproject.com/KB/dotnet/idisposable.aspx

    Erik

    Erik

  5. #5
    Join Date
    Oct 2008
    Location
    San Jose, CA
    Posts
    10,283
    Post Thanks / Like

    Default Re: Adjustable Preview Data Format Reverse Engineered

    You will be an absolute hero to everyone here that uses Vixen if you get a better AP editor working - even simulating MS 'Paint' usage would be a great improvement (no offense KC!).
    [COLOR=#000080][B][I]Brian[/I][/B][/COLOR]

    [COLOR=#ff0000]Christmas in San Jose! - [URL="http://www.christmasinsj.com"]WEB[/URL] - [URL="https://www.facebook.com/ChristmasInSanJose"]FB[/URL] - [URL="https://www.youtube.com/playlist?list=PL1W78s7liEQEE0ed7WSyLF7B6j3lBX43w"]VIDEOS[/URL]
    [/COLOR][COLOR=#800080]Halloween in San Jose! - [URL="https://www.facebook.com/pages/Halloween-in-San-Jose/356280784428581?ref=tn_tnmn"]FB[/URL]
    [SIZE=1]2015 Halloween Show - Planning now - hopefully some house projection...
    2015 Christmas Show - 5x E681-12, 1x 6804, Ren48LSD, 3x RenSS16, 1x Falcon16v2 (w/expander), 24x90 WS2811 pixel MT (James MT Strips), 12x DIYC Floods, SuperPixelStar, 3x Pixel Arches, PixaBulb House outline
    [/SIZE]
    [/COLOR][SIZE=3][COLOR=#008000][I]Ignorance is Temporary [/I][/COLOR][COLOR=#800080][I]- [/I][/COLOR][COLOR=#ff0000][I]Stupidity is Forever[/I][/COLOR][COLOR=#800080][I]...[/I][/COLOR][/SIZE][I][COLOR=#ff0000]
    [/COLOR][/I]

  6. #6
    Join Date
    Dec 2009
    Location
    Gresham, OR (45.483992, -122.453879)
    Posts
    1,591
    Post Thanks / Like

    Default Re: Adjustable Preview Data Format Reverse Engineered

    Good read. I'll pass everything through FXCop, although, I remember it being picky about some stuff. :D

  7. #7
    Join Date
    Dec 2009
    Location
    Gresham, OR (45.483992, -122.453879)
    Posts
    1,591
    Post Thanks / Like

    Default Re: Adjustable Preview Data Format Reverse Engineered

    Quote Originally Posted by budude View Post
    You will be an absolute hero to everyone here that uses Vixen if you get a better AP editor working - even simulating MS 'Paint' usage would be a great improvement (no offense KC!).
    I think I am a ways away from that. There are a lot of moving pieces with AP that I have not even begun to understand. The key, id, BackgroundImage encoding and RedirectOutputs to name a few. One little step at a time. Plus, I still have sequencing to do. UGH.

  8. #8
    Join Date
    Dec 2009
    Location
    Gresham, OR (45.483992, -122.453879)
    Posts
    1,591
    Post Thanks / Like

    Default Re: Adjustable Preview Data Format Reverse Engineered

    Quote Originally Posted by budude View Post
    You will be an absolute hero to everyone here that uses Vixen if you get a better AP editor working - even simulating MS 'Paint' usage would be a great improvement (no offense KC!).
    I got to thinking about this on the ride home. What part of MS Paint doesn't the current AP have? (Too be honest, I have not looked at Paint recently as I use GIMP.) But what are some features people would want in an AP editor?

  9. #9
    Join Date
    Oct 2008
    Location
    San Jose, CA
    Posts
    10,283
    Post Thanks / Like

    Default Re: Adjustable Preview Data Format Reverse Engineered

    Quote Originally Posted by macebobo View Post
    I got to thinking about this on the ride home. What part of MS Paint doesn't the current AP have? (Too be honest, I have not looked at Paint recently as I use GIMP.) But what are some features people would want in an AP editor?
    snaring an object and moving it elsewhere - that alone would make it twice as useful...
    [COLOR=#000080][B][I]Brian[/I][/B][/COLOR]

    [COLOR=#ff0000]Christmas in San Jose! - [URL="http://www.christmasinsj.com"]WEB[/URL] - [URL="https://www.facebook.com/ChristmasInSanJose"]FB[/URL] - [URL="https://www.youtube.com/playlist?list=PL1W78s7liEQEE0ed7WSyLF7B6j3lBX43w"]VIDEOS[/URL]
    [/COLOR][COLOR=#800080]Halloween in San Jose! - [URL="https://www.facebook.com/pages/Halloween-in-San-Jose/356280784428581?ref=tn_tnmn"]FB[/URL]
    [SIZE=1]2015 Halloween Show - Planning now - hopefully some house projection...
    2015 Christmas Show - 5x E681-12, 1x 6804, Ren48LSD, 3x RenSS16, 1x Falcon16v2 (w/expander), 24x90 WS2811 pixel MT (James MT Strips), 12x DIYC Floods, SuperPixelStar, 3x Pixel Arches, PixaBulb House outline
    [/SIZE]
    [/COLOR][SIZE=3][COLOR=#008000][I]Ignorance is Temporary [/I][/COLOR][COLOR=#800080][I]- [/I][/COLOR][COLOR=#ff0000][I]Stupidity is Forever[/I][/COLOR][COLOR=#800080][I]...[/I][/COLOR][/SIZE][I][COLOR=#ff0000]
    [/COLOR][/I]

  10. #10
    Join Date
    May 2007
    Location
    Apple Valley, MN
    Posts
    3,755
    Post Thanks / Like

    Default Re: Adjustable Preview Data Format Reverse Engineered

    The current AP has all the finesse of a pencil. You can draw or erase the pixel under the mouse pointer, that's it!

    Even rubber band around an area with copy, paste and move would be huge.
    [I]A mediocre person tells. A good person explains. A superior person demonstrates. A great person inspires others to see for themselves.[/I]

    <a href="#" onclick="return(showhide(this));">Click here to show/hide my display details ...</a>
    <script language="javascript">function showhide(anc){ for(; ; ){ if(!anc.nextSibling) break; if(anc.nextSibling.nodeName == "DIV") break; anc = anc.nextSibling; }//<br />
    var Y='block', N='none', det=anc.nextSibling; //<br />
    if (!det) det=document.getElementById('details'); det.style.display=(det.style.display!=N)?N:Y; return false;}</script><div id="details" style="display:none;"><br /><img src="http://www.vixenlights.com/sig/sig_h.php/128/All.gif" border="0" alt="" /></div><a href="#" onclick="return(showhide(this));">Click here to show/hide DIYC Links ...</a>
    <script language="javascript">function showhide(anc){ for(; ; ){ if(!anc.nextSibling) break; if(anc.nextSibling.nodeName == "DIV") break; anc = anc.nextSibling; }//<br />
    var Y='block', N='none', det=anc.nextSibling; //<br />
    if (!det) det=document.getElementById('details'); det.style.display=(det.style.display!=N)?N:Y; return false;}</script><div id="details" style="display:none;"><br /><b>Chat link</b> - <a href="http://doityourselfchristmas.com/forums/addonchat.php" target="_blank">http://doityourselfchristmas.com/forums/addonchat.php</a>
    <b>Christmas Wiki link</b> - <a href="http://doityourselfchristmas.com/wiki/index.php" target="_blank">http://doityourselfchristmas.com/wiki/index.php</a>
    <b>File Library link</b> - <a href="http://doityourselfchristmas.com/forums/dynamics/index.php" target="_blank">http://doityourselfchristmas.com/forums/dynamics/index.php</a>
    <b>Who's in chat?</b> - <a href="http://doityourselfchristmas.com/forums/chat/info.php" target="_blank">http://doityourselfchristmas.com/forums/chat/info.php</a>
    </div>

Page 1 of 3 123 LastLast

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
  •