libragephoto: improve documentation

This commit is contained in:
Syping 2024-04-09 05:21:36 +02:00
parent 0fa69667d0
commit bc9065e8dc
9 changed files with 234 additions and 109 deletions

View file

@ -1,6 +1,6 @@
#[[************************************************************************** #[[**************************************************************************
* libragephoto RAGE Photo Parser * libragephoto RAGE Photo Parser
* Copyright (C) 2021 Syping * Copyright (C) 2021-2024 Syping
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -24,12 +24,13 @@ if (NOT DOXYGEN_FOUND)
message(FATAL_ERROR "Doxygen is needed to build the documentation.") message(FATAL_ERROR "Doxygen is needed to build the documentation.")
endif() endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in" "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile" @ONLY)
add_custom_target( add_custom_target(
doc ALL doc ALL
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile COMMAND "${DOXYGEN_EXECUTABLE}" "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Generate API documentation with Doxygen" COMMENT "Generate API documentation with Doxygen"
SOURCES "build.dox" "index.dox" "usage.dox"
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
VERBATIM VERBATIM
) )
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html DESTINATION ${CMAKE_INSTALL_DOCDIR}) install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/html" DESTINATION "${CMAKE_INSTALL_DOCDIR}")

View file

@ -1,16 +1,18 @@
PROJECT_NAME = "libragephoto" PROJECT_NAME = "libragephoto"
PROJECT_NUMBER = "Version: @ragephoto_VERSION@" PROJECT_NUMBER = "Version: @ragephoto_VERSION@"
INPUT = "@CMAKE_CURRENT_SOURCE_DIR@/index.doc" \ INPUT = "src/core" \
"@CMAKE_CURRENT_SOURCE_DIR@/build.doc" \ "@CMAKE_CURRENT_SOURCE_DIR@/index.dox" \
"@CMAKE_CURRENT_SOURCE_DIR@/usage.doc" \ "@CMAKE_CURRENT_SOURCE_DIR@/build.dox" \
"src/core" "@CMAKE_CURRENT_SOURCE_DIR@/usage.dox"
OUTPUT_DIRECTORY = "@CMAKE_CURRENT_BINARY_DIR@" OUTPUT_DIRECTORY = "@CMAKE_CURRENT_BINARY_DIR@"
FULL_PATH_NAMES = NO
EXTRACT_PRIVATE = NO EXTRACT_PRIVATE = NO
ENABLE_PREPROCESSING = YES ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = YES MACRO_EXPANSION = YES
EXPAND_ONLY_PREDEF = YES EXPAND_ONLY_PREDEF = NO
PREDEFINED = "__cplusplus=201703L" \ PREDEFINED = "__cplusplus=201703L" \
"RAGEPHOTO_CXX_STD=17" \ "RAGEPHOTO_CXX_STD=17" \
"@LIBRAGEPHOTO_API@" \
"LIBRAGEPHOTO_C_PUBLIC=" \ "LIBRAGEPHOTO_C_PUBLIC=" \
"LIBRAGEPHOTO_CXX_PUBLIC=" "LIBRAGEPHOTO_CXX_PUBLIC=" \
"INT32_C(val)=val" \
"UINT32_C(val)=val##U"

View file

@ -21,6 +21,7 @@ To customise your libragephoto build, the following <a href="#flags">Optional CM
-DRAGEPHOTO_BENCHMARK=ON -DRAGEPHOTO_BENCHMARK=ON
-DRAGEPHOTO_C_API=OFF -DRAGEPHOTO_C_API=OFF
-DRAGEPHOTO_C_LIBRARY=ON -DRAGEPHOTO_C_LIBRARY=ON
-DRAGEPHOTO_DEBUG=ON
-DRAGEPHOTO_DOC=ON -DRAGEPHOTO_DOC=ON
-DRAGEPHOTO_EXAMPLE_GTKVIEWER=ON -DRAGEPHOTO_EXAMPLE_GTKVIEWER=ON
-DRAGEPHOTO_EXAMPLE_QTVIEWER=ON -DRAGEPHOTO_EXAMPLE_QTVIEWER=ON

View file

@ -12,9 +12,8 @@
\subpage Usage "Using libragephoto" \subpage Usage "Using libragephoto"
<b>Reference</b> <b>Reference</b>
ragephoto::cxx_abi::photo (C++ API) \ref RagePhotoInstance "RagePhoto C API"
ragephoto::c_abi::photo (C++ API based on C API) \ref ragephoto::photo "RagePhoto C++ API"
RagePhoto.h (C API)
RagePhotoData (Data Object Struct) RagePhotoData (Data Object Struct)
RagePhotoFormatParser (Custom Format Parser Struct) RagePhotoFormatParser (Custom Format Parser Struct)

View file

