Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ Capture()

void Terraria.Graphics.Capture.CaptureCamera.Capture ( CaptureSettings settings)
inline

Definition at line 106 of file CaptureCamera.cs.

107 {
108 Main.GlobalTimerPaused = true;
110 if (_activeSettings != null)
111 {
112 throw new InvalidOperationException("Capture called while another capture was already active.");
113 }
114 _activeSettings = settings;
116 float num = 1f;
117 if (settings.UseScaling)
118 {
119 if (area.Width * 16 > 4096)
120 {
121 num = 4096f / (float)(area.Width * 16);
122 }
123 if (area.Height * 16 > 4096)
124 {
125 num = Math.Min(num, 4096f / (float)(area.Height * 16));
126 }
127 num = Math.Min(1f, num);
128 _outputImageSize = new Size((int)MathHelper.Clamp((int)(num * (float)(area.Width * 16)), 1f, 4096f), (int)MathHelper.Clamp((int)(num * (float)(area.Height * 16)), 1f, 4096f));
129 _outputData = new byte[4 * _outputImageSize.Width * _outputImageSize.Height];
130 int num2 = (int)Math.Floor(num * 2048f);
131 _scaledFrameData = new byte[4 * num2 * num2];
133 }
134 else
135 {
136 _outputData = new byte[16777216];
137 }
138 _tilesProcessed = 0f;
139 _totalTiles = area.Width * area.Height;
140 for (int i = area.X; i < area.X + area.Width; i += 126)
141 {
142 for (int j = area.Y; j < area.Y + area.Height; j += 126)
143 {
144 int num3 = Math.Min(128, area.X + area.Width - i);
145 int num4 = Math.Min(128, area.Y + area.Height - j);
146 int width = (int)Math.Floor(num * (float)(num3 * 16));
147 int height = (int)Math.Floor(num * (float)(num4 * 16));
148 int x = (int)Math.Floor(num * (float)((i - area.X) * 16));
149 int y = (int)Math.Floor(num * (float)((j - area.Y) * 16));
150 _renderQueue.Enqueue(new CaptureChunk(new Microsoft.Xna.Framework.Rectangle(i, j, num3, num4), new Microsoft.Xna.Framework.Rectangle(x, y, width, height)));
151 }
152 }
154 }
static float Clamp(float value, float min, float max)
Definition MathHelper.cs:46
static byte Min(byte val1, byte val2)
Definition Math.cs:912
static double Floor(double d)
static void Exit(object obj)
static void Enter(object obj)

References Terraria.Graphics.Capture.CaptureCamera._activeSettings, Terraria.Graphics.Capture.CaptureCamera._captureLock, Terraria.Graphics.Capture.CaptureCamera._graphics, Terraria.Graphics.Capture.CaptureCamera._outputData, Terraria.Graphics.Capture.CaptureCamera._outputImageSize, Terraria.Graphics.Capture.CaptureCamera._renderQueue, Terraria.Graphics.Capture.CaptureCamera._scaledFrameBuffer, Terraria.Graphics.Capture.CaptureCamera._scaledFrameData, Terraria.Graphics.Capture.CaptureCamera._tilesProcessed, Terraria.Graphics.Capture.CaptureCamera._totalTiles, Terraria.Graphics.Capture.CaptureSettings.Area, Microsoft.Xna.Framework.Graphics.PresentationParameters.BackBufferFormat, Microsoft.Xna.Framework.MathHelper.Clamp(), System.Threading.Monitor.Enter(), System.Threading.Monitor.Exit(), System.Math.Floor(), System.Drawing.Size.Height, System.Math.Min(), Microsoft.Xna.Framework.Graphics.GraphicsDevice.PresentationParameters, System.IO.Size, and Terraria.Graphics.Capture.CaptureSettings.UseScaling.

Referenced by Terraria.Graphics.Capture.CaptureManager.Capture().