home
products
contribute
download
documentation
forum
Home
Forums
New posts
Search forums
What's new
New posts
All posts
Latest activity
Members
Registered members
Current visitors
Donate
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Search titles only
By:
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
MediaPortal 2
Plugin Development
AtmoLight 2.1.0.0 for MediaPortal2 [2015-01-21]
Contact us
RSS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Lightning303" data-source="post: 1077272" data-attributes="member: 97876"><p>OK, after a lot of trial and error i came up with this.</p><p></p><p>[CODE=C#] private SharpDX.Direct3D9.Surface rgbSurface;</p><p> private void MyThread()</p><p> {</p><p> while (ServiceRegistration.Get<IPlayerContextManager>().IsVideoContextActive)</p><p> {</p><p> try</p><p> {</p><p> rgbSurface = ServiceRegistration.Get<ISharpDXVideoPlayer>().Surface;</p><p> Rectangle rect = new Rectangle(0, 0, rgbSurface.Description.Width, rgbSurface.Description.Height);</p><p></p><p> DataStream stream = SharpDX.Direct3D9.Surface.ToStream(rgbSurface, SharpDX.Direct3D9.ImageFileFormat.Bmp, rect);</p><p></p><p> BinaryReader reader = new BinaryReader(stream);</p><p> stream.Position = 0; // ensure that what start at the beginning of the stream.</p><p> reader.ReadBytes(14); // skip bitmap file info header</p><p> byte[] bmiInfoHeader = reader.ReadBytes(4 + 4 + 4 + 2 + 2 + 4 + 4 + 4 + 4 + 4 + 4);</p><p></p><p> int rgbL = (int)(stream.Length - stream.Position);</p><p> int rgb = (int)(rgbL / (AtmoLightObject.captureWidth * AtmoLightObject.captureHeight));</p><p></p><p> byte[] pixelData = reader.ReadBytes((int)(stream.Length - stream.Position));</p><p></p><p> byte[] h1pixelData = new byte[AtmoLightObject.captureWidth * rgb];</p><p> byte[] h2pixelData = new byte[AtmoLightObject.captureWidth * rgb];</p><p> //now flip horizontally, we do it always to prevent microstudder</p><p> int i;</p><p> for (i = 0; i < ((AtmoLightObject.captureHeight / 2) - 1); i++)</p><p> {</p><p> Array.Copy(pixelData, i * AtmoLightObject.captureWidth * rgb, h1pixelData, 0, AtmoLightObject.captureWidth * rgb);</p><p> Array.Copy(pixelData, (AtmoLightObject.captureHeight - i - 1) * AtmoLightObject.captureWidth * rgb, h2pixelData, 0, AtmoLightObject.captureWidth * rgb);</p><p> Array.Copy(h1pixelData, 0, pixelData, (AtmoLightObject.captureHeight - i - 1) * AtmoLightObject.captureWidth * rgb, AtmoLightObject.captureWidth * rgb);</p><p> Array.Copy(h2pixelData, 0, pixelData, i * AtmoLightObject.captureWidth * rgb, AtmoLightObject.captureWidth * rgb);</p><p> }</p><p></p><p> AtmoLightObject.SetPixelData(bmiInfoHeader, pixelData);</p><p></p><p> stream.Close();</p><p> stream.Dispose();</p><p></p><p> }</p><p> catch (Exception ex)</p><p> {</p><p> Log.Error("ex: {0}", ex.Message);</p><p> }</p><p> }</p><p> System.Threading.Thread.Sleep(10);</p><p> }[/CODE]</p><p></p><p>Lots of red squgily lines in vs for a long time, because directx surfaces are not the same as sharpdx surfaces blabla..., after trying to convert one to another for some time i found the ToStream method in sharpdx, which looked to be my savior. However my error seems to be even before that. Running this i get this exception:</p><p></p><p>[code][2014-04-23 03:08:20,811] [21474 ] [112 ] [ERROR] - AtmoLight: ex: Could not find the MediaPortal.UI.SkinEngine.Players.ISharpDXVideoPlayer service[/code]</p><p></p><p>its late, im tiered, if i make no sense or did obvious mistakes, please forgive me. Wanted to let this here as its still fresh and i still know what i actually did... <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite2" alt=";)" title="Wink ;)" loading="lazy" data-shortname=";)" />.</p><p>Maybe someone has an idea <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite2" alt=";)" title="Wink ;)" loading="lazy" data-shortname=";)" />.</p></blockquote><p></p>
[QUOTE="Lightning303, post: 1077272, member: 97876"] OK, after a lot of trial and error i came up with this. [CODE=C#] private SharpDX.Direct3D9.Surface rgbSurface; private void MyThread() { while (ServiceRegistration.Get<IPlayerContextManager>().IsVideoContextActive) { try { rgbSurface = ServiceRegistration.Get<ISharpDXVideoPlayer>().Surface; Rectangle rect = new Rectangle(0, 0, rgbSurface.Description.Width, rgbSurface.Description.Height); DataStream stream = SharpDX.Direct3D9.Surface.ToStream(rgbSurface, SharpDX.Direct3D9.ImageFileFormat.Bmp, rect); BinaryReader reader = new BinaryReader(stream); stream.Position = 0; // ensure that what start at the beginning of the stream. reader.ReadBytes(14); // skip bitmap file info header byte[] bmiInfoHeader = reader.ReadBytes(4 + 4 + 4 + 2 + 2 + 4 + 4 + 4 + 4 + 4 + 4); int rgbL = (int)(stream.Length - stream.Position); int rgb = (int)(rgbL / (AtmoLightObject.captureWidth * AtmoLightObject.captureHeight)); byte[] pixelData = reader.ReadBytes((int)(stream.Length - stream.Position)); byte[] h1pixelData = new byte[AtmoLightObject.captureWidth * rgb]; byte[] h2pixelData = new byte[AtmoLightObject.captureWidth * rgb]; //now flip horizontally, we do it always to prevent microstudder int i; for (i = 0; i < ((AtmoLightObject.captureHeight / 2) - 1); i++) { Array.Copy(pixelData, i * AtmoLightObject.captureWidth * rgb, h1pixelData, 0, AtmoLightObject.captureWidth * rgb); Array.Copy(pixelData, (AtmoLightObject.captureHeight - i - 1) * AtmoLightObject.captureWidth * rgb, h2pixelData, 0, AtmoLightObject.captureWidth * rgb); Array.Copy(h1pixelData, 0, pixelData, (AtmoLightObject.captureHeight - i - 1) * AtmoLightObject.captureWidth * rgb, AtmoLightObject.captureWidth * rgb); Array.Copy(h2pixelData, 0, pixelData, i * AtmoLightObject.captureWidth * rgb, AtmoLightObject.captureWidth * rgb); } AtmoLightObject.SetPixelData(bmiInfoHeader, pixelData); stream.Close(); stream.Dispose(); } catch (Exception ex) { Log.Error("ex: {0}", ex.Message); } } System.Threading.Thread.Sleep(10); }[/CODE] Lots of red squgily lines in vs for a long time, because directx surfaces are not the same as sharpdx surfaces blabla..., after trying to convert one to another for some time i found the ToStream method in sharpdx, which looked to be my savior. However my error seems to be even before that. Running this i get this exception: [code][2014-04-23 03:08:20,811] [21474 ] [112 ] [ERROR] - AtmoLight: ex: Could not find the MediaPortal.UI.SkinEngine.Players.ISharpDXVideoPlayer service[/code] its late, im tiered, if i make no sense or did obvious mistakes, please forgive me. Wanted to let this here as its still fresh and i still know what i actually did... ;). Maybe someone has an idea ;). [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 2
Plugin Development
AtmoLight 2.1.0.0 for MediaPortal2 [2015-01-21]
Contact us
RSS
Top
Bottom