mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-01-23 05:39:39 -05:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
24 lines
524 B
C#
24 lines
524 B
C#
namespace Sandbox;
|
|
|
|
public partial class Bitmap
|
|
{
|
|
ImageFormat ImageFormat => IsFloatingPoint ? ImageFormat.RGBA16161616F : ImageFormat.RGBA8888;
|
|
|
|
/// <summary>
|
|
/// Try to create a texture from this bitmap
|
|
/// </summary>
|
|
public Texture ToTexture( bool mips = true )
|
|
{
|
|
var builder = Texture.Create( Width, Height )
|
|
.WithFormat( ImageFormat )
|
|
.WithData( _bitmap.GetPixels(), _bitmap.BytesPerPixel * Width * Height );
|
|
|
|
if ( mips )
|
|
{
|
|
builder = builder.WithMips();
|
|
}
|
|
|
|
return builder.Finish();
|
|
}
|
|
}
|