.cosmetics

git-svn-id: svn://ultimatepp.org/upp/trunk@11499 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2017-11-27 16:23:38 +00:00
parent e805067cd7
commit a1dd116809

View file

@ -228,40 +228,35 @@ void Image::Serialize(Stream& s)
Size dots = GetDots();
s % sz % p % dots;
int64 len = (int64)sz.cx * (int64)sz.cy * (int64)sizeof(RGBA);
if(s.IsLoading())
if(s.IsLoading()) {
if(len) {
// if(s.GetPos() + len > s.GetSize()) {
// s.SetError();
// return;
// }
// TODO: Add invalid stream protection
ImageBuffer b;
if(len < 6 * 1024 * 1024) {
b.Create(sz);
if(!s.GetAll(~b, (int)len)) {
s.LoadError();
Clear();
s.LoadError();
return;
}
}
else {
Huge h;
if(!s.GetAll(h, (size_t)len)) {
s.LoadError();
Clear();
s.LoadError();
return;
}
b.Create(sz);
h.Get(~b);
}
b.SetDots(dots);
b.SetHotSpot(p);
*this = b;
}
else
Clear();
}
else
s.Put64(~*this, len);
}