Git Product home page Git Product logo

stbimagesharpforunity's Introduction

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",

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 GIF images, see 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

MIT License

stbimagesharpforunity's People

Contributors

ayutaz avatar mochi-neko avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.