mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-05-31 11:44:47 +00:00
SkinRenderer - Add GetThumbnail function
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user