@ -2,15 +2,13 @@
<h3 id="api_cxx">C++ API</h3> <h3 id="api_cxx">C++ API</h3>
<h4 id="cxx_include_usage">Including and using RagePhoto</h4> <h4 id="cxx_include">Including RagePhoto</h4>
Include RagePhoto
\code{.cpp} \code{.cpp}
#include <RagePhoto> #include <RagePhoto>
\endcode \endcode
Create a RagePhoto object Initializing a RagePhoto object
\code{.cpp} \code{.cpp}
RagePhoto ragePhoto; RagePhoto ragePhoto;
@ -21,16 +19,14 @@ RagePhoto ragePhoto;
From a file using RagePhoto::loadFile From a file using RagePhoto::loadFile
\code{.cpp} \code{.cpp}
const char* filename = "PGTA5123456789"; const bool loaded = ragePhoto.loadFile("PGTA5123456789");
const bool loaded = ragePhoto.loadFile(filename);
\endcode \endcode
From a file using RagePhoto::load(const std::string&) From a file using RagePhoto::load(const std::string&)
\code{.cpp} \code{.cpp}
// Reading file // Reading file
const char* filename = "PGTA5123456789"; std::ifstream ifs("PGTA5123456789", std::ios::in | std::ios::binary);
std::ifstream ifs(filename, std::ios::in | std::ios::binary);
if (!ifs.is_open()) if (!ifs.is_open())
return; return;
std::string sdata(std::istreambuf_iterator<char>{ifs}, {}); std::string sdata(std::istreambuf_iterator<char>{ifs}, {});
@ -46,7 +42,7 @@ From a char* using RagePhoto::load(const char*, size_t)
const bool loaded = ragePhoto.load(data, size); const bool loaded = ragePhoto.load(data, size);
\endcode \endcode
<h4 id="cxx_using">Using a Photo</h4> <h4 id="cxx_using">Querying Photo data</h4>
\code{.cpp} \code{.cpp}
// Returns the Photo Format // Returns the Photo Format
@ -85,64 +81,21 @@ Saving the JPEG from a Photo
\code{.cpp} \code{.cpp}
// Example saveJpeg function // Example saveJpeg function
bool saveJpeg(RagePhoto* ragePhoto, const std::string& filename) { bool saveJpeg(RagePhoto &ragePhoto, const std::string &filename) {
std::ofstream ofs(filename, std::ios::out | std::ios::binary | std::ios::trunc); std::ofstream ofs(filename, std::ios::out | std::ios::binary | std::ios::trunc);
if (!ofs.is_open()) if (!ofs.is_open())
return false; return false;
ofs << ragePhoto->jpeg(); ofs << ragePhoto.jpeg();
const bool saved = ofs.good(); const bool saved = ofs.good();
ofs.close(); ofs.close();
return saved; return saved;
} }
// Using the saveJpeg function // Using the saveJpeg function
const char* filename = "PGTA5123456789.jpg"; const bool saved = saveJpeg(ragePhoto, "photo.jpg");
const bool saved = saveJpeg(&ragePhoto, filename);
\endcode \endcode
Using the JPEG in GTK+ (gtkmm) <h4 id="cxx_error">Querying last error</h4>
\code{.cpp}
// Writing pixbuf loader
GdkPixbufLoader* pixbuf_loader = gdk_pixbuf_loader_new();
gdk_pixbuf_loader_write(pixbuf_loader, reinterpret_cast<const guchar*>(ragePhoto.jpegData()), ragePhoto.jpegSize(), nullptr);
GdkPixbuf* pixbuf = gdk_pixbuf_loader_get_pixbuf(pixbuf_loader);
gdk_pixbuf_loader_close(pixbuf_loader, nullptr);
// Set image
Gtk::Image image;
image.set(Glib::wrap(pixbuf));
\endcode
Using the JPEG in Qt
\code{.cpp}
// Returns the JPEG as QImage
const QImage image = QImage::fromData(QByteArray::fromRawData(ragePhoto.jpegData(), ragePhoto.jpegSize()), "JPEG");
// Loading the JPEG in QImage
QImage image;
const bool loaded = image.loadFromData(QByteArray::fromRawData(ragePhoto.jpegData(), ragePhoto.jpegSize()), "JPEG");
\endcode
Using the JSON in Boost.JSON
\code{.cpp}
boost::json::error_code ec;
const boost::json::value jv = boost::json::parse(ragePhoto.json(), ec);
if (ec)
return;
\endcode
Using the JSON in Qt
\code{.cpp}
const QJsonDocument jd = QJsonDocument::fromJson(ragePhoto.json());
if (jd.isNull())
return;
\endcode
<h4 id="cxx_error">Detect Photo errors</h4>
\code{.cpp} \code{.cpp}
const int32_t error = ragePhoto.error(); const int32_t error = ragePhoto.error();
@ -164,6 +117,110 @@ default:
Available error codes: RagePhoto::Error Available error codes: RagePhoto::Error
<h3 id="api_c">C API</h3>
<h4 id="c_include">Including RagePhoto</h4>
\code{.c}
#include <RagePhoto.h>
\endcode
Initializing a RagePhoto instance
\code{.c}
ragephoto_t instance = ragephoto_open();
\endcode
Destroying a RagePhoto instance
\code{.c}
ragephoto_close(instance);
\endcode
<h4 id="c_loading">Loading a Photo</h4>
From a file using ragephoto_loadfile(ragephoto_t, const char*)
\code{.c}
const bool loaded = ragephoto_loadfile(instance, "PGTA5123456789");
\endcode
From a char* using ragephoto_load(ragephoto_t, const char*, size_t)
\code{.c}
const bool loaded = ragephoto_load(instance, data, size);
\endcode
<h4 id="c_using">Querying Photo data</h4>
\code{.c}
// Returns the Photo Format
const uint32_t format = ragephoto_getphotoformat(instance);
// Returns the JPEG as const char*
const char* jpeg = ragephoto_getphotojpeg(instance);
const uint32_t size = ragephoto_getphotosize(instance);
// Returns the JSON
const char* json = ragephoto_getphotojson(instance);
// Returns the Title
const char* title = ragephoto_getphototitle(instance);
\endcode
Detecting if Photo is from GTA V or RDR 2
\code{.c}
switch (ragephoto_getphotoformat(instance)) {
case RAGEPHOTO_FORMAT_GTA5:
printf("GTA V format detected\n");
break;
case RAGEPHOTO_FORMAT_RDR2:
printf("RDR 2 format detected\n");
break;
default:
printf("Unknown format detected\n");
}
\endcode
Saving the JPEG from a Photo
\code{.c}
// Example saveJpeg function
bool saveJpeg(ragephoto_t instance, const char* filename) {
FILE* file = fopen(filename, "wb");
if (!file)
return false;
const uint32_t jpegSize = ragephoto_getphotosize(instance);
const size_t writeSize = fwrite(ragephoto_getphotojpeg(instance), sizeof(char), jpegSize, file);
fclose(file);
return (jpegSize == writeSize);
}
// Using the saveJpeg function
const bool saved = saveJpeg(instance, "photo.jpg");
\endcode
<h4 id="c_error">Querying last error</h4>
\code{.c}
const int32_t error = ragephoto_error(instance);
switch (error) {
case RAGEPHOTO_ERROR_NOFORMATIDENTIFIER:
printf("No format identifier\n");
break;
case RAGEPHOTO_ERROR_INCOMPATIBLEFORMAT:
printf("Incompatible format\n");
break;
// Detect for more errors here...
case RAGEPHOTO_ERROR_NOERROR:
printf("No error detected\n");
break;
default:
printf("Unknown error detected\n");
}
\endcode
<h3 id="cmake">Including libragephoto in a CMake project</h3> <h3 id="cmake">Including libragephoto in a CMake project</h3>
<h4 id="cmake_pkgconfig">Using PkgConfig</h4> <h4 id="cmake_pkgconfig">Using PkgConfig</h4>

