StbImageSharpForUnity
Decodes an image and converts Texture2D on Unity with pure C#.
Install / Use
/learn @mochi-neko/StbImageSharpForUnityREADME
StbImageSharpForUnity
Provides an Unity extension of StbImageSharp.
Decodes a binary image file byte[] or Stream and converts to Texture2D on Unity with pure C# (without any native libraries).
How to import by UPM
Add
dependencies: {
"com.stbsharp.stbimagesharp": "https://github.com/mochi-neko/StbImageSharpForUnity.git?path=/Assets/StbImageSharp",
"com.mochineko.stbimagesharp-for-unity": "https://github.com/mochi-neko/StbImageSharpForUnity.git?path=/Assets/Mochineko/StbImageSharpForUnity",
}
to /Packages/manifest.json on your Unity project and add its reference to your Assembly Definition.
Also you can add a demo codes by adding
"com.mochineko.stbimagesharp-for-unity.demo": "https://github.com/mochi-neko/StbImageSharpForUnity.git?path=/Assets/Mochineko/StbImageSharpForUnity.Demo",
"com.cysharp.unitask": "https://github.com/Cysharp/UniTask.git?path=src/UniTask/Assets/Plugins/UniTask",
to your dependencies.
How to use
A sample usage with the UniTask is as follows:
private async UniTask<Texture2D> LoadImageAsync(byte[] data)
{
await UniTask.SwitchToThreadPool();
// Decodes an image on a thread pool.
var imageResult = ImageDecoder.DecodeImage(data);
await UniTask.SwitchToMainThread();
// Creates a texture and set the pixel data on the main thread.
return imageResult.ToTexture2D();
}
.
See also Demo.
For animated GIF images, see Animated GIF Demo.
Support Codecs
- JPG
- PNG
- BMP
- TGA
- PSD
- GIF
- (HDR)
See also StbImageSharp.
Support Platforms
All platforms supported by Unity are supported because StbImageSharp is written by pure C#.
See also StbImageSharp.
Changelog
See CHANGELOG.md.
Credits
See also NOTICE.md.
License
Related Skills
healthcheck
345.4kHost security hardening and risk-tolerance configuration for OpenClaw deployments
imsg
345.4kiMessage/SMS CLI for listing chats, history, and sending messages via Messages.app.
node-connect
345.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
xurl
345.4kA CLI tool for making authenticated requests to the X (Twitter) API. Use this skill when you need to post tweets, reply, quote, search, read posts, manage followers, send DMs, upload media, or interact with any X API v2 endpoint.
