public void ChangeImage(byte[] pixeldata, byte[] bmiInfoHeader) { if (!IsConnected() && !_priorityClearing) { return; } if (!_isSending) { _isSending = true; // Hyperion expects the bytestring to be the size of 3*width*height. // So 3 bytes per pixel, as in RGB. // Given pixeldata however is 4 bytes per pixel, as in RGBA. // So we need to remove the last byte per pixel. byte[] newpixeldata = new byte[coreObject.GetCaptureHeight() * coreObject.GetCaptureWidth() * 3]; int x = 0; int i = 0; while (i <= (newpixeldata.GetLength(0) - 2)) { newpixeldata[i] = pixeldata[i + x + 2]; newpixeldata[i + 1] = pixeldata[i + x + 1]; newpixeldata[i + 2] = pixeldata[i + x]; i += 3; x++; } ImageRequest imageRequest = ImageRequest.CreateBuilder() .SetImagedata(Google.ProtocolBuffers.ByteString.CopyFrom(newpixeldata)) .SetImageheight(coreObject.GetCaptureHeight()) .SetImagewidth(coreObject.GetCaptureWidth()) .SetPriority(coreObject.hyperionPriority) .SetDuration(-1) .Build(); HyperionRequest request = HyperionRequest.CreateBuilder() .SetCommand(HyperionRequest.Types.Command.IMAGE) .SetExtension(ImageRequest.ImageRequest_, imageRequest) .Build(); Thread t = new Thread(() => SendRequest(request)) { IsBackground = true }; t.Start(); } }
public void SendImageToServer(byte[] pixeldata, int width, int height) { var imageRequest = ImageRequest.CreateBuilder() .SetImagedata(ByteString.CopyFrom(pixeldata)) .SetImageheight(height) .SetImagewidth(width) .SetPriority(_priority) .SetDuration(_messageDuration) .Build(); var request = HyperionRequest.CreateBuilder() .SetCommand(HyperionRequest.Types.Command.IMAGE) .SetExtension(ImageRequest.ImageRequest_, imageRequest) .Build(); SendRequest(request); }
public void SendImageToServer(byte[] pixeldata) { try { var imageRequest = ImageRequest.CreateBuilder() .SetImagedata(ByteString.CopyFrom(pixeldata)) .SetImageheight(Form1.HyperionHeight) .SetImagewidth(Form1.HyperionWidth) .SetPriority(_hyperionPriority) .SetDuration(Form1.HyperionMessageDuration) .Build(); var request = HyperionRequest.CreateBuilder() .SetCommand(HyperionRequest.Types.Command.IMAGE) .SetExtension(ImageRequest.ImageRequest_, imageRequest) .Build(); SendRequest(request); } catch (Exception) { } }
public static void SendImageToServer(byte[] pixeldata) { try { var imageRequest = ImageRequest.CreateBuilder() .SetImagedata(ByteString.CopyFrom(pixeldata)) .SetImageheight(Settings.HyperionHeight) .SetImagewidth(Settings.HyperionWidth) .SetPriority(_hyperionPriority) .SetDuration(Settings.HyperionMessageDuration) .Build(); var request = HyperionRequest.CreateBuilder() .SetCommand(HyperionRequest.Types.Command.IMAGE) .SetExtension(ImageRequest.ImageRequest_, imageRequest) .Build(); SendRequest(request); } catch (Exception ex) { Notifications.Error($"Failed to send image to server.{ex.Message}"); } }