libragephoto 0.7.0 release

- libragephoto: support JPEG as save format
This commit is contained in:
Syping 2025-10-23 02:20:17 +02:00
parent c14c46cd41
commit 83832a6724
11 changed files with 42 additions and 15 deletions

View file

@ -984,6 +984,15 @@ bool ragephotodata_savef(RagePhotoData *rp_data, RagePhotoFormatParser *rp_parse
return false; return false;
#endif #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) { else if (rp_parser) {
RagePhotoFormatParser n_parser; RagePhotoFormatParser n_parser;
memset(&n_parser, 0, sizeof(RagePhotoFormatParser)); 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)); 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) 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)); 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) { else if (rp_parser) {
RagePhotoFormatParser n_parser; RagePhotoFormatParser n_parser;
memset(&n_parser, 0, sizeof(RagePhotoFormatParser)); memset(&n_parser, 0, sizeof(RagePhotoFormatParser));

View file

@ -939,6 +939,15 @@ bool RagePhoto::save(char *data, uint32_t photoFormat, RagePhotoData *rp_data, R
return false; return false;
#endif #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) { else if (rp_parser) {
RagePhotoFormatParser n_parser[1]{}; RagePhotoFormatParser n_parser[1]{};
for (size_t i = 0; memcmp(&n_parser[0], &rp_parser[i], sizeof(RagePhotoFormatParser)); i++) { 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)); return (rp_data->jpegBuffer + rp_data->jsonBuffer + rp_data->titlBuffer + rp_data->descBuffer + GTA5_HEADERSIZE + UINT32_C(56));
else if (photoFormat == PhotoFormat::RDR2) else if (photoFormat == PhotoFormat::RDR2)
return (rp_data->jpegBuffer + rp_data->jsonBuffer + rp_data->titlBuffer + rp_data->descBuffer + RDR2_HEADERSIZE + UINT32_C(56)); 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) { else if (rp_parser) {
RagePhotoFormatParser n_parser[1]{}; RagePhotoFormatParser n_parser[1]{};
for (size_t i = 0; memcmp(&n_parser[0], &rp_parser[i], sizeof(RagePhotoFormatParser)); i++) { for (size_t i = 0; memcmp(&n_parser[0], &rp_parser[i], sizeof(RagePhotoFormatParser)); i++) {

View file

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* libragephoto RAGE Photo Parser * 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, * 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:
@ -136,6 +136,7 @@ typedef enum RagePhotoLibraryFlag {
#define RAGEPHOTO_ERROR_UNINITIALISED INT32_C(0) /**< Uninitialised, file access failed */ #define RAGEPHOTO_ERROR_UNINITIALISED INT32_C(0) /**< Uninitialised, file access failed */
/* RagePhoto formats */ /* 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_GTA5 UINT32_C(0x01000000) /**< GTA V Photo Format */
#define RAGEPHOTO_FORMAT_RDR2 UINT32_C(0x04000000) /**< RDR 2 Photo Format */ #define RAGEPHOTO_FORMAT_RDR2 UINT32_C(0x04000000) /**< RDR 2 Photo Format */

View file

@ -1,6 +1,6 @@
/***************************************************************************** /*****************************************************************************
* libragephoto RAGE Photo Parser * 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, * 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:
@ -41,7 +41,7 @@ public:
DEFAULT_JSONBUFFER = RAGEPHOTO_DEFAULT_JSONBUFFER, /**< Default JSON Buffer Size */ DEFAULT_JSONBUFFER = RAGEPHOTO_DEFAULT_JSONBUFFER, /**< Default JSON Buffer Size */
DEFAULT_TITLBUFFER = RAGEPHOTO_DEFAULT_TITLBUFFER, /**< Default Title Buffer Size */ DEFAULT_TITLBUFFER = RAGEPHOTO_DEFAULT_TITLBUFFER, /**< Default Title Buffer Size */
GTA5_HEADERSIZE = RAGEPHOTO_GTA5_HEADERSIZE, /**< GTA V Header 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 */ /** Parsing and set errors */
enum Error : int32_t { enum Error : int32_t {
@ -85,17 +85,18 @@ public:
TitleReadError = RAGEPHOTO_ERROR_TITLEREADERROR, /**< Title can't be read */ TitleReadError = RAGEPHOTO_ERROR_TITLEREADERROR, /**< Title can't be read */
UnicodeInitError = RAGEPHOTO_ERROR_UNICODEINITERROR, /**< Failed to initialise Unicode decoder */ UnicodeInitError = RAGEPHOTO_ERROR_UNICODEINITERROR, /**< Failed to initialise Unicode decoder */
UnicodeHeaderError = RAGEPHOTO_ERROR_UNICODEHEADERERROR, /**< Header can't be encoded/decoded successfully */ 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 */ /** Photo Formats */
enum PhotoFormat : uint32_t { enum PhotoFormat : uint32_t {
JPEG = RAGEPHOTO_FORMAT_JPEG, /**< JPEG Photo Format */
GTA5 = RAGEPHOTO_FORMAT_GTA5, /**< GTA V 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 */ /** Sign Initials */
enum SignInitials : uint32_t { enum SignInitials : uint32_t {
SIGTA5 = RAGEPHOTO_SIGNINITIAL_GTA5, /**< GTA V Sign Initial */ 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() {
instance = ragephoto_open(); instance = ragephoto_open();

View file

@ -44,7 +44,7 @@ public:
DEFAULT_JSONBUFFER = RAGEPHOTO_DEFAULT_JSONBUFFER, /**< Default JSON Buffer Size */ DEFAULT_JSONBUFFER = RAGEPHOTO_DEFAULT_JSONBUFFER, /**< Default JSON Buffer Size */
DEFAULT_TITLBUFFER = RAGEPHOTO_DEFAULT_TITLBUFFER, /**< Default Title Buffer Size */ DEFAULT_TITLBUFFER = RAGEPHOTO_DEFAULT_TITLBUFFER, /**< Default Title Buffer Size */
GTA5_HEADERSIZE = RAGEPHOTO_GTA5_HEADERSIZE, /**< GTA V Header 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 */ /** Parsing and set errors */
enum Error : int32_t { enum Error : int32_t {
@ -88,17 +88,18 @@ public:
TitleReadError = RAGEPHOTO_ERROR_TITLEREADERROR, /**< Title can't be read */ TitleReadError = RAGEPHOTO_ERROR_TITLEREADERROR, /**< Title can't be read */
UnicodeInitError = RAGEPHOTO_ERROR_UNICODEINITERROR, /**< Failed to initialise Unicode decoder */ UnicodeInitError = RAGEPHOTO_ERROR_UNICODEINITERROR, /**< Failed to initialise Unicode decoder */
UnicodeHeaderError = RAGEPHOTO_ERROR_UNICODEHEADERERROR, /**< Header can't be encoded/decoded successfully */ 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 */ /** Photo Formats */
enum PhotoFormat : uint32_t { enum PhotoFormat : uint32_t {
JPEG = RAGEPHOTO_FORMAT_JPEG, /**< JPEG Photo Format */
GTA5 = RAGEPHOTO_FORMAT_GTA5, /**< GTA V 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 */ /** Sign Initials */
enum SignInitials : uint32_t { enum SignInitials : uint32_t {
SIGTA5 = RAGEPHOTO_SIGNINITIAL_GTA5, /**< GTA V Sign Initial */ 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();
~photo(); ~photo();

View file

@ -57,6 +57,7 @@ namespace RagePhoto {
} }
public enum PhotoFormat : UInt32 { public enum PhotoFormat : UInt32 {
JPEG = 0xE0FFD8FFU,
GTA5 = 0x01000000U, GTA5 = 0x01000000U,
RDR2 = 0x04000000U RDR2 = 0x04000000U
} }

View file

@ -1,6 +1,6 @@
############################################################################## ##############################################################################
# libragephoto for Python # 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, # 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:

View file

@ -1,6 +1,6 @@
############################################################################## ##############################################################################
# libragephoto for Python # libragephoto for Python
# Copyright (C) 2023 Syping # Copyright (C) 2023-2025 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:

View file

@ -1,6 +1,6 @@
############################################################################## ##############################################################################
# libragephoto for Python # 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, # 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:

View file

@ -1,6 +1,6 @@
############################################################################## ##############################################################################
# libragephoto for Python # 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, # 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:
@ -73,6 +73,7 @@ class RagePhoto:
Uninitialised = 0 Uninitialised = 0
class PhotoFormat(IntEnum): class PhotoFormat(IntEnum):
JPEG = 0xE0FFD8FF
GTA5 = 0x01000000 GTA5 = 0x01000000
RDR2 = 0x04000000 RDR2 = 0x04000000

View file

@ -1,7 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
############################################################################## ##############################################################################
# libragephoto for Python # libragephoto for Python
# Copyright (C) 2023 Syping # Copyright (C) 2023-2025 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: