Fix tabs. Fix leak.
This commit is contained in:
parent
66d02325d8
commit
2952480d30
@ -1789,22 +1789,24 @@ Image * nv::ImageIO::loadSTB(Stream & s)
|
|||||||
|
|
||||||
if (data != NULL) {
|
if (data != NULL) {
|
||||||
Image * img = new Image;
|
Image * img = new Image;
|
||||||
img->allocate(w, h);
|
img->allocate(w, h);
|
||||||
img->setFormat(n == 4 ? Image::Format_ARGB : Image::Format_RGB);
|
img->setFormat(n == 4 ? Image::Format_ARGB : Image::Format_RGB);
|
||||||
|
|
||||||
for (int y = 0; y < h; ++y)
|
for (int y = 0; y < h; ++y)
|
||||||
{
|
{
|
||||||
nv::Color32* dest = img->scanline(y);
|
nv::Color32* dest = img->scanline(y);
|
||||||
uint8* src = data + y * w * 4;
|
uint8* src = data + y * w * 4;
|
||||||
|
|
||||||
for (int x = 0; x < w; ++x)
|
for (int x = 0; x < w; ++x)
|
||||||
{
|
{
|
||||||
dest[x].r = src[x * 4 + 0];
|
dest[x].r = src[x * 4 + 0];
|
||||||
dest[x].g = src[x * 4 + 1];
|
dest[x].g = src[x * 4 + 1];
|
||||||
dest[x].b = src[x * 4 + 2];
|
dest[x].b = src[x * 4 + 2];
|
||||||
dest[x].a = src[x * 4 + 3];
|
dest[x].a = src[x * 4 + 3];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(data);
|
||||||
|
|
||||||
return img;
|
return img;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user