Browse Source

G5E 2.0 implemented

Syping 6 months ago
parent
commit
c3e030e827
2 changed files with 31 additions and 18 deletions
  1. 30
    18
      SnapmaticPicture.cpp
  2. 1
    0
      SnapmaticPicture.h

+ 30
- 18
SnapmaticPicture.cpp View File

@@ -91,6 +91,7 @@ void SnapmaticPicture::reset()
91 91
 
92 92
     // INIT PIC BOOLS
93 93
     isCustomFormat = false;
94
+    isModernFormat = false;
94 95
     isFormatSwitch = false;
95 96
     isLoadedInRAM = false;
96 97
     lowRamMode = false;
@@ -138,6 +139,7 @@ bool SnapmaticPicture::preloadFile()
138 139
         else
139 140
         {
140 141
             isCustomFormat = false;
142
+            isModernFormat = false;
141 143
             isLoadedInRAM = true;
142 144
         }
143 145
     }
@@ -207,6 +209,29 @@ bool SnapmaticPicture::preloadFile()
207 209
                     return false;
208 210
                 }
209 211
             }
212
+            else if (g5eContent.left(2).toHex() == QByteArray("3200"))
213
+            {
214
+                g5eContent.remove(0, 2);
215
+                if (g5eContent.left(2).toHex() == QByteArray("0001"))
216
+                {
217
+                    g5eContent.remove(0, 2);
218
+                    rawPicContent = qUncompress(g5eContent);
219
+
220
+                    // Setting is values
221
+                    isModernFormat = true;
222
+                    isLoadedInRAM = true;
223
+                }
224
+                else if (g5eContent.left(2).toHex() == QByteArray("0002"))
225
+                {
226
+                    lastStep = "2;/4,ReadingFile," % convertDrawStringForLog(picFilePath) % ",2,G5E2_FORMATWRONG,G5E2_SGD";
227
+                    return false;
228
+                }
229
+                else
230
+                {
231
+                    lastStep = "2;/3,ReadingFile," % convertDrawStringForLog(picFilePath) % ",2,G5E2_MISSINGEXTENSION";
232
+                    return false;
233
+                }
234
+            }
210 235
             else
211 236
             {
212 237
                 lastStep = "2;/3,ReadingFile," % convertDrawStringForLog(picFilePath) % ",1,G5E_NOTCOMPATIBLE";
@@ -440,6 +465,7 @@ void SnapmaticPicture::updateStrings()
440 465
     pictureStr = tr("PHOTO - %1").arg(localProperties.createdDateTime.toString("MM/dd/yy HH:mm:ss"));
441 466
     sortStr = localProperties.createdDateTime.toString("yyMMddHHmmss") % QString::number(localProperties.uid);
442 467
     QString exportStr = localProperties.createdDateTime.toString("yyyyMMdd") % "-" % QString::number(localProperties.uid);
468
+    if (isModernFormat) { picFileName = "PGTA5" % QString::number(localProperties.uid); }
443 469
     picExportFileName = exportStr % "_" % cmpPicTitl;
444 470
 }
445 471
 
@@ -1132,27 +1158,13 @@ bool SnapmaticPicture::exportPicture(const QString &fileName, SnapmaticFormat fo
1132 1158
     {
1133 1159
         if (format == SnapmaticFormat::G5E_Format)
1134 1160
         {
1135
-            // Modern compressed export
1136
-            QByteArray stockFileNameUTF8 = picFileName.toUtf8();
1137
-            QByteArray numberLength = QByteArray::number(stockFileNameUTF8.length());
1138
-            if (numberLength.length() == 1)
1139
-            {
1140
-                numberLength.insert(0, '0');
1141
-            }
1142
-            else if (numberLength.length() != 2)
1143
-            {
1144
-                numberLength = "00";
1145
-            }
1161
+            // Modern compressed export (v2)
1146 1162
             QByteArray g5eHeader;
1147
-            g5eHeader.reserve(stockFileNameUTF8.length() + 16);
1163
+            g5eHeader.reserve(10);
1148 1164
             g5eHeader += '\x00'; // First Null Byte
1149 1165
             g5eHeader += QByteArray("G5E"); // GTA 5 Export
1150
-            g5eHeader += '\x10'; g5eHeader += '\x00'; // 2 byte GTA 5 Export Version
1151
-            g5eHeader += QByteArray("LEN"); // Before Length
1152
-            g5eHeader += QByteArray::fromHex(numberLength); // Length in HEX before Compressed
1153
-            g5eHeader += QByteArray("FIL"); // Before File Name
1154
-            g5eHeader += stockFileNameUTF8; // File Name
1155
-            g5eHeader += QByteArray("COM"); // Before Compressed
1166
+            g5eHeader += '\x32'; g5eHeader += '\x00'; // 2 byte GTA 5 Export Version
1167
+            g5eHeader += '\x00'; g5eHeader += '\x01'; // 2 byte GTA 5 Export Type
1156 1168
             if (picFile->write(g5eHeader) == -1) { writeFailure = true; }
1157 1169
             if (!lowRamMode)
1158 1170
             {

+ 1
- 0
SnapmaticPicture.h View File

@@ -160,6 +160,7 @@ private:
160 160
     bool isLoadedInRAM;
161 161
     bool isCustomFormat;
162 162
     bool isFormatSwitch;
163
+    bool isModernFormat;
163 164
     bool careSnapDefault;
164 165
     int jpegRawContentSize;
165 166
     int jpegRawContentSizeE;