diff --git a/src/core/RagePhoto.c b/src/core/RagePhoto.c index 27e7a3b..198a2c3 100644 --- a/src/core/RagePhoto.c +++ b/src/core/RagePhoto.c @@ -984,6 +984,15 @@ bool ragephotodata_savef(RagePhotoData *rp_data, RagePhotoFormatParser *rp_parse return false; #endif } + else if (photoFormat == RAGEPHOTO_FORMAT_JPEG) { + const size_t length = ragephotodata_getsavesizef(rp_data, NULL, photoFormat); + size_t pos = 0; + + writeBuffer(rp_data->jpeg, data, &pos, length, rp_data->jpegSize); + + rp_data->error = RAGEPHOTO_ERROR_NOERROR; // 255 + return true; + } else if (rp_parser) { RagePhotoFormatParser n_parser; memset(&n_parser, 0, sizeof(RagePhotoFormatParser)); @@ -1049,6 +1058,8 @@ size_t ragephotodata_getsavesizef(RagePhotoData *rp_data, RagePhotoFormatParser return (rp_data->jpegBuffer + rp_data->jsonBuffer + rp_data->titlBuffer + rp_data->descBuffer + RAGEPHOTO_GTA5_HEADERSIZE + UINT32_C(56)); else if (photoFormat == RAGEPHOTO_FORMAT_RDR2) return (rp_data->jpegBuffer + rp_data->jsonBuffer + rp_data->titlBuffer + rp_data->descBuffer + RAGEPHOTO_RDR2_HEADERSIZE + UINT32_C(56)); + else if (photoFormat == RAGEPHOTO_FORMAT_JPEG) + return (rp_data->jpegSize); else if (rp_parser) { RagePhotoFormatParser n_parser; memset(&n_parser, 0, sizeof(RagePhotoFormatParser)); diff --git a/src/core/RagePhoto.cpp b/src/core/RagePhoto.cpp index 6e51099..5d15ebc 100644 --- a/src/core/RagePhoto.cpp +++ b/src/core/RagePhoto.cpp @@ -939,6 +939,15 @@ bool RagePhoto::save(char *data, uint32_t photoFormat, RagePhotoData *rp_data, R return false; #endif } + else if (photoFormat == PhotoFormat::JPEG) { + const size_t length = saveSize(photoFormat, rp_data, nullptr); + size_t pos = 0; + + writeBuffer(rp_data->jpeg, data, &pos, length, rp_data->jpegSize); + + rp_data->error = Error::NoError; // 255 + return true; + } else if (rp_parser) { RagePhotoFormatParser n_parser[1]{}; for (size_t i = 0; memcmp(&n_parser[0], &rp_parser[i], sizeof(RagePhotoFormatParser)); i++) { @@ -1024,6 +1033,8 @@ size_t RagePhoto::saveSize(uint32_t photoFormat, RagePhotoData *rp_data, RagePho return (rp_data->jpegBuffer + rp_data->jsonBuffer + rp_data->titlBuffer + rp_data->descBuffer + GTA5_HEADERSIZE + UINT32_C(56)); else if (photoFormat == PhotoFormat::RDR2) return (rp_data->jpegBuffer + rp_data->jsonBuffer + rp_data->titlBuffer + rp_data->descBuffer + RDR2_HEADERSIZE + UINT32_C(56)); + else if (photoFormat == PhotoFormat::JPEG) + return (rp_data->jpegSize); else if (rp_parser) { RagePhotoFormatParser n_parser[1]{}; for (size_t i = 0; memcmp(&n_parser[0], &rp_parser[i], sizeof(RagePhotoFormatParser)); i++) { diff --git a/src/core/RagePhotoTypedefs.h b/src/core/RagePhotoTypedefs.h index 5a3cabb..c21a2ef 100644 --- a/src/core/RagePhotoTypedefs.h +++ b/src/core/RagePhotoTypedefs.h @@ -1,6 +1,6 @@ /***************************************************************************** * libragephoto RAGE Photo Parser -* Copyright (C) 2021-2024 Syping +* Copyright (C) 2021-2025 Syping * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: @@ -136,6 +136,7 @@ typedef enum RagePhotoLibraryFlag { #define RAGEPHOTO_ERROR_UNINITIALISED INT32_C(0) /**< Uninitialised, file access failed */ /* RagePhoto formats */ +#define RAGEPHOTO_FORMAT_JPEG UINT32_C(0xE0FFD8FF) /**< JPEG Photo Format */ #define RAGEPHOTO_FORMAT_GTA5 UINT32_C(0x01000000) /**< GTA V Photo Format */ #define RAGEPHOTO_FORMAT_RDR2 UINT32_C(0x04000000) /**< RDR 2 Photo Format */ diff --git a/src/core/ragephoto_c.hpp b/src/core/ragephoto_c.hpp index b836cb8..9e73c07 100644 --- a/src/core/ragephoto_c.hpp +++ b/src/core/ragephoto_c.hpp @@ -1,6 +1,6 @@ /***************************************************************************** * libragephoto RAGE Photo Parser -* Copyright (C) 2021-2024 Syping +* Copyright (C) 2021-2025 Syping * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: @@ -41,7 +41,7 @@ public: DEFAULT_JSONBUFFER = RAGEPHOTO_DEFAULT_JSONBUFFER, /**< Default JSON Buffer Size */ DEFAULT_TITLBUFFER = RAGEPHOTO_DEFAULT_TITLBUFFER, /**< Default Title Buffer Size */ GTA5_HEADERSIZE = RAGEPHOTO_GTA5_HEADERSIZE, /**< GTA V Header Size */ - RDR2_HEADERSIZE = RAGEPHOTO_RDR2_HEADERSIZE, /**< RDR 2 Header Size */ + RDR2_HEADERSIZE = RAGEPHOTO_RDR2_HEADERSIZE /**< RDR 2 Header Size */ }; /** Parsing and set errors */ enum Error : int32_t { @@ -85,17 +85,18 @@ public: TitleReadError = RAGEPHOTO_ERROR_TITLEREADERROR, /**< Title can't be read */ UnicodeInitError = RAGEPHOTO_ERROR_UNICODEINITERROR, /**< Failed to initialise Unicode decoder */ UnicodeHeaderError = RAGEPHOTO_ERROR_UNICODEHEADERERROR, /**< Header can't be encoded/decoded successfully */ - Uninitialised = RAGEPHOTO_ERROR_UNINITIALISED, /**< Uninitialised, file access failed */ + Uninitialised = RAGEPHOTO_ERROR_UNINITIALISED /**< Uninitialised, file access failed */ }; /** Photo Formats */ enum PhotoFormat : uint32_t { + JPEG = RAGEPHOTO_FORMAT_JPEG, /**< JPEG Photo Format */ GTA5 = RAGEPHOTO_FORMAT_GTA5, /**< GTA V Photo Format */ - RDR2 = RAGEPHOTO_FORMAT_RDR2, /**< RDR 2 Photo Format */ + RDR2 = RAGEPHOTO_FORMAT_RDR2 /**< RDR 2 Photo Format */ }; /** Sign Initials */ enum SignInitials : uint32_t { SIGTA5 = RAGEPHOTO_SIGNINITIAL_GTA5, /**< GTA V Sign Initial */ - SIRDR2 = RAGEPHOTO_SIGNINITIAL_RDR2, /**< RDR 2 Sign Initial */ + SIRDR2 = RAGEPHOTO_SIGNINITIAL_RDR2 /**< RDR 2 Sign Initial */ }; photo() { instance = ragephoto_open(); diff --git a/src/core/ragephoto_cxx.hpp b/src/core/ragephoto_cxx.hpp index c205266..c58a06b 100644 --- a/src/core/ragephoto_cxx.hpp +++ b/src/core/ragephoto_cxx.hpp @@ -44,7 +44,7 @@ public: DEFAULT_JSONBUFFER = RAGEPHOTO_DEFAULT_JSONBUFFER, /**< Default JSON Buffer Size */ DEFAULT_TITLBUFFER = RAGEPHOTO_DEFAULT_TITLBUFFER, /**< Default Title Buffer Size */ GTA5_HEADERSIZE = RAGEPHOTO_GTA5_HEADERSIZE, /**< GTA V Header Size */ - RDR2_HEADERSIZE = RAGEPHOTO_RDR2_HEADERSIZE, /**< RDR 2 Header Size */ + RDR2_HEADERSIZE = RAGEPHOTO_RDR2_HEADERSIZE /**< RDR 2 Header Size */ }; /** Parsing and set errors */ enum Error : int32_t { @@ -88,17 +88,18 @@ public: TitleReadError = RAGEPHOTO_ERROR_TITLEREADERROR, /**< Title can't be read */ UnicodeInitError = RAGEPHOTO_ERROR_UNICODEINITERROR, /**< Failed to initialise Unicode decoder */ UnicodeHeaderError = RAGEPHOTO_ERROR_UNICODEHEADERERROR, /**< Header can't be encoded/decoded successfully */ - Uninitialised = RAGEPHOTO_ERROR_UNINITIALISED, /**< Uninitialised, file access failed */ + Uninitialised = RAGEPHOTO_ERROR_UNINITIALISED /**< Uninitialised, file access failed */ }; /** Photo Formats */ enum PhotoFormat : uint32_t { + JPEG = RAGEPHOTO_FORMAT_JPEG, /**< JPEG Photo Format */ GTA5 = RAGEPHOTO_FORMAT_GTA5, /**< GTA V Photo Format */ - RDR2 = RAGEPHOTO_FORMAT_RDR2, /**< RDR 2 Photo Format */ + RDR2 = RAGEPHOTO_FORMAT_RDR2 /**< RDR 2 Photo Format */ }; /** Sign Initials */ enum SignInitials : uint32_t { SIGTA5 = RAGEPHOTO_SIGNINITIAL_GTA5, /**< GTA V Sign Initial */ - SIRDR2 = RAGEPHOTO_SIGNINITIAL_RDR2, /**< RDR 2 Sign Initial */ + SIRDR2 = RAGEPHOTO_SIGNINITIAL_RDR2 /**< RDR 2 Sign Initial */ }; photo(); ~photo(); diff --git a/src/dotnet/RagePhotoTypes.cs b/src/dotnet/RagePhotoTypes.cs index 036a3be..8c6dbb3 100644 --- a/src/dotnet/RagePhotoTypes.cs +++ b/src/dotnet/RagePhotoTypes.cs @@ -57,6 +57,7 @@ namespace RagePhoto { } public enum PhotoFormat : UInt32 { + JPEG = 0xE0FFD8FFU, GTA5 = 0x01000000U, RDR2 = 0x04000000U } diff --git a/src/python/__init__.py b/src/python/__init__.py index b3a7697..c9b495a 100644 --- a/src/python/__init__.py +++ b/src/python/__init__.py @@ -1,6 +1,6 @@ ############################################################################## # libragephoto for Python -# Copyright (C) 2023-2024 Syping +# Copyright (C) 2023-2025 Syping # # Redistribution and use in source and binary forms, with or without modification, # are permitted provided that the following conditions are met: diff --git a/src/python/__version__.py.in b/src/python/__version__.py.in index 0168254..04d9508 100644 --- a/src/python/__version__.py.in +++ b/src/python/__version__.py.in @@ -1,6 +1,6 @@ ############################################################################## # libragephoto for Python -# Copyright (C) 2023 Syping +# Copyright (C) 2023-2025 Syping # # Redistribution and use in source and binary forms, with or without modification, # are permitted provided that the following conditions are met: diff --git a/src/python/libragephoto_loader.py b/src/python/libragephoto_loader.py index 2401359..c1f9ccd 100644 --- a/src/python/libragephoto_loader.py +++ b/src/python/libragephoto_loader.py @@ -1,6 +1,6 @@ ############################################################################## # libragephoto for Python -# Copyright (C) 2023-2024 Syping +# Copyright (C) 2023-2025 Syping # # Redistribution and use in source and binary forms, with or without modification, # are permitted provided that the following conditions are met: diff --git a/src/python/ragephoto.py b/src/python/ragephoto.py index a1574c6..9b49dc1 100644 --- a/src/python/ragephoto.py +++ b/src/python/ragephoto.py @@ -1,6 +1,6 @@ ############################################################################## # libragephoto for Python -# Copyright (C) 2023-2024 Syping +# Copyright (C) 2023-2025 Syping # # Redistribution and use in source and binary forms, with or without modification, # are permitted provided that the following conditions are met: @@ -73,6 +73,7 @@ class RagePhoto: Uninitialised = 0 class PhotoFormat(IntEnum): + JPEG = 0xE0FFD8FF GTA5 = 0x01000000 RDR2 = 0x04000000 diff --git a/src/python/setup.py.in b/src/python/setup.py.in index 7f1cf4b..ed5db30 100644 --- a/src/python/setup.py.in +++ b/src/python/setup.py.in @@ -1,7 +1,7 @@ #!/usr/bin/env python3 ############################################################################## # libragephoto for Python -# Copyright (C) 2023 Syping +# Copyright (C) 2023-2025 Syping # # Redistribution and use in source and binary forms, with or without modification, # are permitted provided that the following conditions are met: