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

◆ SaveImage() [1/2]

bool Terraria.Graphics.Capture.CaptureCamera.SaveImage ( int width,
int height,
ImageFormat imageFormat,
string filename )
inlineprivate

Definition at line 250 of file CaptureCamera.cs.

251 {
252 if (!Utils.TryCreatingDirectory(Main.SavePath + Path.DirectorySeparatorChar + "Captures" + Path.DirectorySeparatorChar))
253 {
254 return false;
255 }
256 try
257 {
258 if (!Platform.IsWindows)
259 {
261 PlatformUtilities.SavePng(stream, width, height, width, height, _outputData);
262 }
263 else
264 {
265 using Bitmap bitmap = new Bitmap(width, height);
266 System.Drawing.Rectangle rect = new System.Drawing.Rectangle(0, 0, width, height);
267 BitmapData bitmapData = bitmap.LockBits(rect, ImageLockMode.WriteOnly, PixelFormat.Format32bppPArgb);
268 IntPtr scan = bitmapData.Scan0;
269 Marshal.Copy(_outputData, 0, scan, width * height * 4);
270 bitmap.UnlockBits(bitmapData);
272 bitmap.Dispose();
273 }
274 return true;
275 }
276 catch (Exception value)
277 {
279 return false;
280 }
281 }
static bool IsWindows
Definition Platform.cs:19
static void WriteLine()
Definition Console.cs:733
static FileStream Create(string path)
Definition File.cs:73
static readonly char DirectorySeparatorChar
Definition Path.cs:71
static void Copy(int[] source, int startIndex, IntPtr destination, int length)
Definition Marshal.cs:800
static void SavePng(Stream stream, int width, int height, int imgWidth, int imgHeight, byte[] data)

References Terraria.Graphics.Capture.CaptureCamera._outputData, System.Runtime.InteropServices.Marshal.Copy(), System.IO.File.Create(), System.IO.Path.DirectorySeparatorChar, ReLogic.OS.Platform.IsWindows, Terraria.Main.SavePath, Terraria.Utilities.PlatformUtilities.SavePng(), System.stream, Terraria.Utils.TryCreatingDirectory(), System.value, and System.Console.WriteLine().

Referenced by Terraria.Graphics.Capture.CaptureCamera.DrawTick(), and Terraria.Graphics.Capture.CaptureCamera.FinishCapture().