libragephoto: add ragephoto_getphotosigns function
- rename libragephoto.py to libragephoto_loader.py - enforce set CXX standard for WASM build
This commit is contained in:
parent
1b7c95e735
commit
dd60f8d0b7
8 changed files with 53 additions and 18 deletions
|
@ -210,7 +210,7 @@ if (RAGEPHOTO_PYTHON)
|
||||||
# Python Package Source files + Target
|
# Python Package Source files + Target
|
||||||
set(PYRAGEPHOTO_SOURCES
|
set(PYRAGEPHOTO_SOURCES
|
||||||
"src/python/__init__.py"
|
"src/python/__init__.py"
|
||||||
"src/python/libragephoto.py"
|
"src/python/libragephoto_loader.py"
|
||||||
"src/python/ragephoto.py"
|
"src/python/ragephoto.py"
|
||||||
)
|
)
|
||||||
add_custom_target(pyragephoto SOURCES ${PYRAGEPHOTO_SOURCES})
|
add_custom_target(pyragephoto SOURCES ${PYRAGEPHOTO_SOURCES})
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#[[**************************************************************************
|
#[[**************************************************************************
|
||||||
* libragephoto RAGE Photo Parser
|
* 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,
|
* 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:
|
||||||
|
@ -17,8 +17,13 @@
|
||||||
****************************************************************************]]
|
****************************************************************************]]
|
||||||
|
|
||||||
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.13.0")
|
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
|
set_target_properties(ragephoto-wasm PROPERTIES
|
||||||
|
CXX_STANDARD ${RAGEPHOTO_CXX_STANDARD}
|
||||||
|
CXX_STANDARD_REQUIRED ON
|
||||||
PREFIX "lib"
|
PREFIX "lib"
|
||||||
OUTPUT_NAME "ragephoto"
|
OUTPUT_NAME "ragephoto"
|
||||||
)
|
)
|
||||||
|
|
|
@ -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:
|
||||||
|
@ -697,6 +697,16 @@ uint64_t ragephoto_getphotosign(ragephoto_t instance_t)
|
||||||
return ragephotodata_getphotosignf(instance->data, instance->data->photoFormat);
|
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)
|
uint32_t ragephoto_getphotosize(ragephoto_t instance_t)
|
||||||
{
|
{
|
||||||
RagePhotoInstance *instance = (RagePhotoInstance*)instance_t;
|
RagePhotoInstance *instance = (RagePhotoInstance*)instance_t;
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "ragephoto_cxx.hpp"
|
#include "ragephoto_cxx.hpp"
|
||||||
#ifdef LIBRAGEPHOTO_CXX_C
|
#ifdef LIBRAGEPHOTO_CXX_C
|
||||||
#include "RagePhoto.h"
|
#include "RagePhoto.h"
|
||||||
|
#include <cinttypes>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
@ -27,10 +28,6 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
|
||||||
#if (RAGEPHOTO_CXX_STD >= 17) && (__cplusplus >= 201703L)
|
|
||||||
#include <filesystem>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef RAGEPHOTO_BENCHMARK
|
#ifdef RAGEPHOTO_BENCHMARK
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#endif
|
#endif
|
||||||
|
@ -607,11 +604,7 @@ bool RagePhoto::load(const std::string &data)
|
||||||
|
|
||||||
bool RagePhoto::loadFile(const std::string &filename)
|
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);
|
std::ifstream ifs(filename, std::ios::in | std::ios::binary);
|
||||||
#endif
|
|
||||||
if (ifs.is_open()) {
|
if (ifs.is_open()) {
|
||||||
std::string sdata(std::istreambuf_iterator<char>{ifs}, {});
|
std::string sdata(std::istreambuf_iterator<char>{ifs}, {});
|
||||||
ifs.close();
|
ifs.close();
|
||||||
|
@ -1382,6 +1375,18 @@ uint64_t ragephoto_getphotosignf(ragephoto_t instance, uint32_t photoFormat)
|
||||||
return ragePhoto->jpegSign(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)
|
uint64_t ragephotodata_getphotosign(RagePhotoData *rp_data)
|
||||||
{
|
{
|
||||||
return RagePhoto::jpegSign(rp_data);
|
return RagePhoto::jpegSign(rp_data);
|
||||||
|
|
|
@ -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:
|
||||||
|
@ -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);
|
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.
|
/** Returns the Photo JPEG sign.
|
||||||
* \param rp_data RagePhotoData object
|
* \param rp_data RagePhotoData object
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
##############################################################################
|
##############################################################################
|
||||||
# libragephoto for Python
|
# libragephoto for Python
|
||||||
# Copyright (C) 2023 Syping
|
# Copyright (C) 2023-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:
|
||||||
|
@ -19,7 +19,7 @@
|
||||||
from .ragephoto import RagePhoto
|
from .ragephoto import RagePhoto
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"libragephoto", # libragephoto Loader Module
|
"libragephoto_loader", # libragephoto Loader Module
|
||||||
"ragephoto", # RagePhoto Module
|
"ragephoto", # RagePhoto Module
|
||||||
"RagePhoto" # RagePhoto API
|
"RagePhoto" # RagePhoto API
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
##############################################################################
|
##############################################################################
|
||||||
# libragephoto for Python
|
# libragephoto for Python
|
||||||
# Copyright (C) 2023 Syping
|
# Copyright (C) 2023-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:
|
|
@ -1,6 +1,6 @@
|
||||||
##############################################################################
|
##############################################################################
|
||||||
# libragephoto for Python
|
# libragephoto for Python
|
||||||
# Copyright (C) 2023 Syping
|
# Copyright (C) 2023-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:
|
||||||
|
@ -16,7 +16,7 @@
|
||||||
# responsible for anything with use of the software, you are self responsible.
|
# responsible for anything with use of the software, you are self responsible.
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
from .libragephoto import *
|
from .libragephoto_loader import *
|
||||||
from enum import IntEnum
|
from enum import IntEnum
|
||||||
from json import loads as parseJson
|
from json import loads as parseJson
|
||||||
from json import dumps as serializeJson
|
from json import dumps as serializeJson
|
||||||
|
|
Loading…
Reference in a new issue