mOwnData = std::make_unique<uchar[]>(mStride * mHeight);
}
+void VBitmap::Impl::reset(uchar *data, size_t width, size_t height, size_t bytesPerLine,
+ VBitmap::Format format)
+{
+ mRoData = data;
+ mWidth = uint(width);
+ mHeight = uint(height);
+ mStride = uint(bytesPerLine);
+ mFormat = format;
+ mDepth = depth(format);
+ mOwnData = nullptr;
+}
+
uchar VBitmap::Impl::depth(VBitmap::Format format)
{
uchar depth = 1;
mImpl = rc_ptr<Impl>(data, width, height, bytesPerLine, format);
}
+void VBitmap::reset(uchar *data, size_t w, size_t h, size_t bytesPerLine,
+ VBitmap::Format format)
+{
+ if (mImpl) {
+ mImpl->reset(data, w, h, bytesPerLine, format);
+ } else {
+ mImpl = rc_ptr<Impl>(data, w, h, bytesPerLine, format);
+ }
+}
+
void VBitmap::reset(size_t w, size_t h, VBitmap::Format format)
{
if (mImpl) {
VBitmap() = default;
VBitmap(size_t w, size_t h, VBitmap::Format format);
VBitmap(uchar *data, size_t w, size_t h, size_t bytesPerLine, VBitmap::Format format);
-
+ void reset(uchar *data, size_t w, size_t h, size_t stride, VBitmap::Format format);
void reset(size_t w, size_t h, VBitmap::Format format=Format::ARGB32_Premultiplied);
size_t stride() const;
size_t width() const;
reset(width, height, format);
}
explicit Impl(uchar *data, size_t w, size_t h, size_t bytesPerLine, VBitmap::Format format)
- : mRoData(data), mWidth(uint(w)), mHeight(uint(h)), mStride(uint(bytesPerLine)),
- mDepth(depth(format)), mFormat(format){}
+ {
+ reset(data, w, h, bytesPerLine, format);
+ }
VRect rect() const { return VRect(0, 0, mWidth, mHeight);}
VSize size() const { return VSize(mWidth, mHeight); }
size_t stride() const { return mStride; }
size_t height() const { return mHeight; }
uchar * data() { return mRoData ? mRoData : mOwnData.get(); }
VBitmap::Format format() const { return mFormat; }
+ void reset(uchar *, size_t, size_t, size_t, VBitmap::Format);
void reset(size_t, size_t, VBitmap::Format);
static uchar depth(VBitmap::Format format);
void fill(uint);