libragephoto: add ragephoto_getphotosigns function

- rename libragephoto.py to libragephoto_loader.py
- enforce set CXX standard for WASM build
This commit is contained in:
Syping 2024-03-25 13:06:14 +01:00
parent 1b7c95e735
commit dd60f8d0b7
8 changed files with 53 additions and 18 deletions

View file

@ -210,7 +210,7 @@ if (RAGEPHOTO_PYTHON)
# Python Package Source files + Target
set(PYRAGEPHOTO_SOURCES
"src/python/__init__.py"
"src/python/libragephoto.py"
"src/python/libragephoto_loader.py"
"src/python/ragephoto.py"
)
add_custom_target(pyragephoto SOURCES ${PYRAGEPHOTO_SOURCES})

View file

@ -1,6 +1,6 @@
#[[**************************************************************************
* libragephoto RAGE Photo Parser
* Copyright (C) 2023 Syping
* Copyright (C) 2023-2024 Syping
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@ -17,8 +17,13 @@
****************************************************************************]]
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.13.0")
add_executable(ragephoto-wasm ${RAGEPHOTO_HEADERS} ${RAGEPHOTO_SOURCES})
add_executable(ragephoto-wasm
${RAGEPHOTO_HEADERS}
${RAGEPHOTO_SOURCES}
)
set_target_properties(ragephoto-wasm PROPERTIES
CXX_STANDARD ${RAGEPHOTO_CXX_STANDARD}
CXX_STANDARD_REQUIRED ON
PREFIX "lib"
OUTPUT_NAME "ragephoto"
)

View file

@ -1,6 +1,6 @@
/*****************************************************************************
* 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,
* are permitted provided that the following conditions are met:
@ -697,6 +697,16 @@ uint64_t ragephoto_getphotosign(ragephoto_t instance_t)
return ragephotodata_getphotosignf(instance->data, instance->data->photoFormat);
}
void ragephoto_getphotosigns(ragephoto_t instance, char *data, size_t size)
{
snprintf(data, size, "%" PRIu64, ragephoto_getphotosign(instance));
}
void ragephoto_getphotosignsf(ragephoto_t instance, char *data, size_t size, uint32_t photoFormat)
{
snprintf(data, size, "%" PRIu64, ragephoto_getphotosignf(instance, photoFormat));
}
uint32_t ragephoto_getphotosize(ragephoto_t instance_t)
{
RagePhotoInstance *instance = (RagePhotoInstance*)instance_t;

View file

@ -19,6 +19,7 @@
#include "ragephoto_cxx.hpp"
#ifdef LIBRAGEPHOTO_CXX_C
#include "RagePhoto.h"
#include <cinttypes>
#endif
#include <cstdlib>
@ -27,10 +28,6 @@
#include <iostream>
#include <iterator>
#if (RAGEPHOTO_CXX_STD >= 17) && (__cplusplus >= 201703L)
#include <filesystem>
#endif
#ifdef RAGEPHOTO_BENCHMARK
#include <chrono>
#endif
@ -607,11 +604,7 @@ bool RagePhoto::load(const std::string &data)
bool RagePhoto::loadFile(const std::string &filename)
{
#if (RAGEPHOTO_CXX_STD >= 17) && (__cplusplus >= 201703L)
std::ifstream ifs(std::filesystem::u8path(filename), std::ios::in | std::ios::binary);
#else
std::ifstream ifs(filename, std::ios::in | std::ios::binary);
#endif
if (ifs.is_open()) {
std::string sdata(std::istreambuf_iterator<char>{ifs}, {});
ifs.close();
@ -1382,6 +1375,18 @@ uint64_t ragephoto_getphotosignf(ragephoto_t instance, uint32_t photoFormat)
return ragePhoto->jpegSign(photoFormat);
}
void ragephoto_getphotosigns(ragephoto_t instance, char *data, size_t size)
{
RagePhoto *ragePhoto = static_cast<RagePhoto*>(instance);
snprintf(data, size, "%" PRIu64, ragePhoto->jpegSign());
}
void ragephoto_getphotosignsf(ragephoto_t instance, char *data, size_t size, uint32_t photoFormat)
{
RagePhoto *ragePhoto = static_cast<RagePhoto*>(instance);
snprintf(data, size, "%" PRIu64, ragePhoto->jpegSign(photoFormat));
}
uint64_t ragephotodata_getphotosign(RagePhotoData *rp_data)
{
return RagePhoto::jpegSign(rp_data);

View file

@ -1,6 +1,6 @@
/*****************************************************************************
* 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,
* are permitted provided that the following conditions are met:
@ -133,6 +133,21 @@ LIBRAGEPHOTO_C_PUBLIC uint64_t ragephoto_getphotosign(ragephoto_t instance);
*/
LIBRAGEPHOTO_C_PUBLIC uint64_t ragephoto_getphotosignf(ragephoto_t instance, uint32_t photoFormat);
/** Returns the Photo JPEG sign as string.
* \param instance \p ragephoto_t instance
* \param data String data
* \param size String size
*/
LIBRAGEPHOTO_C_PUBLIC void ragephoto_getphotosigns(ragephoto_t instance, char *data, size_t size);
/** Returns the Photo JPEG sign as string.
* \param instance \p ragephoto_t instance
* \param data String data
* \param size String size
* \param photoFormat Photo Format (GTA V or RDR 2)
*/
LIBRAGEPHOTO_C_PUBLIC void ragephoto_getphotosignsf(ragephoto_t instance, char *data, size_t size, uint32_t photoFormat);
/** Returns the Photo JPEG sign.
* \param rp_data RagePhotoData object
*/

View file

@ -1,6 +1,6 @@
##############################################################################
# libragephoto for Python
# Copyright (C) 2023 Syping
# Copyright (C) 2023-2024 Syping
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
@ -19,7 +19,7 @@
from .ragephoto import RagePhoto
__all__ = [
"libragephoto", # libragephoto Loader Module
"libragephoto_loader", # libragephoto Loader Module
"ragephoto", # RagePhoto Module
"RagePhoto" # RagePhoto API
]

View file

@ -1,6 +1,6 @@
##############################################################################
# libragephoto for Python
# Copyright (C) 2023 Syping
# Copyright (C) 2023-2024 Syping
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:

View file

@ -1,6 +1,6 @@
##############################################################################
# libragephoto for Python
# Copyright (C) 2023 Syping
# Copyright (C) 2023-2024 Syping
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
@ -16,7 +16,7 @@
# responsible for anything with use of the software, you are self responsible.
##############################################################################
from .libragephoto import *
from .libragephoto_loader import *
from enum import IntEnum
from json import loads as parseJson
from json import dumps as serializeJson