SnapmaticPicture: update size, width and height for RDR 2
This commit is contained in:
		
							parent
							
								
									b19cfdee0f
								
							
						
					
					
						commit
						0e6a6ae34a
					
				
					 4 changed files with 26 additions and 16 deletions
				
			
		|  | @ -793,7 +793,8 @@ void PictureDialog::editSnapmaticImage() | ||||||
|                 QFile::copy(currentFilePath, backupFileName); |                 QFile::copy(currentFilePath, backupFileName); | ||||||
|             } |             } | ||||||
|             if (!smpic->exportPicture(currentFilePath)) { |             if (!smpic->exportPicture(currentFilePath)) { | ||||||
|                 smpic->setPictureStream(previousPicture); |                 // TODO: Find a way to cache the image width and height
 | ||||||
|  |                 smpic->setPictureStream(previousPicture, 0, 0); | ||||||
|                 QMessageBox::warning(this, QApplication::translate("ImageEditorDialog", "Snapmatic Image Editor"), QApplication::translate("ImageEditorDialog", "Patching of Snapmatic Image failed because of I/O Error")); |                 QMessageBox::warning(this, QApplication::translate("ImageEditorDialog", "Snapmatic Image Editor"), QApplication::translate("ImageEditorDialog", "Patching of Snapmatic Image failed because of I/O Error")); | ||||||
|                 return; |                 return; | ||||||
|             } |             } | ||||||
|  |  | ||||||
|  | @ -650,11 +650,14 @@ bool SnapmaticPicture::readingPictureFromFile(const QString &fileName, bool cach | ||||||
| 
 | 
 | ||||||
| bool SnapmaticPicture::setImage(const QImage &picture, bool eXtendMode) | bool SnapmaticPicture::setImage(const QImage &picture, bool eXtendMode) | ||||||
| { | { | ||||||
| #ifdef GTA5SYNC_DYNAMIC_PHOTOBUFFER // It's not properly implemented yet, please don't define
 |     quint32 photoFormat = p_ragePhoto.format(); | ||||||
|     quint32 jpegPicStreamLength = p_ragePhoto.data()->photoBuffer(); |     quint32 jpegPicStreamLength = 0; | ||||||
| #else |     if (gta5view_isGTAVFormat(photoFormat)) { | ||||||
|     quint32 jpegPicStreamLength = RagePhoto::DEFAULT_GTA5_PHOTOBUFFER; |         jpegPicStreamLength = RagePhoto::DEFAULT_GTA5_PHOTOBUFFER; | ||||||
| #endif |     } | ||||||
|  |     else if (gta5view_isRDR2Format(photoFormat)) { | ||||||
|  |         jpegPicStreamLength = RagePhoto::DEFAULT_RDR2_PHOTOBUFFER; | ||||||
|  |     } | ||||||
|     QByteArray picByteArray; |     QByteArray picByteArray; | ||||||
|     int comLvl = 100; |     int comLvl = 100; | ||||||
|     bool saveSuccess = false; |     bool saveSuccess = false; | ||||||
|  | @ -679,17 +682,20 @@ bool SnapmaticPicture::setImage(const QImage &picture, bool eXtendMode) | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     if (saveSuccess) |     if (saveSuccess) | ||||||
|         return setPictureStream(picByteArray); |         return setPictureStream(picByteArray, picture.width(), picture.height()); | ||||||
|     return false; |     return false; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool SnapmaticPicture::setPictureStream(const QByteArray &streamArray) // clean method
 | bool SnapmaticPicture::setPictureStream(const QByteArray &streamArray, int width, int height) | ||||||
| { | { | ||||||
| #ifdef GTA5SYNC_DYNAMIC_PHOTOBUFFER // It's not properly implemented yet, please don't define
 |     quint32 photoFormat = p_ragePhoto.format(); | ||||||
|     quint32 jpegPicStreamLength = p_ragePhoto.data()->photoBuffer(); |     quint32 jpegPicStreamLength = 0; | ||||||
| #else |     if (gta5view_isGTAVFormat(photoFormat)) { | ||||||
|     quint32 jpegPicStreamLength = RagePhoto::DEFAULT_GTA5_PHOTOBUFFER; |         jpegPicStreamLength = RagePhoto::DEFAULT_GTA5_PHOTOBUFFER; | ||||||
| #endif |     } | ||||||
|  |     else if (gta5view_isRDR2Format(photoFormat)) { | ||||||
|  |         jpegPicStreamLength = RagePhoto::DEFAULT_RDR2_PHOTOBUFFER; | ||||||
|  |     } | ||||||
|     if (streamArray.size() > jpegPicStreamLength) |     if (streamArray.size() > jpegPicStreamLength) | ||||||
|         jpegPicStreamLength = streamArray.size(); |         jpegPicStreamLength = streamArray.size(); | ||||||
| #ifdef GTA5SYNC_COMPACT_PHOTOBUFFER // Experiment to save less than the default photo buffer
 | #ifdef GTA5SYNC_COMPACT_PHOTOBUFFER // Experiment to save less than the default photo buffer
 | ||||||
|  | @ -699,7 +705,6 @@ bool SnapmaticPicture::setPictureStream(const QByteArray &streamArray) // clean | ||||||
|     bool success = p_ragePhoto.setJpeg(streamArray.constData(), streamArray.size(), jpegPicStreamLength); |     bool success = p_ragePhoto.setJpeg(streamArray.constData(), streamArray.size(), jpegPicStreamLength); | ||||||
|     if (success) { |     if (success) { | ||||||
|         // Update JPEG signature
 |         // Update JPEG signature
 | ||||||
|         uint32_t photoFormat = p_ragePhoto.format(); |  | ||||||
|         if (gta5view_isGTAVFormat(photoFormat)) { |         if (gta5view_isGTAVFormat(photoFormat)) { | ||||||
|             snapmaticJson.jsonObject["sign"] = p_ragePhoto.jpegSign(RagePhoto::PhotoFormat::GTA5); |             snapmaticJson.jsonObject["sign"] = p_ragePhoto.jpegSign(RagePhoto::PhotoFormat::GTA5); | ||||||
|             const std::string json = SnapmaticJson::serialize(snapmaticJson.jsonObject); |             const std::string json = SnapmaticJson::serialize(snapmaticJson.jsonObject); | ||||||
|  | @ -707,6 +712,9 @@ bool SnapmaticPicture::setPictureStream(const QByteArray &streamArray) // clean | ||||||
|         } |         } | ||||||
|         else if (gta5view_isRDR2Format(photoFormat)) { |         else if (gta5view_isRDR2Format(photoFormat)) { | ||||||
|             snapmaticJson.jsonObject["sign"] = p_ragePhoto.jpegSign(RagePhoto::PhotoFormat::RDR2); |             snapmaticJson.jsonObject["sign"] = p_ragePhoto.jpegSign(RagePhoto::PhotoFormat::RDR2); | ||||||
|  |             snapmaticJson.jsonObject["size"] = jpegPicStreamLength; | ||||||
|  |             snapmaticJson.jsonObject["width"] = width; | ||||||
|  |             snapmaticJson.jsonObject["height"] = height; | ||||||
|             const std::string json = SnapmaticJson::serialize(snapmaticJson.jsonObject); |             const std::string json = SnapmaticJson::serialize(snapmaticJson.jsonObject); | ||||||
|             p_ragePhoto.setJson(json.c_str()); |             p_ragePhoto.setJson(json.c_str()); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  | @ -91,7 +91,7 @@ public: | ||||||
|     const QString getOriginalPictureFilePath(); |     const QString getOriginalPictureFilePath(); | ||||||
|     bool setImage(const QImage &picture, bool eXtendMode = false); |     bool setImage(const QImage &picture, bool eXtendMode = false); | ||||||
|     bool setPictureTitl(const QString &newTitle); // Please use setPictureTitle instead
 |     bool setPictureTitl(const QString &newTitle); // Please use setPictureTitle instead
 | ||||||
|     bool setPictureStream(const QByteArray &streamArray); |     bool setPictureStream(const QByteArray &streamArray, int width, int height); | ||||||
|     void updateStrings(); |     void updateStrings(); | ||||||
|     void emitUpdate(); |     void emitUpdate(); | ||||||
|     void emitCustomSignal(const QString &signal); |     void emitCustomSignal(const QString &signal); | ||||||
|  |  | ||||||
|  | @ -366,7 +366,8 @@ void SnapmaticWidget::editSnapmaticImage() | ||||||
|                 QFile::copy(currentFilePath, backupFileName); |                 QFile::copy(currentFilePath, backupFileName); | ||||||
|             } |             } | ||||||
|             if (!smpic->exportPicture(currentFilePath)) { |             if (!smpic->exportPicture(currentFilePath)) { | ||||||
|                 smpic->setPictureStream(previousPicture); |                 // TODO: Find a way to cache the image width and height
 | ||||||
|  |                 smpic->setPictureStream(previousPicture, 0, 0); | ||||||
|                 QMessageBox::warning(this, QApplication::translate("ImageEditorDialog", "Snapmatic Image Editor"), QApplication::translate("ImageEditorDialog", "Patching of Snapmatic Image failed because of I/O Error")); |                 QMessageBox::warning(this, QApplication::translate("ImageEditorDialog", "Snapmatic Image Editor"), QApplication::translate("ImageEditorDialog", "Patching of Snapmatic Image failed because of I/O Error")); | ||||||
|                 return; |                 return; | ||||||
|             } |             } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue