1
0
Fork 0
mirror of https://gitlab.com/Syping/gta5view-cmd synced 2024-11-21 21:20:22 +01:00

Ignore Original Resolution added

This commit is contained in:
Syping 2018-08-14 01:50:59 +02:00
parent fe4a6cd081
commit dc5f1dc84b
3 changed files with 86 additions and 74 deletions

@ -1 +1 @@
Subproject commit dc101a66dad3bf09336556bfd9fc92bb6f723212 Subproject commit feabaac48eadfcc5a7ccc998884f1f96432d3f7c

View file

@ -32,6 +32,8 @@ HEADERS += \
INCLUDEPATH += ./gta5view INCLUDEPATH += ./gta5view
DEFINES += GTA5SYNC_NOASSIST
# WINDOWS ONLY # WINDOWS ONLY
win32: DEFINES += GTA5SYNC_WIN win32: DEFINES += GTA5SYNC_WIN

156
main.cpp
View file

@ -37,6 +37,7 @@ int main(int argc, char *argv[])
QString format = "jpg"; QString format = "jpg";
bool isDefault = true; bool isDefault = true;
bool avatarMode = false; bool avatarMode = false;
bool ignoreORes = false;
bool convertToGTA = false; bool convertToGTA = false;
bool customFormat = false; bool customFormat = false;
bool formatSwitch = false; bool formatSwitch = false;
@ -77,6 +78,11 @@ int main(int argc, char *argv[])
{ {
isDefault = true; isDefault = true;
} }
else if (args.at(4) == "-fs")
{
convertToGTA = false;
formatSwitch = true;
}
else if (args.at(4) == "-aiar") else if (args.at(4) == "-aiar")
{ {
isDefault = false; isDefault = false;
@ -111,10 +117,11 @@ int main(int argc, char *argv[])
isDefault = true; isDefault = true;
keepAspectRatio = true; keepAspectRatio = true;
} }
else if (args.at(4) == "-fs") else if (args.at(4) == "-ior")
{ {
convertToGTA = false; isDefault = false;
formatSwitch = true; ignoreORes = true;
keepAspectRatio = false;
} }
else else
{ {
@ -249,89 +256,92 @@ int main(int argc, char *argv[])
} }
if (!image.isNull()) if (!image.isNull())
{ {
QSize snapmaticRes(960, 536); if (!ignoreORes)
QSize avatarRes(470, 470);
int avatarZoneX = 145;
int avatarZoneY = 66;
if (isDefault)
{ {
if (image.width() == image.height()) QSize snapmaticRes(960, 536);
QSize avatarRes(470, 470);
int avatarZoneX = 145;
int avatarZoneY = 66;
if (isDefault)
{ {
avatarMode = true; if (image.width() == image.height())
{
avatarMode = true;
}
else
{
avatarMode = false;
}
}
if (!avatarMode)
{
QImage snapmaticImage(snapmaticRes, QImage::Format_RGB888);
snapmaticImage.fill(Qt::black);
QPainter snapmaticPainter(&snapmaticImage);
// Picture mode
int diffWidth = 0;
int diffHeight = 0;
if (keepAspectRatio)
{
image = image.scaled(snapmaticRes, Qt::KeepAspectRatio, Qt::SmoothTransformation);
if (image.width() != snapmaticRes.width())
{
diffWidth = snapmaticRes.width() - image.width();
diffWidth = diffWidth / 2;
}
else if (image.height() != snapmaticRes.height())
{
diffHeight = snapmaticRes.height() - image.height();
diffHeight = diffHeight / 2;
}
}
else
{
image = image.scaled(snapmaticRes.width(), snapmaticRes.height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
}
snapmaticPainter.drawImage(0 + diffWidth, 0 + diffHeight, image);
snapmaticPainter.end();
image = snapmaticImage;
} }
else else
{ {
avatarMode = false; QImage snapmaticImage(snapmaticRes, QImage::Format_RGB888);
} snapmaticImage.fill(Qt::black);
} QPainter snapmaticPainter(&snapmaticImage);
if (!avatarMode)
{
QImage snapmaticImage(snapmaticRes, QImage::Format_RGB888);
snapmaticImage.fill(Qt::black);
QPainter snapmaticPainter(&snapmaticImage);
// Picture mode // Scale to Avatar Resolution if needed
int diffWidth = 0; if (image.width() != avatarRes.width())
int diffHeight = 0;
if (keepAspectRatio)
{
image = image.scaled(snapmaticRes, Qt::KeepAspectRatio, Qt::SmoothTransformation);
if (image.width() != snapmaticRes.width())
{ {
diffWidth = snapmaticRes.width() - image.width(); image.scaled(avatarRes, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
diffWidth = diffWidth / 2;
} }
else if (image.height() != snapmaticRes.height())
{
diffHeight = snapmaticRes.height() - image.height();
diffHeight = diffHeight / 2;
}
}
else
{
image = image.scaled(snapmaticRes.width(), snapmaticRes.height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
}
snapmaticPainter.drawImage(0 + diffWidth, 0 + diffHeight, image);
snapmaticPainter.end();
image = snapmaticImage;
}
else
{
QImage snapmaticImage(snapmaticRes, QImage::Format_RGB888);
snapmaticImage.fill(Qt::black);
QPainter snapmaticPainter(&snapmaticImage);
// Scale to Avatar Resolution if needed // Avatar mode
if (image.width() != avatarRes.width()) int diffWidth = 0;
{ int diffHeight = 0;
image.scaled(avatarRes, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); if (keepAspectRatio)
}
// Avatar mode
int diffWidth = 0;
int diffHeight = 0;
if (keepAspectRatio)
{
image = image.scaled(avatarRes, Qt::KeepAspectRatio, Qt::SmoothTransformation);
if (image.width() > image.height())
{ {
diffHeight = avatarRes.height() - image.height(); image = image.scaled(avatarRes, Qt::KeepAspectRatio, Qt::SmoothTransformation);
diffHeight = diffHeight / 2; if (image.width() > image.height())
{
diffHeight = avatarRes.height() - image.height();
diffHeight = diffHeight / 2;
}
else if (image.width() < image.height())
{
diffWidth = avatarRes.width() - image.width();
diffWidth = diffWidth / 2;
}
} }
else if (image.width() < image.height()) else
{ {
diffWidth = avatarRes.width() - image.width(); image = image.scaled(avatarRes, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
diffWidth = diffWidth / 2;
} }
snapmaticPainter.drawImage(avatarZoneX + diffWidth, avatarZoneY + diffHeight, image);
snapmaticPainter.end();
image = snapmaticImage;
} }
else
{
image = image.scaled(avatarRes, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
}
snapmaticPainter.drawImage(avatarZoneX + diffWidth, avatarZoneY + diffHeight, image);
snapmaticPainter.end();
image = snapmaticImage;
} }
if (picture.setImage(image)) if (picture.setImage(image))
@ -510,7 +520,7 @@ int main(int argc, char *argv[])
cout << "Convert-only: <autodef> (auto file name at convert)" << endl; cout << "Convert-only: <autodef> (auto file name at convert)" << endl;
cout << "Convert-only: <autoext> (auto file extension at convert)" << endl; cout << "Convert-only: <autoext> (auto file extension at convert)" << endl;
cout << "Formats: jpg pgta g5e" << endl; cout << "Formats: jpg pgta g5e" << endl;
cout << "Snapmatic Modes: a p d fs aiar akar piar pkar diar dkar" << endl; cout << "Snapmatic Modes: a p d fs aiar akar piar pkar diar dkar ior" << endl;
cout << "Snapmatic Flags: crew=int players=int[] position=double[] title=string" << endl; cout << "Snapmatic Flags: crew=int players=int[] position=double[] title=string" << endl;
cout << "Global Flags: output=string" << endl; cout << "Global Flags: output=string" << endl;
} }