diff --git a/README.md b/README.md
index e27f99d..22d7a8d 100644
--- a/README.md
+++ b/README.md
@@ -17,7 +17,7 @@ sudo make install
```
##### Optional CMake flags
-`-DWITH_EXTRACT=OFF` `-DWITH_GTK_EXAMPLE=ON` `-DWITH_QT_EXAMPLE=ON` `-DBUILD_SHARED=OFF`
+`-DWITH_DOCUMENTATION=ON` `-DWITH_EXTRACT=OFF` `-DWITH_GTK_EXAMPLE=ON` `-DWITH_QT_EXAMPLE=ON` `-DBUILD_SHARED=OFF`
#### How to Use libragephoto
@@ -31,6 +31,7 @@ std::string title = ragePhoto.title();
RagePhoto::Error error = ragePhoto.error();
RagePhoto::PhotoFormat format = ragePhoto.format();
```
+[RagePhoto API](https://libragephoto.syping.de/doc/classRagePhoto.html)
#### How to Use ragephoto-extract
diff --git a/doc/index.doc b/doc/index.doc
index 624ab4f..700afc0 100644
--- a/doc/index.doc
+++ b/doc/index.doc
@@ -1,6 +1,6 @@
/*! \mainpage
-#### Open Source RAGE Photo Parser for GTA V and RDR 2
+
Open Source RAGE Photo Parser for GTA V and RDR 2
- Read RAGE Photos error free and correct
- Support for metadata stored in RAGE Photos
diff --git a/src/RagePhoto.cpp b/src/RagePhoto.cpp
index bb9cd58..f95d9e8 100644
--- a/src/RagePhoto.cpp
+++ b/src/RagePhoto.cpp
@@ -36,6 +36,7 @@ RagePhoto::RagePhoto()
{
p_photoLoaded = false;
p_photoData = nullptr;
+ setBufferDefault();
}
RagePhoto::~RagePhoto()
@@ -56,6 +57,7 @@ void RagePhoto::clear()
p_titleString.clear();
p_error = Error::Uninitialised;
p_photoFormat = PhotoFormat::Undefined;
+ setBufferDefault();
}
bool RagePhoto::load(const char *data, size_t length)
@@ -344,6 +346,25 @@ bool RagePhoto::load(const char *data, size_t length)
std::cout << "Benchmark: " << benchmark_ns.count() << "ns" << std::endl;
#endif
+#ifdef RAGEPHOTO_DEBUG
+ std::cout << "header: " << p_photoString << std::endl;
+ std::cout << "headerSum: " << p_headerSum << std::endl;
+ std::cout << "photoBuffer: " << p_photoBuffer << std::endl;
+ std::cout << "descBuffer: " << p_descBuffer << std::endl;
+ std::cout << "descOffset: " << p_descOffset << std::endl;
+ std::cout << "jsonBuffer: " << p_jsonBuffer << std::endl;
+ std::cout << "jsonOffset: " << p_jsonOffset << std::endl;
+ std::cout << "titlBuffer: " << p_titlBuffer << std::endl;
+ std::cout << "titlOffset: " << p_titlOffset << std::endl;
+ std::cout << "eofOffset: " << p_endOfFile << std::endl;
+ std::cout << "moveOffsets()" << std::endl;
+ moveOffsets();
+ std::cout << "descOffset: " << p_descOffset << std::endl;
+ std::cout << "jsonOffset: " << p_jsonOffset << std::endl;
+ std::cout << "titlOffset: " << p_titlOffset << std::endl;
+ std::cout << "eofOffset: " << p_endOfFile << std::endl;
+#endif
+
p_error = Error::NoError; // 255
return true;
}
@@ -374,7 +395,7 @@ const char* RagePhoto::photoData()
return nullptr;
}
-const uint32_t RagePhoto::photoSize()
+uint32_t RagePhoto::photoSize()
{
if (p_photoLoaded)
return p_photoSize;
@@ -402,6 +423,14 @@ const std::string RagePhoto::title()
return p_titleString;
}
+void RagePhoto::setBufferDefault()
+{
+ p_descBuffer = DEFAULT_DESCBUFFER;
+ p_jsonBuffer = DEFAULT_JSONBUFFER;
+ p_titlBuffer = DEFAULT_TITLBUFFER;
+ moveOffsets();
+}
+
void RagePhoto::setDescription(const std::string &description, uint32_t bufferSize)
{
p_descriptionString = description;
@@ -411,6 +440,11 @@ void RagePhoto::setDescription(const std::string &description, uint32_t bufferSi
}
}
+void RagePhoto::setFormat(PhotoFormat photoFormat)
+{
+ p_photoFormat = photoFormat;
+}
+
void RagePhoto::setJson(const std::string &json, uint32_t bufferSize)
{
p_jsonString = json;
diff --git a/src/RagePhoto.h b/src/RagePhoto.h
index 6b4e341..283d700 100644
--- a/src/RagePhoto.h
+++ b/src/RagePhoto.h
@@ -24,6 +24,12 @@
#include
#include
+#define DEFAULT_GTAV_PHOTOBUFFER 524288UL /**< GTA V default Photo Buffer Size */
+#define DEFAULT_RDR2_PHOTOBUFFER 1048576UL /**< RDR 2 default Photo Buffer Size */
+#define DEFAULT_DESCBUFFER 256UL /**< Default Description Buffer Size */
+#define DEFAULT_JSONBUFFER 3072UL /**< Default JSON Buffer Size */
+#define DEFAULT_TITLBUFFER 256UL /**< Default Title Buffer Size */
+
class LIBRAGEPHOTO_EXPORT RagePhoto
{
public:
@@ -79,21 +85,25 @@ public:
Error error(); /**< Returns the last error occurred. */
PhotoFormat format(); /**< Returns the Photo Format (GTA V or RDR 2). */
const char *photoData(); /**< Returns the Photo JPEG data. */
- const uint32_t photoSize(); /**< Returns the Photo JPEG data size. */
+ uint32_t photoSize(); /**< Returns the Photo JPEG data size. */
const std::string description(); /**< Returns the Photo description. */
const std::string json(); /**< Returns the Photo JSON data. */
const std::string header(); /**< Returns the Photo header. */
const std::string title(); /**< Returns the Photo title. */
+ void setBufferDefault(); /**< Sets all cross-format Buffer to default size. */
void setDescription(const std::string &description, uint32_t bufferSize = 0); /**< Sets the Photo description. */
+ void setFormat(PhotoFormat photoFormat); /**< Sets the Photo Format (GTA V or RDR 2). */
void setJson(const std::string &json, uint32_t bufferSize = 0); /**< Sets the Photo JSON data. */
void setHeader(const std::string &header, uint32_t headerSum); /**< Sets the Photo header. (expert only) */
/** Sets the Photo JPEG data.
- * @param data JPEG data
- * @param size JPEG data size
+ * \param data JPEG data
+ * \param size JPEG data size
+ * \param bufferSize JPEG buffer size
*/
bool setPhotoData(const char *data, uint32_t size, uint32_t bufferSize = 0);
/** Sets the Photo JPEG data.
- * @param data JPEG data
+ * \param data JPEG data
+ * \param bufferSize JPEG buffer size
*/
bool setPhotoData(const std::string &data, uint32_t bufferSize = 0);
void setTitle(const std::string &title, uint32_t bufferSize = 0); /**< Sets the Photo title. */
diff --git a/tests/CodecvtTest.cpp b/tests/CodecvtTest.cpp
index e20245c..f5adce2 100644
--- a/tests/CodecvtTest.cpp
+++ b/tests/CodecvtTest.cpp
@@ -23,7 +23,7 @@
int main(int argc, char *argv[])
{
- const char photoHeader[256] = {
+ char photoHeader[256] = {
0x50, 0x00, 0x48, 0x00, 0x4f, 0x00, 0x54, 0x00,
0x4f, 0x00, 0x20, 0x00, 0x2d, 0x00, 0x20, 0x00,
0x30, 0x00, 0x32, 0x00, 0x2f, 0x00, 0x30, 0x00,
@@ -57,10 +57,7 @@ int main(int argc, char *argv[])
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
- char16_t photoHeader16[128];
- memcpy(photoHeader16, photoHeader, 256);
std::wstring_convert,char16_t> convert;
- std::string photoString = convert.to_bytes(photoHeader16);
- std::cout << photoString << std::endl;
+ std::string photoString = convert.to_bytes(reinterpret_cast(photoHeader));
return strcmp(photoString.c_str(), "PHOTO - 02/01/17 08:42:44");
}