Beispiel #1
0
        public static void Load(string path, IRenderReceiver receiver)
        {
            using (var fileStream = new FileStream(path, FileMode.Open))
            {
                while (true)
                {
                    var buffer = new byte[4];

                    fileStream.Read(buffer, 0, 4);
                    var width = BitConverter.ToUInt32(buffer, 0);

                    if (width == 0)
                    {
                        break;
                    }

                    fileStream.Read(buffer, 0, 4);
                    var height = BitConverter.ToUInt32(buffer, 0);

                    buffer = new byte[3 * width * height];
                    fileStream.Read(buffer, 0, buffer.Length);

                    var bitmap = new WriteableBitmap((int)width, (int)height, 96, 96, PixelFormats.Rgb24, null);
                    var rect   = new Int32Rect(0, 0, (int)width, (int)height);
                    bitmap.WritePixels(rect, buffer, (int)width * 3, 0);
                    bitmap.Freeze();

                    receiver.FrameRendered(bitmap);
                }

                receiver.RenderingDone();
            }
        }
Beispiel #2
0
        public void Render(string script, IRenderReceiver receiver)
        {
            var bitmapDecoder = new BitmapDecoder(new RenderReceiverAdapter(receiver));
            var base64Decoder = new Base64Decoder(bitmapDecoder);
            var blockDecoder  = new BlockDecoder(base64Decoder);

            var process = new ExternalProcess()
            {
                ExecutablePath       = Configuration.RAYTRACER_PATH,
                CommandLineArguments = "-s -",
                Input = script,
                OnOutputDataReceived = blockDecoder.Consume,
                OnErrorDataReceived  = receiver.Message,
                OnExited             = receiver.RenderingDone
            };

            process.Start();
        }
 public TileEngineEditor(IRenderReceiver renderReceiver)
 {
     _renderReceiver = renderReceiver;
     LoadResources();
 }
Beispiel #4
0
 public RenderReceiverAdapter(IRenderReceiver receiver)
 {
     this.receiver = receiver;
 }
Beispiel #5
0
        public static void LoadInSeparateThread(string path, IRenderReceiver receiver)
        {
            var thread = new Thread(() => Load(path, receiver));

            thread.Start();
        }