ColorBuffer

Roman Shapiro edited this page Jul 8, 2018 · 7 revisions

ColorBuffer is utility class, allowing to load 32-bit RGBA images in JPG, PNG, BMP, TGA, PSD and GIF formats.

Unlike Texture2D.FromStream, which loads images to the video memory, ColorBuffer.FromStream loads them into the ordinary memory.

Also ColorBuffer provides basic preprocessing functionality.

I.e. following code loads a JPG image into memory, premultiplies alpha in it and finally creates Texture2D:

// Load image into memory
ColorBuffer colorBuffer;
using(var stream = File.OpenRead("image.jpg"))
{
  colorBuffer = ColorBuffer.FromStream(stream);
}
 
// Premultiply alpha
colorBuffer.Process(true);

// Create Texture2D
Texture2D texture = colorBuffer.CreateTexture2D();

ColorBuffer uses StbSharp internally.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.