protected override void LoadContent() { base.LoadContent(); if (content == null) { content = new ContentManager(Game.Services, "AnalyzerContent"); spriteBatch = new SpriteBatch(GraphicsDevice); font = content.Load<SpriteFont>("Font"); CreateTexture(); var presentationParams = GraphicsDevice.PresentationParameters; var width = presentationParams.BackBufferWidth; var height = presentationParams.BackBufferHeight; resolveTarget = new ResolveTexture2D(GraphicsDevice, width, height, 1, presentationParams.BackBufferFormat); LoadEffects(width, height); CreateVertices(width, height); ChangeView(0); } }
} // GetCurrentScreenshotNum() #endregion /// <summary> /// Make screenshot /// </summary> private void MakeScreenshot() { try { screenshotNum++; // Make sure screenshots directory exists if (Directory.Exists(Directories.ScreenshotsDirectory) == false) { Directory.CreateDirectory(Directories.ScreenshotsDirectory); } using (ResolveTexture2D dstTexture = new ResolveTexture2D( BaseGame.Device, BaseGame.Width, BaseGame.Height, 1, SurfaceFormat.Color)) { // Get data with help of the resolve method BaseGame.Device.ResolveBackBuffer(dstTexture); dstTexture.Save( ScreenshotNameBuilder(screenshotNum), ImageFileFormat.Jpg); } // using (dstTexture) } // try catch (Exception ex) { Log.Write("Failed to save Screenshot: " + ex.ToString()); } // catch (ex) } // MakeScreenshot()
protected override void LoadContent() { spriteBatch = new SpriteBatch(device); //Load the fx files extractEffect = Game.Content.Load <Effect>("BloomExtract"); combineEffect = Game.Content.Load <Effect>("BloomCombine"); gaussBlurEffect = Game.Content.Load <Effect>("GaussBlur"); // Look up the resolution and format of our main backbuffer. PresentationParameters pp = device.PresentationParameters; int width = pp.BackBufferWidth; int height = pp.BackBufferHeight; SurfaceFormat format = pp.BackBufferFormat; //Set how the bloom will behave setBloomSetting(0.25f, 4f, 2f, 1f, 2f, 0f); // Create a texture for reading back the backbuffer contents. resolveTarget = new ResolveTexture2D(device, width, height, 1, format); //Can make the backbuffers smaller to increase efficiency, makes bloom less pronounced /** * width /= 2; * height /= 2; *///for example renderTarget1 = new RenderTarget2D(device, width, height, 1, format); renderTarget2 = new RenderTarget2D(device, width, height, 1, format); }
public void ScreenChanged() { var oldScreenSize = ScreenSize; ScreenSize = Viewer.DisplaySize; // Buffer for screen texture, also same size as viewport and using the backbuffer format. if (Viewer.Settings.WindowGlass) { if (Screen != null) { Screen.Dispose(); } Screen = new ResolveTexture2D(Viewer.GraphicsDevice, ScreenSize.X, ScreenSize.Y, 1, Viewer.GraphicsDevice.PresentationParameters.BackBufferFormat); } // Reposition all the windows. foreach (var window in Windows) { if (oldScreenSize.X - window.Location.Width > 0 && oldScreenSize.Y - window.Location.Height > 0) { window.MoveTo((ScreenSize.X - window.Location.Width) * window.Location.X / (oldScreenSize.X - window.Location.Width), (ScreenSize.Y - window.Location.Height) * window.Location.Y / (oldScreenSize.Y - window.Location.Height)); } window.ScreenChanged(); } }
private void Screenshot() { if (takeScreenshot && (screenshotThread == null || screenshotThread.Join(0))) { resolveTexture = new ResolveTexture2D( graphics.GraphicsDevice, graphics.GraphicsDevice.PresentationParameters.BackBufferWidth, graphics.GraphicsDevice.PresentationParameters.BackBufferHeight, 1, graphics.GraphicsDevice.PresentationParameters.BackBufferFormat); GraphicsDevice.ResolveBackBuffer(resolveTexture); takeScreenshot = false; screenshotThread = new Thread(() => { string filename; filename = Window.Title + ".png"; resolveTexture.Save(filename, ImageFileFormat.Png); }); screenshotThread.Start(); } }
/// <summary> /// Load your graphics content. /// </summary> protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); bloomExtractEffect = Game.Content.Load <Effect>("BloomExtract"); bloomCombineEffect = Game.Content.Load <Effect>("BloomCombine"); gaussianBlurEffect = Game.Content.Load <Effect>("GaussianBlur"); // Look up the resolution and format of our main backbuffer. PresentationParameters pp = GraphicsDevice.PresentationParameters; int width = game.m_Width; int height = game.m_Height; SurfaceFormat format = pp.BackBufferFormat; // Create a texture for reading back the backbuffer contents. resolveTarget = new ResolveTexture2D(GraphicsDevice, width, height, 1, format); // Create two rendertargets for the bloom processing. These are half the // size of the backbuffer, in order to minimize fillrate costs. Reducing // the resolution in this way doesn't hurt quality, because we are going // to be blurring the bloom images in any case. width /= 2; height /= 2; renderTarget1 = new RenderTarget2D(GraphicsDevice, width, height, 1, format); renderTarget2 = new RenderTarget2D(GraphicsDevice, width, height, 1, format); }
protected override void LoadContent() { base.LoadContent(); spriteBatch = new SpriteBatch(GraphicsDevice); blurCombineEffect = Game.Content.Load <Effect>("Content\\Effects\\PostProcessing\\RadialBlurCombine"); radialBlurEffect = Game.Content.Load <Effect>("Content\\Effects\\PostProcessing\\RadialBlur"); PresentationParameters pp = game.Graphics.Device.PresentationParameters; int width = pp.BackBufferWidth; int height = pp.BackBufferHeight; SurfaceFormat format = pp.BackBufferFormat; // Create a texture for reading back the backbuffer contents. resolveTarget = new ResolveTexture2D(GraphicsDevice, width, height, 1, format); // Create two rendertargets for the bloom processing. These are half the // size of the backbuffer, in order to minimize fillrate costs. Reducing // the resolution in this way doesn't hurt quality, because we are going // to be blurring the bloom images in any case. width /= 2; height /= 2; renderTarget1 = new RenderTarget2D(GraphicsDevice, width, height, 1, format, GraphicsDevice.PresentationParameters.MultiSampleType, GraphicsDevice.PresentationParameters.MultiSampleQuality); renderTarget2 = new RenderTarget2D(GraphicsDevice, width, height, 1, format, GraphicsDevice.PresentationParameters.MultiSampleType, GraphicsDevice.PresentationParameters.MultiSampleQuality); }
private void Screenshot() { using (ResolveTexture2D screenshot = new ResolveTexture2D(graphics.GraphicsDevice, graphics.GraphicsDevice.PresentationParameters.BackBufferWidth, graphics.GraphicsDevice.PresentationParameters.BackBufferHeight, 1, SurfaceFormat.Color)) { GraphicsDevice.ResolveBackBuffer(screenshot); screenshot.Save("screenshot.jpg", ImageFileFormat.Jpg); } }
/// <summary> /// Get ScreenShoot Of Screen /// </summary> /// <returns>Return The ScreenShoot Texture</returns> public static Texture2D GetScreenTexture() { ResolveTexture2D text; text = new ResolveTexture2D(gd, gd.PresentationParameters.BackBufferWidth, gd.PresentationParameters.BackBufferHeight, 1, gd.PresentationParameters.BackBufferFormat); gd.ResolveBackBuffer(text); return(text); }
public XnaAviWriter(GraphicsDevice device) { _writer = new AviWriter(); _device = device; _texture = new ResolveTexture2D(_device, _device.PresentationParameters.BackBufferWidth, _device.PresentationParameters.BackBufferHeight, 1, SurfaceFormat.Color); _buffer = new Bitmap(_device.PresentationParameters.BackBufferWidth, _device.PresentationParameters.BackBufferHeight); _bmpd = new BitmapData(); }
/// <summary> /// Get ScreenShoot Of A Part Of The Screen /// </summary> /// <param name="source"></param> /// <returns>Return The ScreenShoot Texture</returns> public static Texture2D GetScreenTexture(Rectangle source) { ResolveTexture2D text; text = new ResolveTexture2D(gd, source.Width, source.Height, 1, gd.PresentationParameters.BackBufferFormat); gd.ResolveBackBuffer(text); return(text); }
public static Texture2D TakeScreenshot() { int w = Engine.Device.PresentationParameters.BackBufferWidth; int h = Engine.Device.PresentationParameters.BackBufferHeight; ResolveTexture2D screenshot = new ResolveTexture2D(Engine.Device, w, h, 1, Engine.Device.PresentationParameters.BackBufferFormat); Engine.Device.ResolveBackBuffer(screenshot); return(screenshot); }
/// <summary> /// Loads the appropriate effect /// </summary> /// <param name="content">Content manager needed to load the appropriate effect</param> /// <param name="filename">The name of the file containing the effect</param> public void LoadEffect(ContentManager content, string filename) { PresentationParameters pp = device.PresentationParameters; targetRenderedTo = new RenderTarget2D(device, pp.BackBufferWidth, pp.BackBufferHeight, 1, device.DisplayMode.Format); resolveTexture = new ResolveTexture2D(device, pp.BackBufferWidth, pp.BackBufferHeight, 1, device.DisplayMode.Format); ppEffect = content.Load <Effect>(filename); }
protected override void LoadContent() { device = graphics.GraphicsDevice; basicEffect = new BasicEffect(device, null); spriteBatch = new SpriteBatch(device); cCross = new CoordCross(device); PresentationParameters pp = device.PresentationParameters; resolveTexture = new ResolveTexture2D(device, pp.BackBufferWidth, pp.BackBufferHeight, 1, device.DisplayMode.Format); }
public static Texture2D RenderGraphicsDevice(GraphicsDevice graphicsDevice, Rectangle rect) { PresentationParameters pp = graphicsDevice.PresentationParameters; ResolveTexture2D resolveTexture = new ResolveTexture2D(graphicsDevice, pp.BackBufferWidth, pp.BackBufferHeight, 1, graphicsDevice.DisplayMode.Format); graphicsDevice.ResolveBackBuffer(resolveTexture); resolveTexture.Save("test.jpg", ImageFileFormat.Jpg); Texture2D returnTexture = (Texture2D)resolveTexture; return(returnTexture); }
protected override void LoadContent() { batch = new SpriteBatch(GraphicsDevice); font = content.Load <SpriteFont>("Fonts/Console"); texture = new ResolveTexture2D(GraphicsDevice, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, 1, GraphicsDevice.DisplayMode.Format); width = GraphicsDevice.Viewport.Width; height = GraphicsDevice.Viewport.Height / 2 - 100; base.LoadContent(); }
public PostProcessor(GraphicsDevice device, Effect ppEffect) { this.device = device; PresentationParameters pp = device.PresentationParameters; targetRenderedTo = new RenderTarget2D(device, pp.BackBufferWidth, pp.BackBufferHeight, 1, device.DisplayMode.Format); resolveTexture = new ResolveTexture2D(device, pp.BackBufferWidth, pp.BackBufferHeight, 1, device.DisplayMode.Format); this.ppEffect = ppEffect; spriteBatch = new SpriteBatch(device); InitPostProcessingVertices(); }
public void TakeScreenShot(string path) { this.spriteBatch.Begin(); for (int num = 0; num != this.listSprite.Count; num++) { this.listSprite[num].Draw(this.spriteBatch); } this.spriteBatch.End(); ResolveTexture2D resolveTexture2D = new ResolveTexture2D(base.GraphicsDevice, base.GraphicsDevice.PresentationParameters.BackBufferWidth, base.GraphicsDevice.PresentationParameters.BackBufferHeight, 1, SurfaceFormat.Color); base.GraphicsDevice.ResolveBackBuffer(resolveTexture2D); resolveTexture2D.Save(path, ImageFileFormat.Bmp); }
public Texture2D CreateImage(Texture2D image, int x, int y, int w, int h) { Rectangle srcRect = new Rectangle(x, y, w, h); byte[] data = new byte[srcRect.Width * srcRect.Height * 4]; image.GetData(0, srcRect, data, 0, data.Length); Texture2D result = new ResolveTexture2D( gdm.GraphicsDevice, srcRect.Width, srcRect.Height, 0, SurfaceFormat.Color); result.SetData(data); return(result); }
void OnDeviceReset(Object sender, EventArgs args) { Device.VertexDeclaration = new VertexDeclaration(Device, Vertex.VertexElements); Device.RenderState.AlphaTestEnable = true; Device.RenderState.AlphaFunction = CompareFunction.Greater; Device.RenderState.ReferenceAlpha = 0; m_renderer.OnDeviceReset(sender, args); if (m_screenshot == null || m_screenshot.IsDisposed == true || ScreenSize != new Point(m_screenshot.Width, m_screenshot.Height)) { m_screenshot = new ResolveTexture2D(Device, Device.PresentationParameters.BackBufferWidth, Device.PresentationParameters.BackBufferHeight, 1, Device.PresentationParameters.BackBufferFormat); } }
/// <summary> /// Take A ScreenShoot Of Current Screen /// </summary> /// <param name="path">Picture Path</param> /// <param name="format">Picture Format</param> /// <param name="graphicsDevice">XNA GraphicsDevice</param> public static void TakeScreen(string path, ImageFileFormat format, GraphicsDevice graphicsDevice) { try { ResolveTexture2D text; text = new ResolveTexture2D(graphicsDevice, graphicsDevice.PresentationParameters.BackBufferWidth, graphicsDevice.PresentationParameters.BackBufferHeight, 1, graphicsDevice.PresentationParameters.BackBufferFormat); graphicsDevice.ResolveBackBuffer(text); text.Save(path, format); } catch (System.Exception e) { throw e; } }
public Texture2D GetScreenContents() { CheckDisposed(); m_graphicsDevice.SetRenderTarget(0, null); ResolveTexture2D retValue = new ResolveTexture2D(m_graphicsDevice, m_renderTarget.Width, m_renderTarget.Height, 1, m_renderTarget.Format); m_graphicsDevice.ResolveBackBuffer(retValue); m_graphicsDevice.SetRenderTarget(0, m_renderTarget); m_graphicsDevice.Clear(Color.Black); return(retValue); }
public void LoadContent() { PresentationParameters pp = _graphicsDevice.PresentationParameters; SurfaceFormat surfaceFormat = pp.BackBufferFormat; int mipmapLevel = 1; int width = pp.BackBufferWidth; int height = pp.BackBufferHeight; _renderTargetA = new RenderTarget2D(_graphicsDevice, width, height, mipmapLevel, surfaceFormat); _renderTargetB = new RenderTarget2D(_graphicsDevice, width, height, mipmapLevel, surfaceFormat); _backbufferTexture = new ResolveTexture2D(_graphicsDevice, width, height, mipmapLevel, surfaceFormat); }
private void TakeScreenshot() { int count = Directory.GetFiles(StorageContainer.TitleLocation + "\\", "ndump*.bmp").Length + 1; string name = "\\ndump" + count.ToString("000") + ".bmp"; GraphicsDevice device = Engine.Device; using (ResolveTexture2D screenshot = new ResolveTexture2D(device, device.PresentationParameters.BackBufferWidth, device.PresentationParameters.BackBufferHeight, 1, SurfaceFormat.Color)) { device.ResolveBackBuffer(screenshot); screenshot.Save(StorageContainer.TitleLocation + name, ImageFileFormat.Bmp); } //MessageRenderer.Instance.PostHeaderMessage("Screenshot dumped to " + name, 3); }
protected override void LoadContent() { device = graphics.GraphicsDevice; basicEffect = new BasicEffect(device, null); cCross = new CoordCross(device); myModel = Content.Load <Model>("Ship"); modelTransforms = new Matrix[myModel.Bones.Count]; PresentationParameters pp = GraphicsDevice.PresentationParameters; targetRenderedTo = new RenderTarget2D(device, pp.BackBufferWidth, pp.BackBufferHeight, 1, device.DisplayMode.Format); resolveTexture = new ResolveTexture2D(device, pp.BackBufferWidth, pp.BackBufferHeight, 1, device.DisplayMode.Format); postProcessingEffect = Content.Load <Effect>("postprocessing"); }
private void UpDownIcon_ValueChanged(object sender, EventArgs e) { try { if (this.IconBmp != null) { this.IconBmp.Dispose(); } PresentationParameters presentationParameters = new PresentationParameters(); presentationParameters.AutoDepthStencilFormat = DepthFormat.Depth24; presentationParameters.BackBufferCount = 1; presentationParameters.BackBufferFormat = SurfaceFormat.Color; presentationParameters.BackBufferHeight = 39; presentationParameters.BackBufferWidth = 39; presentationParameters.EnableAutoDepthStencil = true; presentationParameters.FullScreenRefreshRateInHz = 0; presentationParameters.IsFullScreen = false; presentationParameters.MultiSampleQuality = 0; presentationParameters.MultiSampleType = MultiSampleType.NonMaskable; presentationParameters.PresentationInterval = PresentInterval.One; presentationParameters.PresentOptions = PresentOptions.None; presentationParameters.RenderTargetUsage = RenderTargetUsage.DiscardContents; presentationParameters.SwapEffect = SwapEffect.Discard; GraphicsDevice graphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, DeviceType.Hardware, new Panel().Handle, presentationParameters); this.copiedIcon = new Sprite(graphicsDevice); int index = Convert.ToInt32(this.numericUpDownIcon.Value) / 169; int index2 = Convert.ToInt32(this.numericUpDownIcon.Value) % 169; this.copiedIcon.LoadTextureFromFile(this.ImportedContentFolder + "\\3DDATA\\Control\\RES\\" + this.ImportedTSI.listDDS[index].Path, new Vector2(0f, 0f), new Microsoft.Xna.Framework.Rectangle(this.ImportedTSI.listDDS[index].ListDDS_element[index2].X, this.ImportedTSI.listDDS[index].ListDDS_element[index2].Y, this.ImportedTSI.listDDS[index].ListDDS_element[index2].Width, this.ImportedTSI.listDDS[index].ListDDS_element[index2].Height)); graphicsDevice.Clear(Microsoft.Xna.Framework.Graphics.Color.White); SpriteBatch spriteBatch = new SpriteBatch(graphicsDevice); spriteBatch.Begin(SpriteBlendMode.AlphaBlend); spriteBatch.Draw(this.copiedIcon.texture, new Vector2(0f, 0f), new Microsoft.Xna.Framework.Rectangle?(this.copiedIcon.sourceRectangle), Microsoft.Xna.Framework.Graphics.Color.White); spriteBatch.End(); using (ResolveTexture2D resolveTexture2D = new ResolveTexture2D(graphicsDevice, graphicsDevice.PresentationParameters.BackBufferWidth, graphicsDevice.PresentationParameters.BackBufferHeight, 1, SurfaceFormat.Color)) { graphicsDevice.ResolveBackBuffer(resolveTexture2D); resolveTexture2D.Save("Imported Icon.bmp", ImageFileFormat.Bmp); } this.pictureBox.ImageLocation = "Imported Icon.bmp"; this.IconBmp = new Bitmap("Imported Icon.bmp"); this.copiedIcon = new Sprite(this.textureControl.GraphicsDevice); this.copiedIcon.LoadTextureFromFile(this.ImportedContentFolder + "\\3DDATA\\Control\\RES\\" + this.ImportedTSI.listDDS[index].Path, new Vector2(0f, 0f), new Microsoft.Xna.Framework.Rectangle(this.ImportedTSI.listDDS[index].ListDDS_element[index2].X, this.ImportedTSI.listDDS[index].ListDDS_element[index2].Y, this.ImportedTSI.listDDS[index].ListDDS_element[index2].Width + 1, this.ImportedTSI.listDDS[index].ListDDS_element[index2].Height + 1)); } catch { } }
protected override void LoadGraphicsContent(bool loadAllContent) { if (loadAllContent) { batch = new SpriteBatch(GraphicsDevice); font = content.Load <SpriteFont>("Debug//Console"); } texture = new ResolveTexture2D(GraphicsDevice, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, 1, GraphicsDevice.DisplayMode.Format); //ResourceManagementMode.Manual); width = GraphicsDevice.Viewport.Width; height = GraphicsDevice.Viewport.Height / 2 - 100; base.LoadGraphicsContent(loadAllContent); }
private void MakeScreenshot() { try { //NOTE: This doesn't always work on all cards, especially if // desktop mode switches in fullscreen mode! screenshotNum++; // Make sure screenshots directory exists if (Directory.Exists(Directories.ScreenshotsDirectory) == false) { Directory.CreateDirectory(Directories.ScreenshotsDirectory); } // fix //using (Texture2D dstTexture = new Texture2D( // BaseGame.Device, // BaseGame.Width, BaseGame.Height, 1, // ResourceUsage.ResolveTarget, // SurfaceFormat.Color, // ResourceManagementMode.Manual)) using (ResolveTexture2D dstTexture = new ResolveTexture2D( BaseGame.Device, BaseGame.Width, BaseGame.Height, 1, SurfaceFormat.Color)) { // Get data with help of the resolve method BaseGame.Device.ResolveBackBuffer(dstTexture); dstTexture.Save( ScreenshotNameBuilder(screenshotNum), ImageFileFormat.Bmp); } } catch (Exception ex) { Log.Write("Failed to save Screenshot: " + ex.ToString()); } }
/// <summary> /// A collection of objects that represents inputted data in the form of a Line Graph /// </summary> /// <param name="values">Values to be inputted</param> public LineGraph(string XAxisTitle, string YAxisTitle, List <List <double> > values, List <string> lineLabels) { Manager.PauseRequest = true; while (!Manager.IsPaused) { System.Threading.Thread.Sleep(10); } resolveTarget = new ResolveTexture2D(MyGame.graphics.GraphicsDevice , MyGame.GameWindow.Width , MyGame.GameWindow.Height , 1 , MyGame.graphics.GraphicsDevice.DisplayMode.Format); this.XAxisTitle = XAxisTitle; this.YAxisTitle = YAxisTitle; this.lineLabels = lineLabels; Lines = Curve.CreateCurves(values, lineLabels); RefreshGraphAxes(); RefreshGraphImage(); Manager.PauseRequest = false; }
/// <summary> /// Initialize The Effect /// </summary> /// <param name="graphics">XNA Graphics Device Reference</param> /// <param name="sprite">XNA Sprite Batch Reference</param> public static void Initialize(GraphicsDeviceManager graphics, SpriteBatch sprite) { _sprite = sprite; scale = new Vector2(1); _graphics = graphics; lvl = 240; if (_graphics != null) { _graphics.PreparingDeviceSettings += new System.EventHandler <PreparingDeviceSettingsEventArgs>(_graphics_event_changing); _graphics.PreferMultiSampling = true; _graphics.ApplyChanges(); texture = new ResolveTexture2D(graphics.GraphicsDevice, _graphics.GraphicsDevice.PresentationParameters.BackBufferWidth, _graphics.GraphicsDevice.PresentationParameters.BackBufferHeight, 1, _graphics.GraphicsDevice.PresentationParameters.BackBufferFormat); _graphics.GraphicsDevice.Clear(Color.Black); _graphics.GraphicsDevice.ResolveBackBuffer(texture); } }