Files
sbox-public/engine/Sandbox.Engine/Resources/Textures/Bitmap/Bitmap.Texture.cs
s&box team 71f266059a Open source release
This commit imports the C# engine code and game files, excluding C++ source code.

[Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
2025-11-24 09:05:18 +00:00

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();
}
}