diff options
author | 2016-10-22 13:13:17 +0200 | |
---|---|---|
committer | 2016-10-22 13:13:17 +0200 | |
commit | ddb290d5f615019c33c42b8d94e5a5254cabcf33 (patch) | |
tree | a70f688b0df3acd19da7b1151e5902e3c6af3fa5 /src/lib/util/bitmap.h | |
parent | 333bff8de64dfaeb98134000412796b4fdef970b (diff) |
NOTICE (TYPE NAME CONSOLIDATION)
Use standard uint64_t, uint32_t, uint16_t or uint8_t instead of UINT64, UINT32, UINT16 or UINT8
also use standard int64_t, int32_t, int16_t or int8_t instead of INT64, INT32, INT16 or INT8
Diffstat (limited to 'src/lib/util/bitmap.h')
-rw-r--r-- | src/lib/util/bitmap.h | 150 |
1 files changed, 75 insertions, 75 deletions
diff --git a/src/lib/util/bitmap.h b/src/lib/util/bitmap.h index 23d05af90df..7d367bcb5cb 100644 --- a/src/lib/util/bitmap.h +++ b/src/lib/util/bitmap.h @@ -45,14 +45,14 @@ public: // construction/destruction rectangle() : min_x(0), max_x(0), min_y(0), max_y(0) { } - rectangle(INT32 minx, INT32 maxx, INT32 miny, INT32 maxy) + rectangle(int32_t minx, int32_t maxx, int32_t miny, int32_t maxy) : min_x(minx), max_x(maxx), min_y(miny), max_y(maxy) { } // getters - INT32 left() const { return min_x; } - INT32 right() const { return max_x; } - INT32 top() const { return min_y; } - INT32 bottom() const { return max_y; } + int32_t left() const { return min_x; } + int32_t right() const { return max_x; } + int32_t top() const { return min_y; } + int32_t bottom() const { return max_y; } // compute intersection with another rect rectangle &operator&=(const rectangle &src) @@ -84,32 +84,32 @@ public: // other helpers bool empty() const { return (min_x > max_x || min_y > max_y); } - bool contains(INT32 x, INT32 y) const { return (x >= min_x && x <= max_x && y >= min_y && y <= max_y); } + bool contains(int32_t x, int32_t y) const { return (x >= min_x && x <= max_x && y >= min_y && y <= max_y); } bool contains(const rectangle &rect) const { return (min_x <= rect.min_x && max_x >= rect.max_x && min_y <= rect.min_y && max_y >= rect.max_y); } - INT32 width() const { return max_x + 1 - min_x; } - INT32 height() const { return max_y + 1 - min_y; } - INT32 xcenter() const { return (min_x + max_x + 1) / 2; } - INT32 ycenter() const { return (min_y + max_y + 1) / 2; } + int32_t width() const { return max_x + 1 - min_x; } + int32_t height() const { return max_y + 1 - min_y; } + int32_t xcenter() const { return (min_x + max_x + 1) / 2; } + int32_t ycenter() const { return (min_y + max_y + 1) / 2; } // setters - void set(INT32 minx, INT32 maxx, INT32 miny, INT32 maxy) { min_x = minx; max_x = maxx; min_y = miny; max_y = maxy; } - void setx(INT32 minx, INT32 maxx) { min_x = minx; max_x = maxx; } - void sety(INT32 miny, INT32 maxy) { min_y = miny; max_y = maxy; } - void set_width(INT32 width) { max_x = min_x + width - 1; } - void set_height(INT32 height) { max_y = min_y + height - 1; } - void set_origin(INT32 x, INT32 y) { max_x += x - min_x; max_y += y - min_y; min_x = x; min_y = y; } - void set_size(INT32 width, INT32 height) { set_width(width); set_height(height); } + void set(int32_t minx, int32_t maxx, int32_t miny, int32_t maxy) { min_x = minx; max_x = maxx; min_y = miny; max_y = maxy; } + void setx(int32_t minx, int32_t maxx) { min_x = minx; max_x = maxx; } + void sety(int32_t miny, int32_t maxy) { min_y = miny; max_y = maxy; } + void set_width(int32_t width) { max_x = min_x + width - 1; } + void set_height(int32_t height) { max_y = min_y + height - 1; } + void set_origin(int32_t x, int32_t y) { max_x += x - min_x; max_y += y - min_y; min_x = x; min_y = y; } + void set_size(int32_t width, int32_t height) { set_width(width); set_height(height); } // offset helpers - void offset(INT32 xdelta, INT32 ydelta) { min_x += xdelta; max_x += xdelta; min_y += ydelta; max_y += ydelta; } - void offsetx(INT32 delta) { min_x += delta; max_x += delta; } - void offsety(INT32 delta) { min_y += delta; max_y += delta; } + void offset(int32_t xdelta, int32_t ydelta) { min_x += xdelta; max_x += xdelta; min_y += ydelta; max_y += ydelta; } + void offsetx(int32_t delta) { min_x += delta; max_x += delta; } + void offsety(int32_t delta) { min_y += delta; max_y += delta; } // internal state - INT32 min_x; // minimum X, or left coordinate - INT32 max_x; // maximum X, or right coordinate (inclusive) - INT32 min_y; // minimum Y, or top coordinate - INT32 max_y; // maximum Y, or bottom coordinate (inclusive) + int32_t min_x; // minimum X, or left coordinate + int32_t max_x; // maximum X, or right coordinate (inclusive) + int32_t min_y; // minimum Y, or top coordinate + int32_t max_y; // maximum Y, or bottom coordinate (inclusive) }; @@ -135,11 +135,11 @@ public: void reset(); // getters - INT32 width() const { return m_width; } - INT32 height() const { return m_height; } - INT32 rowpixels() const { return m_rowpixels; } - INT32 rowbytes() const { return m_rowpixels * m_bpp / 8; } - UINT8 bpp() const { return m_bpp; } + int32_t width() const { return m_width; } + int32_t height() const { return m_height; } + int32_t rowpixels() const { return m_rowpixels; } + int32_t rowbytes() const { return m_rowpixels * m_bpp / 8; } + uint8_t bpp() const { return m_bpp; } bitmap_format format() const { return m_format; } bool valid() const { return (m_base != nullptr); } palette_t *palette() const { return m_palette; } @@ -151,9 +151,9 @@ public: // operations void set_palette(palette_t *palette); - void fill(UINT32 color) { fill(color, m_cliprect); } - void fill(UINT32 color, const rectangle &cliprect); - void plot_box(int x, int y, int width, int height, UINT32 color) + void fill(uint32_t color) { fill(color, m_cliprect); } + void fill(uint32_t color, const rectangle &cliprect); + void plot_box(int x, int y, int width, int height, uint32_t color) { rectangle clip(x, x + width - 1, y, y + height - 1); fill(color, clip); @@ -161,8 +161,8 @@ public: // pixel access template<typename _PixelType> - _PixelType &pixt(INT32 y, INT32 x = 0) const { return *(reinterpret_cast<_PixelType *>(m_base) + y * m_rowpixels + x); } - void *raw_pixptr(INT32 y, INT32 x = 0) const { return reinterpret_cast<UINT8 *>(m_base) + (y * m_rowpixels + x) * m_bpp / 8; } + _PixelType &pixt(int32_t y, int32_t x = 0) const { return *(reinterpret_cast<_PixelType *>(m_base) + y * m_rowpixels + x); } + void *raw_pixptr(int32_t y, int32_t x = 0) const { return reinterpret_cast<uint8_t *>(m_base) + (y * m_rowpixels + x) * m_bpp / 8; } protected: // for use by subclasses only to ensure type correctness @@ -171,18 +171,18 @@ protected: private: // internal helpers - INT32 compute_rowpixels(int width, int xslop); + int32_t compute_rowpixels(int width, int xslop); void compute_base(int xslop, int yslop); // internal state - UINT8 * m_alloc; // pointer to allocated pixel memory - UINT32 m_allocbytes; // size of our allocation + uint8_t * m_alloc; // pointer to allocated pixel memory + uint32_t m_allocbytes; // size of our allocation void * m_base; // pointer to pixel (0,0) (adjusted for padding) - INT32 m_rowpixels; // pixels per row (including padding) - INT32 m_width; // width of the bitmap - INT32 m_height; // height of the bitmap + int32_t m_rowpixels; // pixels per row (including padding) + int32_t m_width; // width of the bitmap + int32_t m_height; // height of the bitmap bitmap_format m_format; // format of the bitmap - UINT8 m_bpp; // bits per pixel + uint8_t m_bpp; // bits per pixel palette_t * m_palette; // optional palette rectangle m_cliprect; // a clipping rectangle covering the full bitmap }; @@ -200,17 +200,17 @@ private: protected: // construction/destruction -- subclasses only bitmap8_t(bitmap_format format, int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap_t(format, 8, width, height, xslop, yslop) { } - bitmap8_t(bitmap_format format, UINT8 *base, int width, int height, int rowpixels) : bitmap_t(format, 8, base, width, height, rowpixels) { assert(valid_format(format)); } + bitmap8_t(bitmap_format format, uint8_t *base, int width, int height, int rowpixels) : bitmap_t(format, 8, base, width, height, rowpixels) { assert(valid_format(format)); } bitmap8_t(bitmap_format format, bitmap8_t &source, const rectangle &subrect) : bitmap_t(format, 8, source, subrect) { } public: // getters - UINT8 bpp() const { return 8; } + uint8_t bpp() const { return 8; } // pixel accessors - typedef UINT8 pixel_t; - pixel_t &pix(INT32 y, INT32 x = 0) const { return pixt<pixel_t>(y, x); } - pixel_t &pix8(INT32 y, INT32 x = 0) const { return pixt<pixel_t>(y, x); } + typedef uint8_t pixel_t; + pixel_t &pix(int32_t y, int32_t x = 0) const { return pixt<pixel_t>(y, x); } + pixel_t &pix8(int32_t y, int32_t x = 0) const { return pixt<pixel_t>(y, x); } }; // 16bpp bitmaps @@ -223,17 +223,17 @@ private: protected: // construction/destruction -- subclasses only bitmap16_t(bitmap_format format, int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap_t(format, 16, width, height, xslop, yslop) { assert(valid_format(format)); } - bitmap16_t(bitmap_format format, UINT16 *base, int width, int height, int rowpixels) : bitmap_t(format, 16, base, width, height, rowpixels) { assert(valid_format(format)); } + bitmap16_t(bitmap_format format, uint16_t *base, int width, int height, int rowpixels) : bitmap_t(format, 16, base, width, height, rowpixels) { assert(valid_format(format)); } bitmap16_t(bitmap_format format, bitmap16_t &source, const rectangle &subrect) : bitmap_t(format, 16, source, subrect) { } public: // getters - UINT8 bpp() const { return 16; } + uint8_t bpp() const { return 16; } // pixel accessors - typedef UINT16 pixel_t; - pixel_t &pix(INT32 y, INT32 x = 0) const { return pixt<pixel_t>(y, x); } - pixel_t &pix16(INT32 y, INT32 x = 0) const { return pixt<pixel_t>(y, x); } + typedef uint16_t pixel_t; + pixel_t &pix(int32_t y, int32_t x = 0) const { return pixt<pixel_t>(y, x); } + pixel_t &pix16(int32_t y, int32_t x = 0) const { return pixt<pixel_t>(y, x); } }; // 32bpp bitmaps @@ -246,17 +246,17 @@ private: protected: // construction/destruction -- subclasses only bitmap32_t(bitmap_format format, int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap_t(format, 32, width, height, xslop, yslop) { assert(valid_format(format)); } - bitmap32_t(bitmap_format format, UINT32 *base, int width, int height, int rowpixels) : bitmap_t(format, 32, base, width, height, rowpixels) { assert(valid_format(format)); } + bitmap32_t(bitmap_format format, uint32_t *base, int width, int height, int rowpixels) : bitmap_t(format, 32, base, width, height, rowpixels) { assert(valid_format(format)); } bitmap32_t(bitmap_format format, bitmap32_t &source, const rectangle &subrect) : bitmap_t(format, 32, source, subrect) { } public: // getters - UINT8 bpp() const { return 32; } + uint8_t bpp() const { return 32; } // pixel accessors - typedef UINT32 pixel_t; - pixel_t &pix(INT32 y, INT32 x = 0) const { return pixt<pixel_t>(y, x); } - pixel_t &pix32(INT32 y, INT32 x = 0) const { return pixt<pixel_t>(y, x); } + typedef uint32_t pixel_t; + pixel_t &pix(int32_t y, int32_t x = 0) const { return pixt<pixel_t>(y, x); } + pixel_t &pix32(int32_t y, int32_t x = 0) const { return pixt<pixel_t>(y, x); } }; // 64bpp bitmaps @@ -269,17 +269,17 @@ private: protected: // construction/destruction -- subclasses only bitmap64_t(bitmap_format format, int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap_t(format, 64, width, height, xslop, yslop) { assert(valid_format(format)); } - bitmap64_t(bitmap_format format, UINT64 *base, int width, int height, int rowpixels) : bitmap_t(format, 64, base, width, height, rowpixels) { assert(valid_format(format)); } + bitmap64_t(bitmap_format format, uint64_t *base, int width, int height, int rowpixels) : bitmap_t(format, 64, base, width, height, rowpixels) { assert(valid_format(format)); } bitmap64_t(bitmap_format format, bitmap64_t &source, const rectangle &subrect) : bitmap_t(format, 64, source, subrect) { } public: // getters - UINT8 bpp() const { return 64; } + uint8_t bpp() const { return 64; } // pixel accessors - typedef UINT64 pixel_t; - pixel_t &pix(INT32 y, INT32 x = 0) const { return pixt<pixel_t>(y, x); } - pixel_t &pix64(INT32 y, INT32 x = 0) const { return pixt<pixel_t>(y, x); } + typedef uint64_t pixel_t; + pixel_t &pix(int32_t y, int32_t x = 0) const { return pixt<pixel_t>(y, x); } + pixel_t &pix64(int32_t y, int32_t x = 0) const { return pixt<pixel_t>(y, x); } }; @@ -293,9 +293,9 @@ class bitmap_ind8 : public bitmap8_t public: // construction/destruction bitmap_ind8(int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap8_t(k_bitmap_format, width, height, xslop, yslop) { } - bitmap_ind8(UINT8 *base, int width, int height, int rowpixels) : bitmap8_t(k_bitmap_format, base, width, height, rowpixels) { } + bitmap_ind8(uint8_t *base, int width, int height, int rowpixels) : bitmap8_t(k_bitmap_format, base, width, height, rowpixels) { } bitmap_ind8(bitmap_ind8 &source, const rectangle &subrect) : bitmap8_t(k_bitmap_format, source, subrect) { } - void wrap(UINT8 *base, int width, int height, int rowpixels) { bitmap_t::wrap(base, width, height, rowpixels); } + void wrap(uint8_t *base, int width, int height, int rowpixels) { bitmap_t::wrap(base, width, height, rowpixels); } void wrap(const bitmap_ind8 &source, const rectangle &subrect) { bitmap_t::wrap(static_cast<const bitmap_t &>(source), subrect); } // getters @@ -310,9 +310,9 @@ class bitmap_ind16 : public bitmap16_t public: // construction/destruction bitmap_ind16(int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap16_t(k_bitmap_format, width, height, xslop, yslop) { } - bitmap_ind16(UINT16 *base, int width, int height, int rowpixels) : bitmap16_t(k_bitmap_format, base, width, height, rowpixels) { } + bitmap_ind16(uint16_t *base, int width, int height, int rowpixels) : bitmap16_t(k_bitmap_format, base, width, height, rowpixels) { } bitmap_ind16(bitmap_ind16 &source, const rectangle &subrect) : bitmap16_t(k_bitmap_format, source, subrect) { } - void wrap(UINT16 *base, int width, int height, int rowpixels) { bitmap_t::wrap(base, width, height, rowpixels); } + void wrap(uint16_t *base, int width, int height, int rowpixels) { bitmap_t::wrap(base, width, height, rowpixels); } void wrap(const bitmap_ind8 &source, const rectangle &subrect) { bitmap_t::wrap(static_cast<const bitmap_t &>(source), subrect); } // getters @@ -327,9 +327,9 @@ class bitmap_ind32 : public bitmap32_t public: // construction/destruction bitmap_ind32(int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap32_t(k_bitmap_format, width, height, xslop, yslop) { } - bitmap_ind32(UINT32 *base, int width, int height, int rowpixels) : bitmap32_t(k_bitmap_format, base, width, height, rowpixels) { } + bitmap_ind32(uint32_t *base, int width, int height, int rowpixels) : bitmap32_t(k_bitmap_format, base, width, height, rowpixels) { } bitmap_ind32(bitmap_ind32 &source, const rectangle &subrect) : bitmap32_t(k_bitmap_format, source, subrect) { } - void wrap(UINT32 *base, int width, int height, int rowpixels) { bitmap_t::wrap(base, width, height, rowpixels); } + void wrap(uint32_t *base, int width, int height, int rowpixels) { bitmap_t::wrap(base, width, height, rowpixels); } void wrap(const bitmap_ind8 &source, const rectangle &subrect) { bitmap_t::wrap(static_cast<const bitmap_t &>(source), subrect); } // getters @@ -344,9 +344,9 @@ class bitmap_ind64 : public bitmap64_t public: // construction/destruction bitmap_ind64(int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap64_t(k_bitmap_format, width, height, xslop, yslop) { } - bitmap_ind64(UINT64 *base, int width, int height, int rowpixels) : bitmap64_t(k_bitmap_format, base, width, height, rowpixels) { } + bitmap_ind64(uint64_t *base, int width, int height, int rowpixels) : bitmap64_t(k_bitmap_format, base, width, height, rowpixels) { } bitmap_ind64(bitmap_ind64 &source, const rectangle &subrect) : bitmap64_t(k_bitmap_format, source, subrect) { } - void wrap(UINT64 *base, int width, int height, int rowpixels) { bitmap_t::wrap(base, width, height, rowpixels); } + void wrap(uint64_t *base, int width, int height, int rowpixels) { bitmap_t::wrap(base, width, height, rowpixels); } void wrap(const bitmap_ind8 &source, const rectangle &subrect) { bitmap_t::wrap(static_cast<const bitmap_t &>(source), subrect); } // getters @@ -364,9 +364,9 @@ class bitmap_yuy16 : public bitmap16_t public: // construction/destruction bitmap_yuy16(int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap16_t(k_bitmap_format, width, height, xslop, yslop) { } - bitmap_yuy16(UINT16 *base, int width, int height, int rowpixels) : bitmap16_t(k_bitmap_format, base, width, height, rowpixels) { } + bitmap_yuy16(uint16_t *base, int width, int height, int rowpixels) : bitmap16_t(k_bitmap_format, base, width, height, rowpixels) { } bitmap_yuy16(bitmap_yuy16 &source, const rectangle &subrect) : bitmap16_t(k_bitmap_format, source, subrect) { } - void wrap(UINT16 *base, int width, int height, int rowpixels) { bitmap_t::wrap(base, width, height, rowpixels); } + void wrap(uint16_t *base, int width, int height, int rowpixels) { bitmap_t::wrap(base, width, height, rowpixels); } void wrap(const bitmap_yuy16 &source, const rectangle &subrect) { bitmap_t::wrap(static_cast<const bitmap_t &>(source), subrect); } // getters @@ -381,9 +381,9 @@ class bitmap_rgb32 : public bitmap32_t public: // construction/destruction bitmap_rgb32(int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap32_t(k_bitmap_format, width, height, xslop, yslop) { } - bitmap_rgb32(UINT32 *base, int width, int height, int rowpixels) : bitmap32_t(k_bitmap_format, base, width, height, rowpixels) { } + bitmap_rgb32(uint32_t *base, int width, int height, int rowpixels) : bitmap32_t(k_bitmap_format, base, width, height, rowpixels) { } bitmap_rgb32(bitmap_rgb32 &source, const rectangle &subrect) : bitmap32_t(k_bitmap_format, source, subrect) { } - void wrap(UINT32 *base, int width, int height, int rowpixels) { bitmap_t::wrap(base, width, height, rowpixels); } + void wrap(uint32_t *base, int width, int height, int rowpixels) { bitmap_t::wrap(base, width, height, rowpixels); } void wrap(const bitmap_rgb32 &source, const rectangle &subrect) { bitmap_t::wrap(static_cast<const bitmap_t &>(source), subrect); } // getters @@ -398,9 +398,9 @@ class bitmap_argb32 : public bitmap32_t public: // construction/destruction bitmap_argb32(int width = 0, int height = 0, int xslop = 0, int yslop = 0) : bitmap32_t(k_bitmap_format, width, height, xslop, yslop) { } - bitmap_argb32(UINT32 *base, int width, int height, int rowpixels) : bitmap32_t(k_bitmap_format, base, width, height, rowpixels) { } + bitmap_argb32(uint32_t *base, int width, int height, int rowpixels) : bitmap32_t(k_bitmap_format, base, width, height, rowpixels) { } bitmap_argb32(bitmap_argb32 &source, const rectangle &subrect) : bitmap32_t(k_bitmap_format, source, subrect) { } - void wrap(UINT32 *base, int width, int height, int rowpixels) { bitmap_t::wrap(base, width, height, rowpixels); } + void wrap(uint32_t *base, int width, int height, int rowpixels) { bitmap_t::wrap(base, width, height, rowpixels); } void wrap(const bitmap_argb32 &source, const rectangle &subrect) { bitmap_t::wrap(static_cast<const bitmap_t &>(source), subrect); } // getters |