1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-30 23:18:08 +02:00

Merge pull request #1151 from Nordsoft91/editor-fix-imageload

Fix loading images which aren't divided by 4
This commit is contained in:
Nordsoft91 2022-11-19 15:08:55 +04:00 committed by GitHub
commit 4912f4d5ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View File

@ -450,10 +450,10 @@ void ImageLoader::init(QPoint SpriteSize, QPoint Margins, QPoint FullSize)
margins = Margins;
fullSize = FullSize;
memset((void *)image->bits(), 0, fullSize.y() * fullSize.x());
memset((void *)image->bits(), 0, fullSize.y() * image->bytesPerLine());
lineStart = image->bits();
lineStart += margins.y() * fullSize.x() + margins.x();
lineStart += margins.y() * image->bytesPerLine() + margins.x();
position = lineStart;
}
@ -477,7 +477,7 @@ inline void ImageLoader::Load(size_t size, ui8 color)
inline void ImageLoader::EndLine()
{
lineStart += fullSize.x();
lineStart += image->bytesPerLine();
position = lineStart;
}

View File

@ -63,7 +63,7 @@ namespace BitmapHandler
{
it = 0xC;
//auto bitmap = QBitmap::fromData(qsize, pcx + it);
QImage image(pcx + it, width, height, QImage::Format_Indexed8);
QImage image(pcx + it, width, height, width, QImage::Format_Indexed8);
//palette - last 256*3 bytes
QVector<QRgb> colorTable;
@ -81,7 +81,7 @@ namespace BitmapHandler
}
else
{
QImage image(pcx + it, width, height, QImage::Format_RGB32);
QImage image(pcx + it, width, height, width * 3, QImage::Format_RGB888);
return image;
}
}
@ -117,7 +117,7 @@ namespace BitmapHandler
{
logGlobal->error("Failed to open %s as H3 PCX!", fname);
}
return image;
return image.copy(); //copy must be returned here because buffer readFile.first used to build QImage will be cleaned after this line
}
else
{ //loading via QImage