Path: blob/master/thirdparty/msdfgen/core/BitmapRef.hpp
9903 views
1#pragma once23#include "base.h"45namespace msdfgen {67/// Reference to a 2D image bitmap or a buffer acting as one. Pixel storage not owned or managed by the object.8template <typename T, int N = 1>9struct BitmapRef {1011T *pixels;12int width, height;1314inline BitmapRef() : pixels(NULL), width(0), height(0) { }15inline BitmapRef(T *pixels, int width, int height) : pixels(pixels), width(width), height(height) { }1617inline T *operator()(int x, int y) const {18return pixels+N*(width*y+x);19}2021};2223/// Constant reference to a 2D image bitmap or a buffer acting as one. Pixel storage not owned or managed by the object.24template <typename T, int N = 1>25struct BitmapConstRef {2627const T *pixels;28int width, height;2930inline BitmapConstRef() : pixels(NULL), width(0), height(0) { }31inline BitmapConstRef(const T *pixels, int width, int height) : pixels(pixels), width(width), height(height) { }32inline BitmapConstRef(const BitmapRef<T, N> &orig) : pixels(orig.pixels), width(orig.width), height(orig.height) { }3334inline const T *operator()(int x, int y) const {35return pixels+N*(width*y+x);36}3738};3940}414243