SkinRenderer - Add GetThumbnail function

This commit is contained in:
miku-666
2024-01-20 17:07:47 +01:00
parent b98222e00a
commit d98b7341e8
2 changed files with 20 additions and 4 deletions

View File

@@ -229,16 +229,14 @@ namespace PckStudio.Forms
}
}
// Creates Model Data and Finalizes
private void buttonDone_Click(object sender, EventArgs e)
{
foreach (var part in renderer3D1.ModelData)
{
_file.Properties.Add("BOX", part);
}
var img = new Bitmap(renderer3D1.Size.Width, renderer3D1.Size.Height);
renderer3D1.DrawToBitmap(img, renderer3D1.Bounds);
_previewImage = img;
_previewImage = renderer3D1.GetThumbnail();
DialogResult = DialogResult.OK;
}

View File

@@ -30,6 +30,7 @@ using PckStudio.Properties;
using PckStudio.Forms.Editor;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Drawing.Imaging;
namespace PckStudio.Rendering
{
@@ -591,5 +592,22 @@ namespace PckStudio.Rendering
OnANIMUpdate();
Refresh();
}
/// <summary>
/// Captures the currently displayed frame
/// </summary>
/// <returns>Thumbnail of the cameras current view space</returns>
public Image GetThumbnail()
{
Bitmap bmp = new Bitmap(Width, Height);
BitmapData data = bmp.LockBits(ClientRectangle, ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
MakeCurrent();
GL.Finish();
GL.ReadPixels(0, 0, Width, Height, OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, data.Scan0);
bmp.UnlockBits(data);
bmp.RotateFlip(RotateFlipType.RotateNoneFlipY);
return bmp;
}
}
}