--- nono/lib/bitmap.h 2026/04/29 17:05:08 1.1 +++ nono/lib/bitmap.h 2026/04/29 17:05:15 1.1.1.3 @@ -21,7 +21,7 @@ class BitmapBase BitmapBase(); BitmapBase(int width_, int height_, int depth_); - void Create(int width_, int height_, int depth_); + bool Create(int width_, int height_, int depth_); public: virtual ~BitmapBase(); @@ -68,19 +68,21 @@ class BitmapI8 : public BitmapBase ~BitmapI8() override; void Create(int width_, int height_); + void Create(const void *buf_, int width_, int height_); // カラーコード cc で全体を塗りつぶす void Fill(int cc); uint8 *GetRowPtr(int y) const { - assert(y < height); + assertmsg(y < height, "y=%d height=%d", y, height); return &buf[y * stride]; } uint8 *GetPtr(int x, int y) const { - assert(x < width); - assert(y < height); - return &buf[y * stride + x]; } - }; + assertmsg(x < width, "x=%d width=%d", x, width); + assertmsg(y < height, "y=%d height=%d", y, height); + return &buf[y * stride + x]; + } +}; // 24bpp ビットマップ class BitmapRGB : public BitmapBase @@ -108,21 +110,24 @@ class BitmapRGB : public BitmapBase void DrawRect(Color c, int dx, int dy, int dw, int dh); void DrawBitmap(int dx, int dy, const BitmapI1& src, const Color *palette); + void DrawBitmap(int dx, int dy, const BitmapI8& src, const Color *palette); void DrawBitmap(int dx, int dy, const BitmapI8& src, const Color *palette, const Rect& sr); void DrawBitmap(int dx, int dy, const BitmapRGB& src); void DrawScaleUp(int dx, int dy, int scale, const BitmapI1& src, const Color *palette); + void DrawScale(const Rect& dr, const BitmapI8& src, const Color *palette, + int sxN, int sxD, int sxS, int syN, int syD, int syS); void StretchDraw(Rect dr, const BitmapRGB& src); uint8 *GetRowPtr(int y) const { - assert(y < height); + assertmsg(y < height, "y=%d height=%d", y, height); return &buf[y * stride]; } uint8 *GetPtr(int x, int y) const { - assert(x < width); - assert(y < height); + assertmsg(x < width, "x=%d width=%d", x, width); + assertmsg(y < height, "y=%d height=%d", y, height); return &buf[y * stride + x * 3]; }