public static WinformsModel FromImage(Body body, PlaneImageBrush brush, Size size) { #pragma warning disable 612,618 Image image = brush.Image; #pragma warning restore 612,618 if (!string.IsNullOrEmpty(brush.FilePath)) { image = Image.FromFile(brush.FilePath); } else if (!string.IsNullOrEmpty(brush.ResourceName)) { image = (Image)CVARC.Engine.KR.Properties.Resources.ResourceManager.GetObject(brush.ResourceName); } image.RotateFlip(brush.RotateFlipType); var m = new WinformsModel { Body = body, HasImage = true, Size = size, Image = image }; var newSizeBitmap = new Bitmap(size.Width, size.Height); System.Drawing.Graphics.FromImage(newSizeBitmap). DrawImage(m.Image, 0, 0, size.Width, size.Height); m.Image.Dispose(); m.Image = newSizeBitmap; return(m); }
public bool TestImageBrushEquality(PlaneImageBrush m1, PlaneImageBrush m2) { bool res = m1.Equals(m2); return(res); }
public void HardPerformanceTest() { SceneConfig.Framerate = 1000; for (int i = 0; i < 30; i++) { _rootBody.Add(new Core.Box { XSize = 10, YSize = 20, ZSize = 30, DefaultColor = Color.Yellow, Top = PlaneImageBrush.FromResource(() => Properties.Resources.untitled), Bottom = PlaneImageBrush.FromResource(() => Properties.Resources.untitled), Location = GetRandomFrame() }); _rootBody.Add(new Body { Model = Model.FromResource(() => Properties.Resources.totem), Location = GetRandomFrame() }); _rootBody.Add(new Cylinder { RTop = 20, RBottom = 30, Height = 10, DefaultColor = Color.Red, Location = GetRandomFrame() }); } CreateDrawer(); Thread.Sleep(TimeSpan.FromSeconds(20)); }
public void PlaneImageBrushTest() { var brush = PlaneImageBrush.FromResource(() => CVARC.Engine.KR.Properties.Resources.testtexture); Texture texture; var res = _converter.TryConvert(brush, out texture); try { CheckMaterial(DirectXBrushConverter.DefaultColor, res.MaterialD3D); Assert.NotNull(texture); } finally { texture.Dispose(); } _converter.TryConvert(new SolidColorBrush(), out texture); Assert.Null(texture); }
public virtual ExtendedMaterial Convert(PlaneImageBrush brush) { #pragma warning disable 612,618 Image image = brush.Image; #pragma warning restore 612,618 if (!string.IsNullOrEmpty(brush.FilePath)) { image = Image.FromFile(brush.FilePath); } else if (!string.IsNullOrEmpty(brush.ResourceName)) { image = (Image)Resources.ResourceManager.GetObject(brush.ResourceName); } if (image != null && brush.RotateFlipType != RotateFlipType.RotateNoneFlipNone) { image.RotateFlip(brush.RotateFlipType); } LastTextureResult = Texture.FromStream(_device, image.ToStream(ImageFormat.Jpeg)); ExtendedMaterial m = DefaultColor.GetDirectXMaterial(); return(m); }