Allow replacing raw data on animated bitmaps

This commit is contained in:
Struma 2021-05-02 23:50:16 -04:00 committed by Roza
parent 9c603b329e
commit 66de7c1d14

View file

@ -1226,14 +1226,18 @@ bool Bitmap::getRaw(void *output, int output_size)
void Bitmap::replaceRaw(void *pixel_data, int size)
{
guardDisposed();
int w = width();
int h = height();
if (size != w*h*4) return;
GUARD_MEGA;
GUARD_ANIMATED;
GUARD_PLAYING;
int w = width();
int h = height();
int requiredsize = w*h*4;
if (size != w*h*4)
throw Exception(Exception::MKXPError, "Replacement bitmap data is not large enough (given %i bytes, need %i)", size, requiredsize);
TEX::bind(p->gl.tex);
TEX::bind(getGLTypes().tex);
TEX::uploadImage(w, h, pixel_data, GL_RGBA);
taintArea(IntRect(0,0,w,h));
@ -1914,6 +1918,7 @@ void Bitmap::removeFrame(int position) {
FBO::bind(p->gl.fbo);
gl.ReadPixels(0,0,p->gl.width, p->gl.height, GL_RGBA, GL_UNSIGNED_BYTE, p->surface->pixels);
taintArea(rect());
}
}