Browse Source

add format() function

test
Syping 8 months ago
parent
commit
464e5bf6dd
  1. 1
      README.md
  2. 5
      src/RagePhoto-Extract.cpp
  3. 9
      src/RagePhoto.cpp
  4. 3
      src/RagePhoto.h

1
README.md

@ -29,6 +29,7 @@ uint32_t photoSize = ragePhoto.photoSize();
std::string json = ragePhoto.json();
std::string title = ragePhoto.title();
RagePhoto::Error error = ragePhoto.error();
RagePhoto::PhotoFormat format = ragePhoto.format();
```
#### How to Use ragephoto-extract

5
src/RagePhoto-Extract.cpp

@ -92,7 +92,10 @@ int main(int argc, char *argv[])
return -1;
}
std::cout << "Photo successfully exported" << std::endl;
if (ragePhoto.format() == RagePhoto::PhotoFormat::GTA5)
std::cout << "GTA V Photo successfully exported" << std::endl;
else
std::cout << "RDR 2 Photo successfully exported" << std::endl;
// Clear RagePhoto (provocate crash when pointer leak)
ragePhoto.clear();

9
src/RagePhoto.cpp

@ -36,7 +36,6 @@ RagePhoto::RagePhoto()
{
p_photoLoaded = false;
p_photoData = nullptr;
p_error = Error::Uninitialised;
}
RagePhoto::~RagePhoto()
@ -56,6 +55,7 @@ void RagePhoto::clear()
p_photoString.clear();
p_titleString.clear();
p_error = Error::Uninitialised;
p_photoFormat = PhotoFormat::Undefined;
}
bool RagePhoto::load(const char *data, size_t length)
@ -82,6 +82,8 @@ bool RagePhoto::load(const char *data, size_t length)
uint32_t format = charToUInt32LE(uInt32Buffer);
#endif
if (format == static_cast<uint32_t>(PhotoFormat::GTA5) || format == static_cast<uint32_t>(PhotoFormat::RDR2)) {
p_photoFormat = static_cast<PhotoFormat>(format);
char photoHeader[256];
size = readBuffer(data, photoHeader, &pos, 256, length);
if (size != 256) {
@ -359,6 +361,11 @@ RagePhoto::Error RagePhoto::error()
return p_error;
}
RagePhoto::PhotoFormat RagePhoto::format()
{
return p_photoFormat;
}
const char* RagePhoto::photoData()
{
if (p_photoLoaded)

3
src/RagePhoto.h

@ -67,6 +67,7 @@ public:
enum class PhotoFormat : uint32_t {
GTA5 = 0x01000000U,
RDR2 = 0x04000000U,
Undefined = 0,
};
RagePhoto();
~RagePhoto();
@ -74,6 +75,7 @@ public:
bool load(const char *data, size_t length);
bool load(const std::string &data);
Error error();
PhotoFormat format();
const char *photoData();
const uint32_t photoSize();
const std::string description();
@ -90,6 +92,7 @@ protected:
bool p_photoLoaded;
char* p_photoData;
Error p_error;
PhotoFormat p_photoFormat;
std::string p_descriptionString;
std::string p_jsonString;
std::string p_photoString;

Loading…
Cancel
Save