Joker !How often does the Atmolight plug-in request a frame grab ? Is it calling it from within MP's main render thread (not good), or from a separate thread ?
void AtmolightPlugin_OnNewFrame(short width, short height, short arWidth, short arHeight, uint pSurface)
{
if (currentEffect != ContentEffect.MP_Live_view)
return;
if (width == 0 || height == 0)
return;
if (rgbSurface==null)
rgbSurface = GUIGraphicsContext.DX9Device.CreateRenderTarget(captureWidth,captureHeight, Format.A8R8G8B8,MultiSampleType.None, 0, true);
unsafe
{
try
{
VideoSurfaceToRGBSurfaceExt(new IntPtr(pSurface), width, height, (IntPtr)rgbSurface.UnmanagedComPointer, captureWidth, captureHeight);
Microsoft.DirectX.GraphicsStream stream = SurfaceLoader.SaveToStream(ImageFileFormat.Bmp, rgbSurface);
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);
byte[] pixelData = reader.ReadBytes((int)(stream.Length - stream.Position));
atmoLiveViewCtrl.setPixelData(bmiInfoHeader, pixelData);
stream.Close();
stream.Dispose();
}
catch (Exception ex)
{
Log.Error(ex);
rgbSurface.Dispose();
rgbSurface = null;
}
}
}
Can someone expalin what the new code does (I'm not a C# programmer) ?
Presumably 'OnNewFrame' only exists if something else i.e. the Atomlight plug-in creates it, so it's null by default ?
How often does the Atmolight plug-in request a frame grab ? Is it calling it from within MP's main render thread (not good), or from a separate thread ?