View file

@ -16,6 +16,10 @@
* responsible for anything with use of the software, you are self responsible. * responsible for anything with use of the software, you are self responsible.
*****************************************************************************/ *****************************************************************************/
/** RagePhoto C API header file
* \file RagePhoto.h
*/
#ifndef RAGEPHOTO_H #ifndef RAGEPHOTO_H
#define RAGEPHOTO_H #define RAGEPHOTO_H
@ -28,33 +32,37 @@
extern "C" { extern "C" {
#endif // __cplusplus #endif // __cplusplus
/** C API for RagePhoto. /** RagePhoto typedef for C instance/C++ object.
* \file RagePhoto.h * \memberof RagePhotoInstance
*/ */
/** RagePhoto C instance/C++ class typedef. */
typedef void* ragephoto_t; typedef void* ragephoto_t;
/** Opens a \p ragephoto_t instance. */ /** Opens a \p ragephoto_t instance.
* \memberof RagePhotoInstance
*/
LIBRAGEPHOTO_C_PUBLIC ragephoto_t ragephoto_open(); LIBRAGEPHOTO_C_PUBLIC ragephoto_t ragephoto_open();
/** Add a custom defined RagePhotoFormatParser. /** Add a custom defined RagePhotoFormatParser.
* \memberof RagePhotoInstance
* \param instance \p ragephoto_t instance * \param instance \p ragephoto_t instance
* \param rp_parser RagePhotoFormatParser parser to add * \param rp_parser Parser to add
*/ */
LIBRAGEPHOTO_C_PUBLIC void ragephoto_addparser(ragephoto_t instance, RagePhotoFormatParser *rp_parser); LIBRAGEPHOTO_C_PUBLIC void ragephoto_addparser(ragephoto_t instance, RagePhotoFormatParser *rp_parser);
/** Resets the RagePhotoData object to default values. /** Resets the Data object to default values.
* \memberof RagePhotoInstance
* \param instance \p ragephoto_t instance * \param instance \p ragephoto_t instance
*/ */
LIBRAGEPHOTO_C_PUBLIC void ragephoto_clear(ragephoto_t instance); LIBRAGEPHOTO_C_PUBLIC void ragephoto_clear(ragephoto_t instance);
/** Resets the RagePhotoData object to default values. /** Resets the Data object to default values.
* \param rp_data RagePhotoData object * \memberof RagePhotoData
* \param rp_data Data object
*/ */
LIBRAGEPHOTO_C_PUBLIC void ragephotodata_clear(RagePhotoData *rp_data); LIBRAGEPHOTO_C_PUBLIC void ragephotodata_clear(RagePhotoData *rp_data);
/** Loads a Photo from a const char*. /** Loads a Photo from a const char*.
* \memberof RagePhotoInstance
* \param instance \p ragephoto_t instance * \param instance \p ragephoto_t instance
* \param data Photo data * \param data Photo data
* \param size Photo data size * \param size Photo data size
@ -62,78 +70,98 @@ LIBRAGEPHOTO_C_PUBLIC void ragephotodata_clear(RagePhotoData *rp_data);
LIBRAGEPHOTO_C_PUBLIC bool ragephoto_load(ragephoto_t instance, const char *data, size_t size); LIBRAGEPHOTO_C_PUBLIC bool ragephoto_load(ragephoto_t instance, const char *data, size_t size);
/** Loads a Photo from a const char*. /** Loads a Photo from a const char*.
* \param rp_data RagePhotoData object * \memberof RagePhotoData
* \param rp_parser RagePhotoFormatParser parser array * \param rp_data Data object
* \param rp_parser Parser array
* \param data Photo data * \param data Photo data
* \param size Photo data size * \param size Photo data size
*/ */
LIBRAGEPHOTO_C_PUBLIC bool ragephotodata_load(RagePhotoData *rp_data, RagePhotoFormatParser *rp_parser, const char *data, size_t size); LIBRAGEPHOTO_C_PUBLIC bool ragephotodata_load(RagePhotoData *rp_data, RagePhotoFormatParser *rp_parser, const char *data, size_t size);
/** Loads a Photo from a file. /** Loads a Photo from a file.
* \memberof RagePhotoInstance
* \param instance \p ragephoto_t instance * \param instance \p ragephoto_t instance
* \param filename File to load * \param filename File to load
*/ */
LIBRAGEPHOTO_C_PUBLIC bool ragephoto_loadfile(ragephoto_t instance, const char *filename); LIBRAGEPHOTO_C_PUBLIC bool ragephoto_loadfile(ragephoto_t instance, const char *filename);
/** Returns the last error occurred. /** Returns the last error occurred.
* \memberof RagePhotoInstance
* \param instance \p ragephoto_t instance * \param instance \p ragephoto_t instance
*/ */
LIBRAGEPHOTO_C_PUBLIC int32_t ragephoto_error(ragephoto_t instance); LIBRAGEPHOTO_C_PUBLIC int32_t ragephoto_error(ragephoto_t instance);
/** Returns the GTA V default Photo Buffer Size. */ /** Returns the GTA V default Photo Buffer Size.
* \relates RagePhotoInstance
*/
LIBRAGEPHOTO_C_PUBLIC uint32_t ragephoto_defpbuf_gta5(); LIBRAGEPHOTO_C_PUBLIC uint32_t ragephoto_defpbuf_gta5();
/** Returns the RDR 2 default Photo Buffer Size. */ /** Returns the RDR 2 default Photo Buffer Size.
* \relates RagePhotoInstance
*/
LIBRAGEPHOTO_C_PUBLIC uint32_t ragephoto_defpbuf_rdr2(); LIBRAGEPHOTO_C_PUBLIC uint32_t ragephoto_defpbuf_rdr2();
/** Returns the GTA V Photo Format. */ /** Returns the GTA V Photo Format.
* \relates RagePhotoInstance
*/
LIBRAGEPHOTO_C_PUBLIC uint32_t ragephoto_format_gta5(); LIBRAGEPHOTO_C_PUBLIC uint32_t ragephoto_format_gta5();
/** Returns the RDR 2 Photo Format. */ /** Returns the RDR 2 Photo Format.
* \relates RagePhotoInstance
*/
LIBRAGEPHOTO_C_PUBLIC uint32_t ragephoto_format_rdr2(); LIBRAGEPHOTO_C_PUBLIC uint32_t ragephoto_format_rdr2();
/** Returns the internal RagePhotoData object. /** Returns the internal Data object.
* \memberof RagePhotoInstance
* \param instance \p ragephoto_t instance * \param instance \p ragephoto_t instance
*/ */
LIBRAGEPHOTO_C_PUBLIC RagePhotoData* ragephoto_getphotodata(ragephoto_t instance); LIBRAGEPHOTO_C_PUBLIC RagePhotoData* ragephoto_getphotodata(ragephoto_t instance);
/** Returns the Photo description. /** Returns the Photo description.
* \memberof RagePhotoInstance
* \param instance \p ragephoto_t instance * \param instance \p ragephoto_t instance
*/ */
LIBRAGEPHOTO_C_PUBLIC const char* ragephoto_getphotodesc(ragephoto_t instance); LIBRAGEPHOTO_C_PUBLIC const char* ragephoto_getphotodesc(ragephoto_t instance);
/** Returns the Photo Format (GTA V or RDR 2). /** Returns the Photo Format (GTA V or RDR 2).
* \memberof RagePhotoInstance
* \param instance \p ragephoto_t instance * \param instance \p ragephoto_t instance
*/ */
LIBRAGEPHOTO_C_PUBLIC uint32_t ragephoto_getphotoformat(ragephoto_t instance); LIBRAGEPHOTO_C_PUBLIC uint32_t ragephoto_getphotoformat(ragephoto_t instance);
/** Returns the Photo JPEG data. /** Returns the Photo JPEG data.
* \memberof RagePhotoInstance
* \param instance \p ragephoto_t instance * \param instance \p ragephoto_t instance
*/ */
LIBRAGEPHOTO_C_PUBLIC const char* ragephoto_getphotojpeg(ragephoto_t instance); LIBRAGEPHOTO_C_PUBLIC const char* ragephoto_getphotojpeg(ragephoto_t instance);
/** Returns the Photo JSON data. /** Returns the Photo JSON data.
* \memberof RagePhotoInstance
* \param instance \p ragephoto_t instance * \param instance \p ragephoto_t instance
*/ */
LIBRAGEPHOTO_C_PUBLIC const char* ragephoto_getphotojson(ragephoto_t instance); LIBRAGEPHOTO_C_PUBLIC const char* ragephoto_getphotojson(ragephoto_t instance);
/** Returns the Photo header. /** Returns the Photo header.
* \memberof RagePhotoInstance
* \param instance \p ragephoto_t instance * \param instance \p ragephoto_t instance
*/ */
LIBRAGEPHOTO_C_PUBLIC const char* ragephoto_getphotoheader(ragephoto_t instance); LIBRAGEPHOTO_C_PUBLIC const char* ragephoto_getphotoheader(ragephoto_t instance);
/** Returns the Photo JPEG sign. /** Returns the Photo JPEG sign.
* \memberof RagePhotoInstance
* \param instance \p ragephoto_t instance * \param instance \p ragephoto_t instance
*/ */
LIBRAGEPHOTO_C_PUBLIC uint64_t ragephoto_getphotosign(ragephoto_t instance); LIBRAGEPHOTO_C_PUBLIC uint64_t ragephoto_getphotosign(ragephoto_t instance);
/** Returns the Photo JPEG sign. /** Returns the Photo JPEG sign.
* \memberof RagePhotoInstance
* \param instance \p ragephoto_t instance * \param instance \p ragephoto_t instance
* \param photoFormat Photo Format (GTA V or RDR 2) * \param photoFormat Photo Format (GTA V or RDR 2)
*/ */
LIBRAGEPHOTO_C_PUBLIC uint64_t ragephoto_getphotosignf(ragephoto_t instance, uint32_t photoFormat); LIBRAGEPHOTO_C_PUBLIC uint64_t ragephoto_getphotosignf(ragephoto_t instance, uint32_t photoFormat);
/** Returns the Photo JPEG sign as string. /** Returns the Photo JPEG sign as string.
* \memberof RagePhotoInstance
* \param instance \p ragephoto_t instance * \param instance \p ragephoto_t instance
* \param data String data * \param data String data
* \param size String size * \param size String size
@ -141,6 +169,7 @@ LIBRAGEPHOTO_C_PUBLIC uint64_t ragephoto_getphotosignf(ragephoto_t instance, uin
LIBRAGEPHOTO_C_PUBLIC void ragephoto_getphotosigns(ragephoto_t instance, char *data, size_t size); LIBRAGEPHOTO_C_PUBLIC void ragephoto_getphotosigns(ragephoto_t instance, char *data, size_t size);
/** Returns the Photo JPEG sign as string. /** Returns the Photo JPEG sign as string.
* \memberof RagePhotoInstance
* \param instance \p ragephoto_t instance * \param instance \p ragephoto_t instance
* \param data String data * \param data String data
* \param size String size * \param size String size
@ -149,64 +178,75 @@ LIBRAGEPHOTO_C_PUBLIC void ragephoto_getphotosigns(ragephoto_t instance, char *d
LIBRAGEPHOTO_C_PUBLIC void ragephoto_getphotosignsf(ragephoto_t instance, char *data, size_t size, uint32_t photoFormat); LIBRAGEPHOTO_C_PUBLIC void ragephoto_getphotosignsf(ragephoto_t instance, char *data, size_t size, uint32_t photoFormat);
/** Returns the Photo JPEG sign. /** Returns the Photo JPEG sign.
* \param rp_data RagePhotoData object * \memberof RagePhotoData
* \param rp_data Data object
*/ */
LIBRAGEPHOTO_C_PUBLIC uint64_t ragephotodata_getphotosign(RagePhotoData *rp_data); LIBRAGEPHOTO_C_PUBLIC uint64_t ragephotodata_getphotosign(RagePhotoData *rp_data);
/** Returns the Photo JPEG sign. /** Returns the Photo JPEG sign.
* \param rp_data RagePhotoData object * \memberof RagePhotoData
* \param rp_data Data object
* \param photoFormat Photo Format (GTA V or RDR 2) * \param photoFormat Photo Format (GTA V or RDR 2)
*/ */
LIBRAGEPHOTO_C_PUBLIC uint64_t ragephotodata_getphotosignf(RagePhotoData *rp_data, uint32_t photoFormat); LIBRAGEPHOTO_C_PUBLIC uint64_t ragephotodata_getphotosignf(RagePhotoData *rp_data, uint32_t photoFormat);
/** Returns the Photo JPEG data size. /** Returns the Photo JPEG data size.
* \memberof RagePhotoInstance
* \param instance \p ragephoto_t instance * \param instance \p ragephoto_t instance
*/ */
LIBRAGEPHOTO_C_PUBLIC uint32_t ragephoto_getphotosize(ragephoto_t instance); LIBRAGEPHOTO_C_PUBLIC uint32_t ragephoto_getphotosize(ragephoto_t instance);
/** Returns the Photo title. /** Returns the Photo title.
* \memberof RagePhotoInstance
* \param instance \p ragephoto_t instance * \param instance \p ragephoto_t instance
*/ */
LIBRAGEPHOTO_C_PUBLIC const char* ragephoto_getphototitle(ragephoto_t instance); LIBRAGEPHOTO_C_PUBLIC const char* ragephoto_getphototitle(ragephoto_t instance);
/** Returns the Photo save file size. /** Returns the Photo save file size.
* \memberof RagePhotoInstance
* \param instance \p ragephoto_t instance * \param instance \p ragephoto_t instance
*/ */
LIBRAGEPHOTO_C_PUBLIC size_t ragephoto_getsavesize(ragephoto_t instance); LIBRAGEPHOTO_C_PUBLIC size_t ragephoto_getsavesize(ragephoto_t instance);
/** Returns the Photo save file size. /** Returns the Photo save file size.
* \param rp_data RagePhotoData object * \memberof RagePhotoData
* \param rp_parser RagePhotoFormatParser parser array * \param rp_data Data object
* \param rp_parser Parser array
*/ */
LIBRAGEPHOTO_C_PUBLIC size_t ragephotodata_getsavesize(RagePhotoData *rp_data, RagePhotoFormatParser *rp_parser); LIBRAGEPHOTO_C_PUBLIC size_t ragephotodata_getsavesize(RagePhotoData *rp_data, RagePhotoFormatParser *rp_parser);
/** Returns the Photo save file size. /** Returns the Photo save file size.
* \memberof RagePhotoInstance
* \param instance \p ragephoto_t instance * \param instance \p ragephoto_t instance
* \param photoFormat Photo Format (GTA V or RDR 2) * \param photoFormat Photo Format (GTA V or RDR 2)
*/ */
LIBRAGEPHOTO_C_PUBLIC size_t ragephoto_getsavesizef(ragephoto_t instance, uint32_t photoFormat); LIBRAGEPHOTO_C_PUBLIC size_t ragephoto_getsavesizef(ragephoto_t instance, uint32_t photoFormat);
/** Returns the Photo save file size. /** Returns the Photo save file size.
* \param rp_data RagePhotoData object * \memberof RagePhotoData
* \param rp_parser RagePhotoFormatParser parser array * \param rp_data Data object
* \param rp_parser Parser array
* \param photoFormat Photo Format (GTA V or RDR 2) * \param photoFormat Photo Format (GTA V or RDR 2)
*/ */
LIBRAGEPHOTO_C_PUBLIC size_t ragephotodata_getsavesizef(RagePhotoData *rp_data, RagePhotoFormatParser *rp_parser, uint32_t photoFormat); LIBRAGEPHOTO_C_PUBLIC size_t ragephotodata_getsavesizef(RagePhotoData *rp_data, RagePhotoFormatParser *rp_parser, uint32_t photoFormat);
/** Saves a Photo to a char*. /** Saves a Photo to a char*.
* \memberof RagePhotoInstance
* \param instance \p ragephoto_t instance * \param instance \p ragephoto_t instance
* \param data Photo data * \param data Photo data
*/ */
LIBRAGEPHOTO_C_PUBLIC bool ragephoto_save(ragephoto_t instance, char *data); LIBRAGEPHOTO_C_PUBLIC bool ragephoto_save(ragephoto_t instance, char *data);
/** Saves a Photo to a char*. /** Saves a Photo to a char*.
* \param rp_data RagePhotoData object * \memberof RagePhotoData
* \param rp_parser RagePhotoFormatParser parser array * \param rp_data Data object
* \param rp_parser Parser array
* \param data Photo data * \param data Photo data
*/ */
LIBRAGEPHOTO_C_PUBLIC bool ragephotodata_save(RagePhotoData *rp_data, RagePhotoFormatParser *rp_parser, char *data); LIBRAGEPHOTO_C_PUBLIC bool ragephotodata_save(RagePhotoData *rp_data, RagePhotoFormatParser *rp_parser, char *data);
/** Saves a Photo to a char*. /** Saves a Photo to a char*.
* \memberof RagePhotoInstance
* \param instance \p ragephoto_t instance * \param instance \p ragephoto_t instance
* \param data Photo data * \param data Photo data
* \param photoFormat Photo Format (GTA V or RDR 2) * \param photoFormat Photo Format (GTA V or RDR 2)
@ -214,20 +254,23 @@ LIBRAGEPHOTO_C_PUBLIC bool ragephotodata_save(RagePhotoData *rp_data, RagePhotoF
LIBRAGEPHOTO_C_PUBLIC bool ragephoto_savef(ragephoto_t instance, char *data, uint32_t photoFormat); LIBRAGEPHOTO_C_PUBLIC bool ragephoto_savef(ragephoto_t instance, char *data, uint32_t photoFormat);
/** Saves a Photo to a char*. /** Saves a Photo to a char*.
* \param rp_data RagePhotoData object * \memberof RagePhotoData
* \param rp_parser RagePhotoFormatParser parser array * \param rp_data Data object
* \param rp_parser Parser array
* \param data Photo data * \param data Photo data
* \param photoFormat Photo Format (GTA V or RDR 2) * \param photoFormat Photo Format (GTA V or RDR 2)
*/ */
LIBRAGEPHOTO_C_PUBLIC bool ragephotodata_savef(RagePhotoData *rp_data, RagePhotoFormatParser *rp_parser, char *data, uint32_t photoFormat); LIBRAGEPHOTO_C_PUBLIC bool ragephotodata_savef(RagePhotoData *rp_data, RagePhotoFormatParser *rp_parser, char *data, uint32_t photoFormat);
/** Saves a Photo to a file. /** Saves a Photo to a file.
* \memberof RagePhotoInstance
* \param instance \p ragephoto_t instance * \param instance \p ragephoto_t instance
* \param filename File to save * \param filename File to save
*/ */
LIBRAGEPHOTO_C_PUBLIC bool ragephoto_savefile(ragephoto_t instance, const char *filename); LIBRAGEPHOTO_C_PUBLIC bool ragephoto_savefile(ragephoto_t instance, const char *filename);
/** Saves a Photo to a file. /** Saves a Photo to a file.
* \memberof RagePhotoInstance
* \param instance \p ragephoto_t instance * \param instance \p ragephoto_t instance
* \param filename File to save * \param filename File to save
* \param photoFormat Photo Format (GTA V or RDR 2) * \param photoFormat Photo Format (GTA V or RDR 2)
@ -235,38 +278,45 @@ LIBRAGEPHOTO_C_PUBLIC bool ragephoto_savefile(ragephoto_t instance, const char *
LIBRAGEPHOTO_C_PUBLIC bool ragephoto_savefilef(ragephoto_t instance, const char *filename, uint32_t photoFormat); LIBRAGEPHOTO_C_PUBLIC bool ragephoto_savefilef(ragephoto_t instance, const char *filename, uint32_t photoFormat);
/** Sets all cross-format Buffer to default size. /** Sets all cross-format Buffer to default size.
* \memberof RagePhotoInstance
* \param instance \p ragephoto_t instance * \param instance \p ragephoto_t instance
*/ */
LIBRAGEPHOTO_C_PUBLIC void ragephoto_setbufferdefault(ragephoto_t instance); LIBRAGEPHOTO_C_PUBLIC void ragephoto_setbufferdefault(ragephoto_t instance);
/** Sets all cross-format Buffer to default size. /** Sets all cross-format Buffer to default size.
* \param rp_data RagePhotoData object * \memberof RagePhotoData
* \param rp_data Data object
*/ */
LIBRAGEPHOTO_C_PUBLIC void ragephotodata_setbufferdefault(RagePhotoData *rp_data); LIBRAGEPHOTO_C_PUBLIC void ragephotodata_setbufferdefault(RagePhotoData *rp_data);
/** Moves all Buffer offsets to correct position. /** Moves all Buffer offsets to correct position.
* \memberof RagePhotoInstance
* \param instance \p ragephoto_t instance * \param instance \p ragephoto_t instance
*/ */
LIBRAGEPHOTO_C_PUBLIC void ragephoto_setbufferoffsets(ragephoto_t instance); LIBRAGEPHOTO_C_PUBLIC void ragephoto_setbufferoffsets(ragephoto_t instance);
/** Moves all Buffer offsets to correct position. /** Moves all Buffer offsets to correct position.
* \param rp_data RagePhotoData object * \memberof RagePhotoData
* \param rp_data Data object
*/ */
LIBRAGEPHOTO_C_PUBLIC void ragephotodata_setbufferoffsets(RagePhotoData *rp_data); LIBRAGEPHOTO_C_PUBLIC void ragephotodata_setbufferoffsets(RagePhotoData *rp_data);
/** Sets the internal RagePhotoData object. /** Sets the internal RagePhotoData object.
* \memberof RagePhotoInstance
* \param instance \p ragephoto_t instance * \param instance \p ragephoto_t instance
* \param rp_data RagePhotoData object being set * \param rp_data Data object used to replace
*/ */
LIBRAGEPHOTO_C_PUBLIC bool ragephoto_setphotodata(ragephoto_t instance, RagePhotoData *rp_data); LIBRAGEPHOTO_C_PUBLIC bool ragephoto_setphotodata(ragephoto_t instance, RagePhotoData *rp_data);
/** Copies RagePhotoData object to internal RagePhotoData object. /** Copies RagePhotoData object to internal RagePhotoData object.
* \memberof RagePhotoInstance
* \param instance \p ragephoto_t instance * \param instance \p ragephoto_t instance
* \param rp_data RagePhotoData object being copied * \param rp_data Data object used to copy
*/ */
LIBRAGEPHOTO_C_PUBLIC bool ragephoto_setphotodatac(ragephoto_t instance, RagePhotoData *rp_data); LIBRAGEPHOTO_C_PUBLIC bool ragephoto_setphotodatac(ragephoto_t instance, RagePhotoData *rp_data);
/** Sets the Photo description. /** Sets the Photo description.
* \memberof RagePhotoInstance
* \param instance \p ragephoto_t instance * \param instance \p ragephoto_t instance
* \param description Description * \param description Description
* \param bufferSize Description buffer size * \param bufferSize Description buffer size
@ -276,12 +326,14 @@ LIBRAGEPHOTO_C_PUBLIC bool ragephoto_setphotodatac(ragephoto_t instance, RagePho
LIBRAGEPHOTO_C_PUBLIC void ragephoto_setphotodesc(ragephoto_t instance, const char *description, uint32_t bufferSize); LIBRAGEPHOTO_C_PUBLIC void ragephoto_setphotodesc(ragephoto_t instance, const char *description, uint32_t bufferSize);
/** Sets the Photo Format (GTA V or RDR 2). /** Sets the Photo Format (GTA V or RDR 2).
* \memberof RagePhotoInstance
* \param instance \p ragephoto_t instance * \param instance \p ragephoto_t instance
* \param photoFormat Photo Format (GTA V or RDR 2) * \param photoFormat Photo Format (GTA V or RDR 2)
*/ */
LIBRAGEPHOTO_C_PUBLIC void ragephoto_setphotoformat(ragephoto_t instance, uint32_t photoFormat); LIBRAGEPHOTO_C_PUBLIC void ragephoto_setphotoformat(ragephoto_t instance, uint32_t photoFormat);
/** Sets the Photo JPEG data. /** Sets the Photo JPEG data.
* \memberof RagePhotoInstance
* \param instance \p ragephoto_t instance * \param instance \p ragephoto_t instance
* \param data JPEG data * \param data JPEG data
* \param size JPEG data size * \param size JPEG data size
@ -292,6 +344,7 @@ LIBRAGEPHOTO_C_PUBLIC void ragephoto_setphotoformat(ragephoto_t instance, uint32
LIBRAGEPHOTO_C_PUBLIC bool ragephoto_setphotojpeg(ragephoto_t instance, const char *data, uint32_t size, uint32_t bufferSize); LIBRAGEPHOTO_C_PUBLIC bool ragephoto_setphotojpeg(ragephoto_t instance, const char *data, uint32_t size, uint32_t bufferSize);
/** Sets the Photo JSON data. /** Sets the Photo JSON data.
* \memberof RagePhotoInstance
* \param instance \p ragephoto_t instance * \param instance \p ragephoto_t instance
* \param json JSON data * \param json JSON data
* \param bufferSize JSON data buffer size * \param bufferSize JSON data buffer size
@ -300,13 +353,18 @@ LIBRAGEPHOTO_C_PUBLIC bool ragephoto_setphotojpeg(ragephoto_t instance, const ch
*/ */
LIBRAGEPHOTO_C_PUBLIC void ragephoto_setphotojson(ragephoto_t instance, const char *json, uint32_t bufferSize); LIBRAGEPHOTO_C_PUBLIC void ragephoto_setphotojson(ragephoto_t instance, const char *json, uint32_t bufferSize);
/** Sets the Photo header. */ /** Sets the Photo header.
* \memberof RagePhotoInstance
*/
LIBRAGEPHOTO_C_PUBLIC void ragephoto_setphotoheader(ragephoto_t instance, const char *header, uint32_t headerSum); LIBRAGEPHOTO_C_PUBLIC void ragephoto_setphotoheader(ragephoto_t instance, const char *header, uint32_t headerSum);
/** Sets the Photo header. (RDR 2) */ /** Sets the Photo header. (RDR 2)
* \memberof RagePhotoInstance
*/
LIBRAGEPHOTO_C_PUBLIC void ragephoto_setphotoheader2(ragephoto_t instance, const char *header, uint32_t headerSum, uint32_t headerSum2); LIBRAGEPHOTO_C_PUBLIC void ragephoto_setphotoheader2(ragephoto_t instance, const char *header, uint32_t headerSum, uint32_t headerSum2);
/** Sets the Photo title. /** Sets the Photo title.
* \memberof RagePhotoInstance
* \param instance \p ragephoto_t instance * \param instance \p ragephoto_t instance
* \param title Title * \param title Title
* \param bufferSize Title buffer size * \param bufferSize Title buffer size
@ -316,11 +374,14 @@ LIBRAGEPHOTO_C_PUBLIC void ragephoto_setphotoheader2(ragephoto_t instance, const
LIBRAGEPHOTO_C_PUBLIC void ragephoto_setphototitle(ragephoto_t instance, const char *title, uint32_t bufferSize); LIBRAGEPHOTO_C_PUBLIC void ragephoto_setphototitle(ragephoto_t instance, const char *title, uint32_t bufferSize);
/** Closes a \p ragephoto_t instance. /** Closes a \p ragephoto_t instance.
* \memberof RagePhotoInstance
* \param instance \p ragephoto_t instance * \param instance \p ragephoto_t instance
*/ */
LIBRAGEPHOTO_C_PUBLIC void ragephoto_close(ragephoto_t instance); LIBRAGEPHOTO_C_PUBLIC void ragephoto_close(ragephoto_t instance);
/** Returns the library version. */ /** Returns the library version.
* \relates RagePhotoInstance
*/
LIBRAGEPHOTO_C_PUBLIC const char* ragephoto_version(); LIBRAGEPHOTO_C_PUBLIC const char* ragephoto_version();
#ifdef __cplusplus #ifdef __cplusplus

View file

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* libragephoto RAGE Photo Parser * libragephoto RAGE Photo Parser
* Copyright (C) 2021-2023 Syping * Copyright (C) 2021-2024 Syping
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -70,10 +70,12 @@ typedef struct RagePhotoFormatParser {
ragephoto_saveszfunc_t funcSaveSz; /**< Pointer to saveSize function */ ragephoto_saveszfunc_t funcSaveSz; /**< Pointer to saveSize function */
} RagePhotoFormatParser; } RagePhotoFormatParser;
/** RagePhoto instance struct for storing data and format parser pointer. */ /** RagePhoto instance struct for storing data and format parser pointer.
* \struct RagePhotoInstance RagePhoto.h
*/
typedef struct RagePhotoInstance { typedef struct RagePhotoInstance {
RagePhotoData *data; /**< Pointer for data */ RagePhotoData *data; /**< Pointer for internal data */
RagePhotoFormatParser *parser; /**< Pointer for format parser */ RagePhotoFormatParser *parser; /**< Pointer for internal format parser */
} RagePhotoInstance; } RagePhotoInstance;
/* RagePhoto default sizes */ /* RagePhoto default sizes */

View file

@ -28,6 +28,7 @@ namespace ragephoto_c {
/** /**
* \brief GTA V and RDR 2 Photo Parser (C API wrapper). * \brief GTA V and RDR 2 Photo Parser (C API wrapper).
* \class ragephoto_c::photo RagePhoto.hpp RagePhoto
*/ */
class photo class photo
{ {

View file

@ -31,6 +31,7 @@ namespace ragephoto {
/** /**
* \brief GTA V and RDR 2 Photo Parser. * \brief GTA V and RDR 2 Photo Parser.
* \class ragephoto::photo RagePhoto.hpp RagePhoto
*/ */
class LIBRAGEPHOTO_CXX_PUBLIC photo class LIBRAGEPHOTO_CXX_PUBLIC photo
{ {