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
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));
}
}
}
}
macebobo wrote:Code for any interested .net Geeksprotected 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
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
macebobo wrote: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
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!).
