Compare commits
1 Commits
Author | SHA1 | Date |
---|---|---|
Syping | 6bb8843971 |
|
@ -1,29 +0,0 @@
|
|||
name: Ubuntu C
|
||||
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
Release:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
BUILD_TYPE: Release
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Install packages
|
||||
run: |
|
||||
sudo apt-get update -qq
|
||||
sudo apt-get install cmake gcc g++ ninja-build -qq
|
||||
- name: Configure CMake
|
||||
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DRAGEPHOTO_C_LIBRARY=ON -GNinja
|
||||
- name: Build
|
||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
|
||||
- name: Install
|
||||
run: cmake --install ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --prefix ${{github.workspace}}/install/usr/local
|
||||
- name: Upload
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: Ubuntu
|
||||
path: |
|
||||
${{github.workspace}}/install/
|
|
@ -1,29 +0,0 @@
|
|||
name: Ubuntu CXX
|
||||
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
Release:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
BUILD_TYPE: Release
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Install packages
|
||||
run: |
|
||||
sudo apt-get update -qq
|
||||
sudo apt-get install cmake gcc g++ ninja-build -qq
|
||||
- name: Configure CMake
|
||||
run: cmake -B ${{github.workspace}}/build -DCMAKE_CXX_STANDARD=17 -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -GNinja
|
||||
- name: Build
|
||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
|
||||
- name: Install
|
||||
run: cmake --install ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --prefix ${{github.workspace}}/install/usr/local
|
||||
- name: Upload
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: Ubuntu
|
||||
path: |
|
||||
${{github.workspace}}/install/
|
|
@ -0,0 +1,28 @@
|
|||
name: Ubuntu
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ test ]
|
||||
pull_request:
|
||||
branches: [ test ]
|
||||
|
||||
env:
|
||||
BUILD_TYPE: Release
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Install packages
|
||||
run: |
|
||||
sudo apt-get update -qq
|
||||
sudo apt-get install cmake git gcc g++ make ninja-build -qq
|
||||
- name: Configure CMake
|
||||
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -GNinja
|
||||
- name: Build
|
||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
|
||||
- name: Install
|
||||
run: sudo cmake --install ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
|
|
@ -1,30 +0,0 @@
|
|||
name: WebAssembly C
|
||||
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
Release:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
BUILD_TYPE: Release
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Setup emsdk
|
||||
uses: mymindstorm/setup-emsdk@v11
|
||||
- name: Install packages
|
||||
run: |
|
||||
sudo apt-get update -qq
|
||||
sudo apt-get install cmake ninja-build -qq
|
||||
- name: Configure CMake
|
||||
run: emcmake cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DRAGEPHOTO_C_LIBRARY=ON -GNinja
|
||||
- name: Build
|
||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
|
||||
- name: Upload
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: WebAssembly
|
||||
path: |
|
||||
${{github.workspace}}/build/libragephoto.js
|
||||
${{github.workspace}}/build/libragephoto.wasm
|
|
@ -1,30 +0,0 @@
|
|||
name: WebAssembly CXX
|
||||
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
Release:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
BUILD_TYPE: Release
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Setup emsdk
|
||||
uses: mymindstorm/setup-emsdk@v11
|
||||
- name: Install packages
|
||||
run: |
|
||||
sudo apt-get update -qq
|
||||
sudo apt-get install cmake ninja-build -qq
|
||||
- name: Configure CMake
|
||||
run: emcmake cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -GNinja
|
||||
- name: Build
|
||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
|
||||
- name: Upload
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: WebAssembly
|
||||
path: |
|
||||
${{github.workspace}}/build/libragephoto.js
|
||||
${{github.workspace}}/build/libragephoto.wasm
|
|
@ -1,34 +0,0 @@
|
|||
name: Windows C
|
||||
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
Release:
|
||||
runs-on: windows-latest
|
||||
env:
|
||||
BUILD_TYPE: Release
|
||||
strategy:
|
||||
matrix:
|
||||
arch:
|
||||
- amd64
|
||||
- amd64_x86
|
||||
- amd64_arm64
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: recursive
|
||||
- uses: ilammy/msvc-dev-cmd@v1
|
||||
with:
|
||||
arch: ${{matrix.arch}}
|
||||
- name: Configure CMake
|
||||
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DRAGEPHOTO_C_LIBRARY=ON -DRAGEPHOTO_UNICODE=wincvt -GNinja
|
||||
- name: Build
|
||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
|
||||
- name: Install
|
||||
run: cmake --install ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --prefix ${{github.workspace}}/install
|
||||
- name: Upload
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: Windows MSVC ${{matrix.arch}}
|
||||
path: |
|
||||
${{github.workspace}}/install/
|
|
@ -1,34 +0,0 @@
|
|||
name: Windows CXX
|
||||
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
Release:
|
||||
runs-on: windows-latest
|
||||
env:
|
||||
BUILD_TYPE: Release
|
||||
strategy:
|
||||
matrix:
|
||||
arch:
|
||||
- amd64
|
||||
- amd64_x86
|
||||
- amd64_arm64
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: recursive
|
||||
- uses: ilammy/msvc-dev-cmd@v1
|
||||
with:
|
||||
arch: ${{matrix.arch}}
|
||||
- name: Configure CMake
|
||||
run: cmake -B ${{github.workspace}}/build -DCMAKE_CXX_STANDARD=17 -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DRAGEPHOTO_UNICODE=wincvt -GNinja
|
||||
- name: Build
|
||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
|
||||
- name: Install
|
||||
run: cmake --install ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --prefix ${{github.workspace}}/install
|
||||
- name: Upload
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: Windows MSVC ${{matrix.arch}}
|
||||
path: |
|
||||
${{github.workspace}}/install/
|
|
@ -0,0 +1,23 @@
|
|||
name: Windows
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ test ]
|
||||
pull_request:
|
||||
branches: [ test ]
|
||||
|
||||
env:
|
||||
BUILD_TYPE: Release
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: recursive
|
||||
- uses: ilammy/msvc-dev-cmd@v1
|
||||
- name: Configure CMake
|
||||
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -GNinja
|
||||
- name: Build
|
||||
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
|
200
CMakeLists.txt
200
CMakeLists.txt
|
@ -1,6 +1,6 @@
|
|||
#[[**************************************************************************
|
||||
* libragephoto RAGE Photo Parser
|
||||
* Copyright (C) 2021-2023 Syping
|
||||
* Copyright (C) 2021 Syping
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
@ -16,157 +16,153 @@
|
|||
* responsible for anything with use of the software, you are self responsible.
|
||||
****************************************************************************]]
|
||||
|
||||
cmake_minimum_required(VERSION 3.8)
|
||||
project(ragephoto VERSION 0.5.1 LANGUAGES C CXX)
|
||||
cmake_minimum_required(VERSION 3.7)
|
||||
project(ragephoto VERSION 0.1.0 LANGUAGES CXX)
|
||||
include(GNUInstallDirs)
|
||||
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
# RagePhoto CMake includes
|
||||
include(cmake/cxxstd.cmake)
|
||||
include(cmake/unicode.cmake)
|
||||
|
||||
# RagePhoto Top Level ON
|
||||
if (${CMAKE_PROJECT_NAME} STREQUAL "ragephoto")
|
||||
set(RPTL_ON ON)
|
||||
else()
|
||||
set(RPTL_ON OFF)
|
||||
endif()
|
||||
|
||||
# RagePhoto Source files
|
||||
option(RAGEPHOTO_C_LIBRARY "Build libragephoto as C library" OFF)
|
||||
if (RAGEPHOTO_C_LIBRARY)
|
||||
set(RAGEPHOTO_HEADERS
|
||||
src/RagePhoto.h
|
||||
src/RagePhotoA
|
||||
src/RagePhotoA.hpp
|
||||
src/RagePhotoB
|
||||
src/RagePhotoB.hpp
|
||||
src/RagePhotoLibrary.h
|
||||
src/RagePhotoTypedefs.h
|
||||
)
|
||||
set(RAGEPHOTO_SOURCES
|
||||
src/RagePhoto.c
|
||||
)
|
||||
else()
|
||||
set(RAGEPHOTO_HEADERS
|
||||
src/RagePhoto
|
||||
src/RagePhoto.hpp
|
||||
src/RagePhotoB
|
||||
src/RagePhotoB.hpp
|
||||
src/RagePhotoLibrary.h
|
||||
src/RagePhotoTypedefs.h
|
||||
)
|
||||
set(RAGEPHOTO_SOURCES
|
||||
src/RagePhoto.cpp
|
||||
)
|
||||
endif()
|
||||
set(RAGEPHOTO_HEADERS
|
||||
src/RagePhoto.h
|
||||
src/RagePhotoData.h
|
||||
)
|
||||
set(RAGEPHOTO_SOURCES
|
||||
src/RagePhoto.cpp
|
||||
)
|
||||
|
||||
# RagePhoto Library Type
|
||||
option(RAGEPHOTO_STATIC "Build libragephoto as static library" OFF)
|
||||
if (RAGEPHOTO_STATIC)
|
||||
option(RAGEPHOTO_C_API "Build libragephoto with C API support" OFF)
|
||||
set(LIBRAGEPHOTO_LIBTYPE LIBRAGEPHOTO_STATIC)
|
||||
if (EMSCRIPTEN)
|
||||
option(BUILD_SHARED "Build libragephoto as shared library" OFF)
|
||||
else()
|
||||
option(RAGEPHOTO_C_API "Build libragephoto with C API support" ON)
|
||||
option(BUILD_SHARED "Build libragephoto as shared library" ON)
|
||||
endif()
|
||||
if (BUILD_SHARED)
|
||||
option(WITH_C_API "Build libragephoto with C API support" ON)
|
||||
set(LIBRAGEPHOTO_LIBTYPE LIBRAGEPHOTO_SHARED)
|
||||
else()
|
||||
if (EMSCRIPTEN)
|
||||
option(WITH_C_API "Build libragephoto with C API support" ON)
|
||||
else()
|
||||
option(WITH_C_API "Build libragephoto with C API support" OFF)
|
||||
endif()
|
||||
set(LIBRAGEPHOTO_LIBTYPE LIBRAGEPHOTO_STATIC)
|
||||
endif()
|
||||
|
||||
# RagePhoto Benchmark
|
||||
option(RAGEPHOTO_BENCHMARK "Build with libragephoto benchmark (C++ only)" OFF)
|
||||
if (RAGEPHOTO_BENCHMARK)
|
||||
option(WITH_BENCHMARK "Build with libragephoto benchmark" OFF)
|
||||
if (WITH_BENCHMARK)
|
||||
list(APPEND LIBRAGEPHOTO_DEFINES
|
||||
RAGEPHOTO_BENCHMARK
|
||||
)
|
||||
endif()
|
||||
|
||||
# RagePhoto C API
|
||||
if (RAGEPHOTO_C_LIBRARY)
|
||||
set(LIBRAGEPHOTO_API LIBRAGEPHOTO_C_ONLY)
|
||||
if (WITH_C_API)
|
||||
set(LIBRAGEPHOTO_API LIBRAGEPHOTO_C_API)
|
||||
list(APPEND RAGEPHOTO_HEADERS
|
||||
src/RagePhotoA.h
|
||||
src/RagePhotoC.h
|
||||
)
|
||||
else()
|
||||
if (RAGEPHOTO_C_API)
|
||||
set(LIBRAGEPHOTO_API LIBRAGEPHOTO_CXX_C)
|
||||
list(APPEND RAGEPHOTO_HEADERS
|
||||
src/RagePhoto.h
|
||||
src/RagePhotoA
|
||||
src/RagePhotoA.hpp
|
||||
)
|
||||
else()
|
||||
set(LIBRAGEPHOTO_API LIBRAGEPHOTO_CXX_ONLY)
|
||||
endif()
|
||||
set(LIBRAGEPHOTO_API LIBRAGEPHOTO_C_NOAPI)
|
||||
endif()
|
||||
|
||||
# RagePhoto Win32 Shared Resources
|
||||
if (WIN32)
|
||||
string(TIMESTAMP ragephoto_BUILD_YEAR "%Y" UTC)
|
||||
configure_file(src/ragephoto.rc.in "${ragephoto_BINARY_DIR}/resources/ragephoto.rc" @ONLY)
|
||||
configure_file(src/ragephoto.rc.in resources/ragephoto.rc @ONLY)
|
||||
list(APPEND RAGEPHOTO_SHARED_RESOURCES
|
||||
"${ragephoto_BINARY_DIR}/resources/ragephoto.rc"
|
||||
${PROJECT_BINARY_DIR}/resources/ragephoto.rc
|
||||
)
|
||||
endif()
|
||||
|
||||
# RagePhoto Configures + Target + Installs
|
||||
configure_file(src/ragephoto.pc.in "${ragephoto_BINARY_DIR}/pkgconfig/ragephoto.pc" @ONLY)
|
||||
configure_file(src/RagePhotoConfig.h.in "${ragephoto_BINARY_DIR}/include/RagePhotoConfig.h" @ONLY)
|
||||
configure_file(src/ragephoto.pc.in pkgconfig/ragephoto.pc @ONLY)
|
||||
configure_file(src/libragephoto_global.h.in include/libragephoto_global.h @ONLY)
|
||||
list(APPEND RAGEPHOTO_HEADERS
|
||||
"${ragephoto_BINARY_DIR}/include/RagePhotoConfig.h"
|
||||
${PROJECT_BINARY_DIR}/include/libragephoto_global.h
|
||||
)
|
||||
if (RAGEPHOTO_STATIC)
|
||||
add_library(ragephoto STATIC ${RAGEPHOTO_HEADERS} ${RAGEPHOTO_SOURCES} ${RAGEPHOTO_STATIC_RESOURCES})
|
||||
else()
|
||||
if (BUILD_SHARED)
|
||||
add_library(ragephoto SHARED ${RAGEPHOTO_HEADERS} ${RAGEPHOTO_SOURCES} ${RAGEPHOTO_SHARED_RESOURCES})
|
||||
set_target_properties(ragephoto PROPERTIES
|
||||
PREFIX "lib"
|
||||
VERSION "${ragephoto_VERSION}"
|
||||
SOVERSION "${ragephoto_VERSION}"
|
||||
)
|
||||
else()
|
||||
add_library(ragephoto STATIC ${RAGEPHOTO_HEADERS} ${RAGEPHOTO_SOURCES} ${RAGEPHOTO_STATIC_RESOURCES})
|
||||
endif()
|
||||
target_compile_definitions(ragephoto PRIVATE
|
||||
LIBRAGEPHOTO_LIBRARY
|
||||
${LIBRAGEPHOTO_DEFINES}
|
||||
)
|
||||
if (MSVC AND MSVC_VERSION GREATER_EQUAL 1914 AND NOT RAGEPHOTO_C_LIBRARY)
|
||||
target_compile_options(ragephoto PRIVATE "/Zc:__cplusplus")
|
||||
endif()
|
||||
target_include_directories(ragephoto PUBLIC
|
||||
"${ragephoto_BINARY_DIR}/include"
|
||||
"${ragephoto_SOURCE_DIR}/src"
|
||||
${ragephoto_BINARY_DIR}/include
|
||||
${ragephoto_SOURCE_DIR}/src
|
||||
)
|
||||
install(TARGETS ragephoto
|
||||
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
||||
)
|
||||
install(FILES ${RAGEPHOTO_HEADERS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/RagePhoto")
|
||||
if (UNIX)
|
||||
install(FILES "${ragephoto_BINARY_DIR}/pkgconfig/ragephoto.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
||||
endif()
|
||||
install(TARGETS ragephoto DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
install(FILES ${RAGEPHOTO_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/RagePhoto)
|
||||
install(FILES ${ragephoto_BINARY_DIR}/pkgconfig/ragephoto.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
||||
|
||||
# RagePhoto WebAssembly Target
|
||||
if (EMSCRIPTEN)
|
||||
include(cmake/wasm.cmake)
|
||||
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.13.0")
|
||||
add_executable(ragephoto-wasm ${RAGEPHOTO_HEADERS} ${RAGEPHOTO_SOURCES})
|
||||
set_target_properties(ragephoto-wasm PROPERTIES
|
||||
PREFIX "lib"
|
||||
OUTPUT_NAME "ragephoto"
|
||||
)
|
||||
target_compile_definitions(ragephoto-wasm PRIVATE
|
||||
LIBRAGEPHOTO_LIBRARY
|
||||
${LIBRAGEPHOTO_DEFINES}
|
||||
)
|
||||
target_link_options(ragephoto-wasm PRIVATE
|
||||
"SHELL:-O2"
|
||||
"SHELL:--no-entry"
|
||||
"SHELL:-s WASM=1"
|
||||
"SHELL:-s EXPORTED_FUNCTIONS=_free"
|
||||
"SHELL:-s EXPORTED_RUNTIME_METHODS=ccall,cwrap"
|
||||
)
|
||||
target_include_directories(ragephoto-wasm PUBLIC
|
||||
${ragephoto_BINARY_DIR}/include
|
||||
${ragephoto_SOURCE_DIR}/src
|
||||
)
|
||||
else()
|
||||
message(WARNING "A useable WebAssembly build needs at least CMake 3.13.0 or newer")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# RagePhoto Documentation
|
||||
option(RAGEPHOTO_DOC "Build libragephoto with documentation" OFF)
|
||||
if (RAGEPHOTO_DOC)
|
||||
option(WITH_DOCUMENTATION "Build libragephoto with documentation" OFF)
|
||||
if (WITH_DOCUMENTATION)
|
||||
add_subdirectory(doc)
|
||||
endif()
|
||||
|
||||
# RagePhoto Examples
|
||||
option(RAGEPHOTO_EXAMPLE_GTKVIEWER "Build libragephoto with GTK Photo Viewer" OFF)
|
||||
if (RAGEPHOTO_EXAMPLE_GTKVIEWER)
|
||||
option(WITH_GTK_EXAMPLE "Build libragephoto with GTK Photo Viewer" OFF)
|
||||
if (WITH_GTK_EXAMPLE)
|
||||
add_subdirectory(examples/ragephoto-gtkviewer)
|
||||
endif()
|
||||
|
||||
option(RAGEPHOTO_EXAMPLE_QTVIEWER "Build libragephoto with Qt Photo Viewer" OFF)
|
||||
if (RAGEPHOTO_EXAMPLE_QTVIEWER)
|
||||
option(WITH_QT_EXAMPLE "Build libragephoto with Qt Photo Viewer" OFF)
|
||||
if (WITH_QT_EXAMPLE)
|
||||
add_subdirectory(examples/ragephoto-qtviewer)
|
||||
endif()
|
||||
|
||||
# RagePhoto Extract Tool
|
||||
option(RAGEPHOTO_EXTRACT "Build libragephoto with ragephoto-extract" ${RPTL_ON})
|
||||
if (RAGEPHOTO_EXTRACT)
|
||||
if (${CMAKE_PROJECT_NAME} STREQUAL "ragephoto")
|
||||
option(WITH_EXTRACT "Build libragephoto with ragephoto-extract" ON)
|
||||
else()
|
||||
option(WITH_EXTRACT "Build libragephoto with ragephoto-extract" OFF)
|
||||
endif()
|
||||
if (WITH_EXTRACT)
|
||||
# RagePhoto-Extract Source files
|
||||
if (RAGEPHOTO_C_API)
|
||||
if (WITH_C_API)
|
||||
enable_language(C)
|
||||
set(EXTRACT_SOURCES src/RagePhoto-Extract.c)
|
||||
else()
|
||||
set(EXTRACT_SOURCES src/RagePhoto-Extract.cpp)
|
||||
|
@ -174,9 +170,9 @@ if (RAGEPHOTO_EXTRACT)
|
|||
# RagePhoto-Extract Win32 Shared Resources
|
||||
if (WIN32)
|
||||
string(TIMESTAMP ragephoto_BUILD_YEAR "%Y" UTC)
|
||||
configure_file(src/ragephoto-extract.rc.in "${ragephoto_BINARY_DIR}/resources/ragephoto-extract.rc" @ONLY)
|
||||
configure_file(src/ragephoto-extract.rc.in resources/ragephoto-extract.rc @ONLY)
|
||||
list(APPEND EXTRACT_RESOURCES
|
||||
"${ragephoto_BINARY_DIR}/resources/ragephoto-extract.rc"
|
||||
${ragephoto_BINARY_DIR}/resources/ragephoto-extract.rc
|
||||
)
|
||||
endif()
|
||||
# RagePhoto-Extract Target + Installs
|
||||
|
@ -184,22 +180,6 @@ if (RAGEPHOTO_EXTRACT)
|
|||
set_target_properties(ragephoto-extract PROPERTIES
|
||||
INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}"
|
||||
)
|
||||
if (MSVC AND MSVC_VERSION GREATER_EQUAL 1914 AND NOT RAGEPHOTO_C_API)
|
||||
target_compile_options(ragephoto-extract PRIVATE "/Zc:__cplusplus")
|
||||
endif()
|
||||
target_link_libraries(ragephoto-extract PRIVATE ragephoto)
|
||||
install(TARGETS ragephoto-extract DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
||||
endif()
|
||||
|
||||
# CPack Package Generation
|
||||
if (RPTL_ON)
|
||||
include(InstallRequiredSystemLibraries)
|
||||
set(CPACK_PACKAGE_DESCRIPTION "Open Source RAGE Photo Parser for GTA V and RDR 2")
|
||||
set(CPACK_PACKAGE_NAME "libragephoto")
|
||||
set(CPACK_PACKAGE_VENDOR "Syping")
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR "${ragephoto_VERSION_MAJOR}")
|
||||
set(CPACK_PACKAGE_VERSION_MINOR "${ragephoto_VERSION_MINOR}")
|
||||
set(CPACK_PACKAGE_VERSION_PATCH "${ragephoto_VERSION_PATCH}")
|
||||
set(CPACK_STRIP_FILES ON)
|
||||
include(CPack)
|
||||
install(TARGETS ragephoto-extract DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
endif()
|
||||
|
|
45
README.md
45
README.md
|
@ -9,34 +9,37 @@ Open Source RAGE Photo Parser for GTA V and RDR 2
|
|||
#### Build libragephoto
|
||||
|
||||
```bash
|
||||
git clone https://github.com/Syping/libragephoto
|
||||
cmake -B libragephoto-build libragephoto
|
||||
cmake --build libragephoto-build
|
||||
sudo cmake --install libragephoto-build
|
||||
git clone https://github.com/Syping/libragephoto && cd libragephoto
|
||||
mkdir -p build && cd build
|
||||
cmake ../
|
||||
make -j $(nproc --all)
|
||||
sudo make install
|
||||
```
|
||||
|
||||
##### Optional CMake flags
|
||||
`-DCMAKE_CXX_STANDARD=17`
|
||||
`-DRAGEPHOTO_BENCHMARK=ON`
|
||||
`-DRAGEPHOTO_C_API=OFF`
|
||||
`-DRAGEPHOTO_C_LIBRARY=ON`
|
||||
`-DRAGEPHOTO_DOC=ON`
|
||||
`-DRAGEPHOTO_EXAMPLE_GTKVIEWER=ON`
|
||||
`-DRAGEPHOTO_EXAMPLE_QTVIEWER=ON`
|
||||
`-DRAGEPHOTO_EXTRACT=OFF`
|
||||
`-DRAGEPHOTO_STATIC=ON`
|
||||
`-DWITH_DOCUMENTATION=ON`
|
||||
`-DWITH_EXTRACT=OFF`
|
||||
`-DWITH_GTK_EXAMPLE=ON`
|
||||
`-DWITH_QT_EXAMPLE=ON`
|
||||
`-DBUILD_SHARED=OFF`
|
||||
|
||||
#### RagePhoto API
|
||||
#### How to Use libragephoto
|
||||
|
||||
[RagePhoto C API](https://libragephoto.syping.de/doc/RagePhoto_8h.html)
|
||||
```cpp
|
||||
RagePhoto ragePhoto;
|
||||
bool loaded = ragePhoto.load(data, size);
|
||||
std::string photo = ragePhoto.photo();
|
||||
const char* photoData = ragePhoto.photoData();
|
||||
uint32_t photoSize = ragePhoto.photoSize();
|
||||
std::string json = ragePhoto.json();
|
||||
std::string title = ragePhoto.title();
|
||||
RagePhoto::Error error = ragePhoto.error();
|
||||
uint32_t format = ragePhoto.format(); // RagePhoto::GTA5 or RagePhoto::RDR2
|
||||
```
|
||||
|
||||
[RagePhoto C API](https://libragephoto.syping.de/doc/RagePhotoC_8h.html)
|
||||
[RagePhoto C++ API](https://libragephoto.syping.de/doc/classRagePhoto.html)
|
||||
|
||||
#### libragephoto Documentation
|
||||
|
||||
[Main Page](https://libragephoto.syping.de/doc/)
|
||||
[Build libragephoto](https://libragephoto.syping.de/doc/Build.html)
|
||||
[Using libragephoto](https://libragephoto.syping.de/doc/Usage.html)
|
||||
|
||||
#### How to Use ragephoto-extract
|
||||
|
||||
```bash
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#[[**************************************************************************
|
||||
* libragephoto RAGE Photo Parser
|
||||
* Copyright (C) 2021-2023 Syping
|
||||
* Copyright (C) 2021 Syping
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
@ -16,61 +16,47 @@
|
|||
* responsible for anything with use of the software, you are self responsible.
|
||||
****************************************************************************]]
|
||||
|
||||
set(RAGEPHOTO_UNICODE "" CACHE STRING "libragephoto Unicode implementation")
|
||||
if (RAGEPHOTO_UNICODE)
|
||||
string(TOUPPER "UNICODE_${RAGEPHOTO_UNICODE}" UNICODE_DEF)
|
||||
list(APPEND LIBRAGEPHOTO_DEFINES
|
||||
"${UNICODE_DEF}"
|
||||
)
|
||||
message("-- UnicodeCvt - ${RAGEPHOTO_UNICODE}")
|
||||
# RagePhoto Unicode functionality tests
|
||||
message("-- Testing codecvt")
|
||||
try_run(CODECVT_RUN CODECVT_COMPILE ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/tests/CodecvtTest.cpp)
|
||||
if (CODECVT_COMPILE AND CODECVT_RUN EQUAL 0)
|
||||
set(CODECVT_COMPAT TRUE)
|
||||
message("-- Testing codecvt - yes")
|
||||
else()
|
||||
# RagePhoto Unicode functionality tests
|
||||
message("-- Testing codecvt")
|
||||
try_run(CODECVT_RUN CODECVT_COMPILE "${PROJECT_BINARY_DIR}" "${PROJECT_SOURCE_DIR}/tests/CodecvtTest.cpp")
|
||||
if (CODECVT_COMPILE AND CODECVT_RUN EQUAL 0)
|
||||
set(CODECVT_COMPAT TRUE)
|
||||
message("-- Testing codecvt - yes")
|
||||
message("-- Testing codecvt - no")
|
||||
endif()
|
||||
|
||||
message("-- Testing iconv")
|
||||
try_run(ICONV_RUN ICONV_COMPILE ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/tests/IconvTest.cpp)
|
||||
if (ICONV_COMPILE AND ICONV_RUN EQUAL 0)
|
||||
set(ICONV_COMPAT TRUE)
|
||||
message("-- Testing iconv - yes")
|
||||
else()
|
||||
message("-- Testing iconv - no")
|
||||
endif()
|
||||
|
||||
if (WIN32)
|
||||
message("-- Testing wincvt")
|
||||
try_run(WINCVT_RUN WINCVT_COMPILE ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/tests/WincvtTest.cpp)
|
||||
if (WINCVT_COMPILE AND WINCVT_RUN EQUAL 0)
|
||||
set(WINCVT_COMPAT TRUE)
|
||||
message("-- Testing wincvt - yes")
|
||||
else()
|
||||
message("-- Testing codecvt - no")
|
||||
endif()
|
||||
|
||||
message("-- Testing iconv")
|
||||
try_run(ICONV_RUN ICONV_COMPILE "${PROJECT_BINARY_DIR}" "${PROJECT_SOURCE_DIR}/tests/IconvTest.cpp")
|
||||
if (ICONV_COMPILE AND ICONV_RUN EQUAL 0)
|
||||
set(ICONV_COMPAT TRUE)
|
||||
message("-- Testing iconv - yes")
|
||||
else()
|
||||
message("-- Testing iconv - no")
|
||||
endif()
|
||||
|
||||
if (WIN32)
|
||||
message("-- Testing wincvt")
|
||||
try_run(WINCVT_RUN WINCVT_COMPILE "${PROJECT_BINARY_DIR}" "${PROJECT_SOURCE_DIR}/tests/WincvtTest.cpp")
|
||||
if (WINCVT_COMPILE AND WINCVT_RUN EQUAL 0)
|
||||
set(WINCVT_COMPAT TRUE)
|
||||
message("-- Testing wincvt - yes")
|
||||
else()
|
||||
message("-- Testing wincvt - no")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Unicode implementation for RagePhoto
|
||||
if (WINCVT_COMPAT)
|
||||
list(APPEND LIBRAGEPHOTO_DEFINES
|
||||
"UNICODE_WINCVT"
|
||||
)
|
||||
message("-- UnicodeCvt - wincvt")
|
||||
elseif (CODECVT_COMPAT AND NOT RAGEPHOTO_C_LIBRARY)
|
||||
list(APPEND LIBRAGEPHOTO_DEFINES
|
||||
"UNICODE_CODECVT"
|
||||
)
|
||||
message("-- UnicodeCvt - codecvt")
|
||||
elseif (ICONV_COMPAT)
|
||||
list(APPEND LIBRAGEPHOTO_DEFINES
|
||||
"UNICODE_ICONV"
|
||||
)
|
||||
message("-- UnicodeCvt - iconv")
|
||||
else()
|
||||
message("-- UnicodeCvt - none")
|
||||
message("-- Testing wincvt - no")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Unicode implementation for RagePhoto
|
||||
if (WINCVT_COMPAT)
|
||||
list(APPEND LIBRAGEPHOTO_DEFINES
|
||||
UNICODE_WINCVT
|
||||
)
|
||||
elseif (CODECVT_COMPAT)
|
||||
list(APPEND LIBRAGEPHOTO_DEFINES
|
||||
UNICODE_CODECVT
|
||||
)
|
||||
elseif (ICONV_COMPAT)
|
||||
list(APPEND LIBRAGEPHOTO_DEFINES
|
||||
UNICODE_ICONV
|
||||
)
|
||||
endif()
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
#[[**************************************************************************
|
||||
* libragephoto RAGE Photo Parser
|
||||
* Copyright (C) 2023 Syping
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* This software is provided as-is, no warranties are given to you, we are not
|
||||
* responsible for anything with use of the software, you are self responsible.
|
||||
****************************************************************************]]
|
||||
|
||||
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.13.0")
|
||||
add_executable(ragephoto-wasm ${RAGEPHOTO_HEADERS} ${RAGEPHOTO_SOURCES})
|
||||
set_target_properties(ragephoto-wasm PROPERTIES
|
||||
PREFIX "lib"
|
||||
OUTPUT_NAME "ragephoto"
|
||||
)
|
||||
target_compile_definitions(ragephoto-wasm PRIVATE
|
||||
LIBRAGEPHOTO_LIBRARY
|
||||
LIBRAGEPHOTO_WASM
|
||||
${LIBRAGEPHOTO_DEFINES}
|
||||
)
|
||||
target_link_options(ragephoto-wasm PRIVATE
|
||||
"SHELL:-O3"
|
||||
"SHELL:--no-entry"
|
||||
"SHELL:-s ALLOW_MEMORY_GROWTH=1"
|
||||
"SHELL:-s MODULARIZE=1"
|
||||
"SHELL:-s WASM=1"
|
||||
"SHELL:-s WASM_BIGINT=1"
|
||||
"SHELL:-s EXPORT_NAME=libragephotoModule"
|
||||
"SHELL:-s EXPORTED_FUNCTIONS=_free,_malloc"
|
||||
"SHELL:-s EXPORTED_RUNTIME_METHODS=ccall,cwrap"
|
||||
)
|
||||
target_include_directories(ragephoto-wasm PUBLIC
|
||||
"${ragephoto_BINARY_DIR}/include"
|
||||
"${ragephoto_SOURCE_DIR}/src"
|
||||
)
|
||||
else()
|
||||
message(WARNING "A useable WebAssembly build needs at least CMake 3.13.0 or newer")
|
||||
endif()
|
|
@ -1,16 +1,12 @@
|
|||
PROJECT_NAME = "libragephoto"
|
||||
PROJECT_NUMBER = "Version: @ragephoto_VERSION@"
|
||||
INPUT = "@CMAKE_CURRENT_SOURCE_DIR@/index.doc" \
|
||||
"@CMAKE_CURRENT_SOURCE_DIR@/build.doc" \
|
||||
"@CMAKE_CURRENT_SOURCE_DIR@/usage.doc" \
|
||||
"src"
|
||||
OUTPUT_DIRECTORY = "@CMAKE_CURRENT_BINARY_DIR@"
|
||||
EXTRACT_PRIVATE = NO
|
||||
ENABLE_PREPROCESSING = YES
|
||||
MACRO_EXPANSION = YES
|
||||
EXPAND_ONLY_PREDEF = YES
|
||||
PREDEFINED = "__cplusplus=201703L" \
|
||||
"RAGEPHOTO_CXX_STD=17" \
|
||||
"@LIBRAGEPHOTO_API@" \
|
||||
"LIBRAGEPHOTO_C_PUBLIC=" \
|
||||
"LIBRAGEPHOTO_CXX_PUBLIC="
|
||||
PREDEFINED = "protected=private" \
|
||||
"__cplusplus" \
|
||||
"@LIBRAGEPHOTO_API@"
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
/*! \page Build Build libragephoto
|
||||
|
||||
Keep sure you have CMake and a C++ compiler installed, then do the following or the equivalent necessary.
|
||||
|
||||
<h4 id="build">Build libragephoto</h4>
|
||||
\code{.sh}
|
||||
cmake -B libragephoto-build libragephoto
|
||||
cmake --build libragephoto-build
|
||||
\endcode
|
||||
|
||||
<h4 id="install">Install libragephoto</h4>
|
||||
\code{.sh}
|
||||
sudo cmake --install libragephoto-build
|
||||
\endcode
|
||||
|
||||
To customise your libragephoto build, the following <a href="#flags">Optional CMake flags</a> can be used
|
||||
|
||||
<h4 id="flags">Optional CMake flags</h4>
|
||||
\code{.sh}
|
||||
-DCMAKE_CXX_STANDARD=17
|
||||
-DRAGEPHOTO_BENCHMARK=ON
|
||||
-DRAGEPHOTO_C_API=OFF
|
||||
-DRAGEPHOTO_C_LIBRARY=ON
|
||||
-DRAGEPHOTO_DOC=ON
|
||||
-DRAGEPHOTO_EXAMPLE_GTKVIEWER=ON
|
||||
-DRAGEPHOTO_EXAMPLE_QTVIEWER=ON
|
||||
-DRAGEPHOTO_EXTRACT=OFF
|
||||
-DRAGEPHOTO_STATIC=ON
|
||||
\endcode
|
||||
*/
|
|
@ -5,22 +5,14 @@
|
|||
- Read/Write RAGE Photos error free and correct
|
||||
- Support for metadata stored in RAGE Photos
|
||||
- Export RAGE Photos to jpeg with ragephoto-extract
|
||||
- High Efficient and Simple C/C++ API
|
||||
- High Efficient and Simple C++ API
|
||||
|
||||
<b>Getting started</b>
|
||||
\subpage Build "Build libragephoto"
|
||||
\subpage Usage "Using libragephoto"
|
||||
<b>Main Class:</b>
|
||||
- RagePhoto
|
||||
|
||||
<b>Reference</b>
|
||||
RagePhoto (C++ API)
|
||||
RagePhotoA (C++ API based on C API)
|
||||
RagePhoto.h (C API)
|
||||
RagePhotoData (Data Object Struct)
|
||||
RagePhotoFormatParser (Custom Format Parser Struct)
|
||||
|
||||
<b>Project Pages</b>
|
||||
https://git.syping.de/Syping/libragephoto
|
||||
https://gitlab.com/Syping/libragephoto
|
||||
https://github.com/Syping/libragephoto
|
||||
<b>Project Pages:</b>
|
||||
- https://git.syping.de/Syping/libragephoto
|
||||
- https://gitlab.com/Syping/libragephoto
|
||||
- https://github.com/Syping/libragephoto
|
||||
|
||||
*/
|
||||
|
|
188
doc/usage.doc
188
doc/usage.doc
|
@ -1,188 +0,0 @@
|
|||
/*! \page Usage Using libragephoto
|
||||
|
||||
<h3 id="api_cxx">C++ API</h3>
|
||||
|
||||
<h4 id="cxx_include_usage">Including and using RagePhoto</h4>
|
||||
|
||||
Include RagePhoto (C++ native), RagePhotoA (C API wrapper) or \link RagePhotoB.hpp RagePhotoB \endlink (best implementation)
|
||||
|
||||
\code{.cpp}
|
||||
#include <RagePhoto>
|
||||
\endcode
|
||||
|
||||
Create a RagePhoto object
|
||||
|
||||
\code{.cpp}
|
||||
RagePhoto ragePhoto;
|
||||
\endcode
|
||||
|
||||
<h4 id="cxx_loading">Loading a Photo</h4>
|
||||
|
||||
From a file using RagePhoto::loadFile
|
||||
|
||||
\code{.cpp}
|
||||
const char* filename = "PGTA5123456789";
|
||||
const bool loaded = ragePhoto.loadFile(filename);
|
||||
\endcode
|
||||
|
||||
From a file using RagePhoto::load(const std::string&)
|
||||
|
||||
\code{.cpp}
|
||||
// Reading file
|
||||
const char* filename = "PGTA5123456789";
|
||||
std::ifstream ifs(filename, std::ios::in | std::ios::binary);
|
||||
if (!ifs.is_open())
|
||||
return;
|
||||
std::string sdata(std::istreambuf_iterator<char>{ifs}, {});
|
||||
ifs.close();
|
||||
|
||||
// Loading file
|
||||
const bool loaded = ragePhoto.load(sdata);
|
||||
\endcode
|
||||
|
||||
From a char* using RagePhoto::load(const char*, size_t)
|
||||
|
||||
\code{.cpp}
|
||||
const bool loaded = ragePhoto.load(data, size);
|
||||
\endcode
|
||||
|
||||
<h4 id="cxx_using">Using a Photo</h4>
|
||||
|
||||
\code{.cpp}
|
||||
// Returns the Photo Format
|
||||
const uint32_t format = ragePhoto.format();
|
||||
|
||||
// Returns the JPEG as std::string
|
||||
const std::string jpeg = ragePhoto.jpeg();
|
||||
|
||||
// Returns the JPEG as const char*
|
||||
const char* jpeg = ragePhoto.jpegData();
|
||||
const uint32_t size = ragePhoto.jpegSize();
|
||||
|
||||
// Returns the JSON
|
||||
const char* json = ragePhoto.json();
|
||||
|
||||
// Returns the Title
|
||||
const char* title = ragePhoto.title();
|
||||
\endcode
|
||||
|
||||
Detecting if Photo is from GTA V or RDR 2
|
||||
|
||||
\code{.cpp}
|
||||
switch (ragePhoto.format()) {
|
||||
case RagePhoto::PhotoFormat::GTA5:
|
||||
std::cout << "GTA V format detected" << std::endl;
|
||||
break;
|
||||
case RagePhoto::PhotoFormat::RDR2:
|
||||
std::cout << "RDR 2 format detected" << std::endl;
|
||||
break;
|
||||
default:
|
||||
std::cout << "Unknown format detected" << std::endl;
|
||||
}
|
||||
\endcode
|
||||
|
||||
Saving the JPEG from a Photo
|
||||
|
||||
\code{.cpp}
|
||||
// Example saveJpeg function
|
||||
bool saveJpeg(RagePhoto* ragePhoto, const std::string& filename) {
|
||||
std::ofstream ofs(filename, std::ios::out | std::ios::binary | std::ios::trunc);
|
||||
if (!ofs.is_open())
|
||||
return false;
|
||||
ofs << ragePhoto->jpeg();
|
||||
const bool saved = ofs.good();
|
||||
ofs.close();
|
||||
return saved;
|
||||
}
|
||||
|
||||
// Using the saveJpeg function
|
||||
const char* filename = "PGTA5123456789.jpg";
|
||||
const bool saved = saveJpeg(&ragePhoto, filename);
|
||||
\endcode
|
||||
|
||||
Using the JPEG in GTK+ (gtkmm)
|
||||
|
||||
\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}
|
||||
const int32_t error = ragePhoto.error();
|
||||
switch (error) {
|
||||
case RagePhoto::Error::NoFormatIdentifier:
|
||||
std::cout << "No format identifier" << std::endl;
|
||||
break;
|
||||
case RagePhoto::Error::IncompatibleFormat:
|
||||
std::cout << "Incompatible format" << std::endl;
|
||||
break;
|
||||
// Detect for more errors here...
|
||||
case RagePhoto::Error::NoError:
|
||||
std::cout << "No error detected" << std::endl;
|
||||
break;
|
||||
default:
|
||||
std::cout << "Unknown error detected" << std::endl;
|
||||
}
|
||||
\endcode
|
||||
|
||||
Available error codes: RagePhoto::Error
|
||||
|
||||
<h3 id="cmake">Including libragephoto in a CMake project</h3>
|
||||
|
||||
<h4 id="cmake_pkgconfig">Using PkgConfig</h4>
|
||||
|
||||
\code{.cmake}
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(RAGEPHOTO REQUIRED ragephoto)
|
||||
target_compile_options(your_project PRIVATE ${RAGEPHOTO_CFLAGS})
|
||||
target_link_libraries(your_project PRIVATE ${RAGEPHOTO_LIBRARIES})
|
||||
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.13.0")
|
||||
target_link_directories(your_project PRIVATE ${RAGEPHOTO_LIBRARY_DIRS})
|
||||
endif()
|
||||
target_include_directories(your_project PRIVATE ${RAGEPHOTO_INCLUDE_DIRS})
|
||||
\endcode
|
||||
|
||||
<h4 id="cmake_add_subdirectory">Using add_subdirectory</h4>
|
||||
|
||||
\code{.cmake}
|
||||
add_subdirectory(src/libragephoto)
|
||||
target_link_libraries(your_project PRIVATE ragephoto)
|
||||
\endcode
|
||||
*/
|
|
@ -1,6 +1,6 @@
|
|||
#[[**************************************************************************
|
||||
* libragephoto RAGE Photo Parser
|
||||
* Copyright (C) 2021-2022 Syping
|
||||
* Copyright (C) 2021 Syping
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*****************************************************************************
|
||||
* libragephoto RAGE Photo Parser
|
||||
* Copyright (C) 2021-2023 Syping
|
||||
* Copyright (C) 2021 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.
|
||||
*****************************************************************************/
|
||||
|
||||
#include <RagePhotoB>
|
||||
#include <RagePhoto.h>
|
||||
#include <gtkmm/application.h>
|
||||
#include <gtkmm/box.h>
|
||||
#include <gtkmm/button.h>
|
||||
|
@ -36,11 +36,11 @@ bool readPhotoFile(const std::string &filename, Gtk::Window *win, Gtk::Image *im
|
|||
if (ifs.is_open()) {
|
||||
std::string data(std::istreambuf_iterator<char>{ifs}, {});
|
||||
ifs.close();
|
||||
RagePhotoB ragePhoto;
|
||||
RagePhoto ragePhoto;
|
||||
const bool loaded = ragePhoto.load(data);
|
||||
if (!loaded) {
|
||||
const int32_t error = ragePhoto.error();
|
||||
if (error <= RagePhotoB::PhotoReadError) {
|
||||
const RagePhoto::Error error = ragePhoto.error();
|
||||
if (error <= RagePhoto::Error::PhotoReadError) {
|
||||
Gtk::MessageDialog msg(*win, "Failed to read photo: " + filename, false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_OK, true);
|
||||
msg.set_title("Open Photo");
|
||||
msg.run();
|
||||
|
@ -48,11 +48,11 @@ bool readPhotoFile(const std::string &filename, Gtk::Window *win, Gtk::Image *im
|
|||
}
|
||||
}
|
||||
GdkPixbufLoader *pixbuf_loader = gdk_pixbuf_loader_new();
|
||||
gdk_pixbuf_loader_write(pixbuf_loader, reinterpret_cast<const guchar*>(ragePhoto.jpegData()), ragePhoto.jpegSize(), nullptr);
|
||||
gdk_pixbuf_loader_write(pixbuf_loader, reinterpret_cast<const guchar*>(ragePhoto.photoData()), ragePhoto.photoSize(), NULL);
|
||||
GdkPixbuf *pixbuf = gdk_pixbuf_loader_get_pixbuf(pixbuf_loader);
|
||||
gdk_pixbuf_loader_close(pixbuf_loader, nullptr);
|
||||
gdk_pixbuf_loader_close(pixbuf_loader, NULL);
|
||||
image->set(Glib::wrap(pixbuf));
|
||||
win->set_title("RagePhoto GTK Photo Viewer - " + std::string(ragePhoto.title()));
|
||||
win->set_title("RagePhoto GTK Photo Viewer - " + ragePhoto.title());
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#[[**************************************************************************
|
||||
* libragephoto RAGE Photo Parser
|
||||
* Copyright (C) 2021-2022 Syping
|
||||
* Copyright (C) 2021 Syping
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*****************************************************************************
|
||||
* libragephoto RAGE Photo Parser
|
||||
* Copyright (C) 2021-2023 Syping
|
||||
* Copyright (C) 2021 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.
|
||||
*****************************************************************************/
|
||||
|
||||
#include <RagePhotoB>
|
||||
#include <RagePhoto.h>
|
||||
#include <QApplication>
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
|
@ -35,19 +35,19 @@ bool readPhotoFile(const QString &filename, QMainWindow *mainWindow, QLabel *pho
|
|||
if (file.open(QIODevice::ReadOnly)) {
|
||||
const QByteArray fileData = file.readAll();
|
||||
file.close();
|
||||
RagePhotoB ragePhoto;
|
||||
RagePhoto ragePhoto;
|
||||
const bool loaded = ragePhoto.load(fileData.data(), static_cast<size_t>(fileData.size()));
|
||||
if (!loaded) {
|
||||
const int32_t error = ragePhoto.error();
|
||||
if (error <= RagePhotoB::PhotoReadError) {
|
||||
const RagePhoto::Error error = ragePhoto.error();
|
||||
if (error <= RagePhoto::Error::PhotoReadError) {
|
||||
QMessageBox::warning(mainWindow, "Open Photo", "Failed to read photo: " + filename);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
const QByteArray jpegData = QByteArray::fromRawData(ragePhoto.jpegData(), ragePhoto.jpegSize());
|
||||
const QImage image = QImage::fromData(jpegData, "JPEG");
|
||||
const QByteArray photoData = QByteArray::fromRawData(ragePhoto.photoData(), ragePhoto.photoSize());
|
||||
const QImage image = QImage::fromData(photoData, "JPEG");
|
||||
photoLabel->setPixmap(QPixmap::fromImage(image));
|
||||
mainWindow->setWindowTitle(QStringLiteral("RagePhoto Qt Photo Viewer - ") + QString::fromUtf8(ragePhoto.title()));
|
||||
mainWindow->setWindowTitle("RagePhoto Qt Photo Viewer - " + QString::fromStdString(ragePhoto.title()));
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
#include "RagePhoto.hpp"
|
|
@ -1,6 +1,6 @@
|
|||
/*****************************************************************************
|
||||
* libragephoto RAGE Photo Parser
|
||||
* Copyright (C) 2021-2023 Syping
|
||||
* Copyright (C) 2021 Syping
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
@ -16,8 +16,7 @@
|
|||
* responsible for anything with use of the software, you are self responsible.
|
||||
*****************************************************************************/
|
||||
|
||||
#include "RagePhoto.h"
|
||||
#include <stdio.h>
|
||||
#include "RagePhotoC.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
@ -33,15 +32,12 @@ int main(int argc, char *argv[])
|
|||
const int loaded = ragephoto_loadfile(ragephoto_in, argv[1]);
|
||||
|
||||
if (loaded != 1) {
|
||||
const int32_t error = ragephoto_error(ragephoto_in);
|
||||
if (error == RAGEPHOTO_ERROR_UNINITIALISED) {
|
||||
if (ragephoto_error(ragephoto_in) == 0) {
|
||||
printf("Failed to open file: %s\n", argv[1]);
|
||||
ragephoto_close(ragephoto_in);
|
||||
return 1;
|
||||
}
|
||||
else if (error <= RAGEPHOTO_ERROR_PHOTOREADERROR) {
|
||||
else if (ragephoto_getphotosize(ragephoto_in) <= 0) {
|
||||
printf("Failed to load photo\n");
|
||||
ragephoto_close(ragephoto_in);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@ -55,26 +51,20 @@ int main(int argc, char *argv[])
|
|||
#endif
|
||||
if (!file) {
|
||||
printf("Failed to write file: %s\n", argv[2]);
|
||||
ragephoto_close(ragephoto_in);
|
||||
return 1;
|
||||
}
|
||||
const size_t jpegSize = ragephoto_getphotosize(ragephoto_in);
|
||||
const size_t fileSize = fwrite(ragephoto_getphotojpeg(ragephoto_in), sizeof(char), jpegSize, file);
|
||||
const size_t size = fwrite(ragephoto_getphotojpeg(ragephoto_in), sizeof(char), ragephoto_getphotosize(ragephoto_in), file);
|
||||
fclose(file);
|
||||
|
||||
if (fileSize != jpegSize) {
|
||||
if (size != ragephoto_getphotosize(ragephoto_in)) {
|
||||
printf("Failed to write file: %s\n", argv[2]);
|
||||
ragephoto_close(ragephoto_in);
|
||||
return 1;
|
||||
}
|
||||
|
||||
const uint32_t photoFormat = ragephoto_getphotoformat(ragephoto_in);
|
||||
if (photoFormat == RAGEPHOTO_FORMAT_GTA5)
|
||||
if (ragephoto_getphotoformat(ragephoto_in) == ragephoto_format_gta5())
|
||||
printf("GTA V Photo successfully exported\n");
|
||||
else if (photoFormat == RAGEPHOTO_FORMAT_RDR2)
|
||||
printf("RDR 2 Photo successfully exported\n");
|
||||
else
|
||||
printf("Photo successfully exported\n");
|
||||
printf("RDR 2 Photo successfully exported\n");
|
||||
|
||||
ragephoto_close(ragephoto_in);
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*****************************************************************************
|
||||
* libragephoto RAGE Photo Parser
|
||||
* Copyright (C) 2021-2023 Syping
|
||||
* Copyright (C) 2021 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.
|
||||
*****************************************************************************/
|
||||
|
||||
#include <RagePhotoB>
|
||||
#include "RagePhoto.h"
|
||||
#include <fstream>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
@ -27,18 +27,17 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
// Initialise RagePhoto
|
||||
RagePhotoB ragePhoto;
|
||||
RagePhoto ragePhoto;
|
||||
|
||||
// Load Photo
|
||||
const bool loaded = ragePhoto.loadFile(argv[1]);
|
||||
|
||||
if (!loaded) {
|
||||
const int32_t error = ragePhoto.error();
|
||||
if (error == RagePhotoB::Uninitialised) {
|
||||
if (ragePhoto.error() == RagePhoto::Error::Uninitialised) {
|
||||
std::cout << "Failed to open file: " << argv[1] << std::endl;
|
||||
return 1;
|
||||
}
|
||||
else if (error <= RagePhotoB::PhotoReadError) {
|
||||
else if (ragePhoto.error() <= RagePhoto::Error::PhotoReadError) {
|
||||
std::cout << "Failed to load photo" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
@ -50,7 +49,7 @@ int main(int argc, char *argv[])
|
|||
std::cout << "Failed to write file: " << argv[2] << std::endl;
|
||||
return 1;
|
||||
}
|
||||
ofs << ragePhoto.jpeg();
|
||||
ofs << ragePhoto.photo();
|
||||
const bool ok = ofs.good();
|
||||
ofs.close();
|
||||
|
||||
|
@ -59,13 +58,10 @@ int main(int argc, char *argv[])
|
|||
return 1;
|
||||
}
|
||||
|
||||
const uint32_t photoFormat = ragePhoto.format();
|
||||
if (photoFormat == RagePhotoB::GTA5)
|
||||
if (ragePhoto.format() == RagePhoto::GTA5)
|
||||
std::cout << "GTA V Photo successfully exported" << std::endl;
|
||||
else if (photoFormat == RagePhotoB::RDR2)
|
||||
std::cout << "RDR 2 Photo successfully exported" << std::endl;
|
||||
else
|
||||
std::cout << "Photo successfully exported" << std::endl;
|
||||
std::cout << "RDR 2 Photo successfully exported" << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
1230
src/RagePhoto.c
1230
src/RagePhoto.c
File diff suppressed because it is too large
Load Diff
1089
src/RagePhoto.cpp
1089
src/RagePhoto.cpp
File diff suppressed because it is too large
Load Diff
436
src/RagePhoto.h
436
src/RagePhoto.h
|
@ -1,6 +1,6 @@
|
|||
/*****************************************************************************
|
||||
* libragephoto RAGE Photo Parser
|
||||
* Copyright (C) 2021-2023 Syping
|
||||
* Copyright (C) 2021 Syping
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
@ -19,297 +19,157 @@
|
|||
#ifndef RAGEPHOTO_H
|
||||
#define RAGEPHOTO_H
|
||||
|
||||
#include "RagePhotoLibrary.h"
|
||||
#include "RagePhotoTypedefs.h"
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
#include "libragephoto_global.h"
|
||||
#include "RagePhotoData.h"
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
|
||||
/** C API for RagePhoto.
|
||||
* \file RagePhoto.h
|
||||
class RagePhotoPrivate;
|
||||
|
||||
/**
|
||||
* \brief GTA V and RDR 2 Photo Parser.
|
||||
*/
|
||||
class LIBRAGEPHOTO_CXX_EXPORT RagePhoto
|
||||
{
|
||||
public:
|
||||
/** Default sizes */
|
||||
enum DefaultSize : uint32_t {
|
||||
DEFAULT_GTA5_PHOTOBUFFER = 524288UL, /**< GTA V default Photo Buffer Size */
|
||||
DEFAULT_RDR2_PHOTOBUFFER = 1048576UL, /**< RDR 2 default Photo Buffer Size */
|
||||
DEFAULT_DESCBUFFER = 256UL, /**< Default Description Buffer Size */
|
||||
DEFAULT_JSONBUFFER = 3072UL, /**< Default JSON Buffer Size */
|
||||
DEFAULT_TITLBUFFER = 256UL, /**< Default Title Buffer Size */
|
||||
GTA5_HEADERSIZE = 264UL, /**< GTA V Header Size */
|
||||
RDR2_HEADERSIZE = 272UL, /**< RDR 2 Header Size */
|
||||
};
|
||||
/** Parsing and set errors */
|
||||
enum class Error : uint8_t {
|
||||
DescBufferTight = 38, /**< Description Buffer is too tight */
|
||||
DescMallocError = 30, /**< Description Buffer can't be allocated */
|
||||
DescReadError = 31, /**< Description can't be read successfully */
|
||||
HeaderBufferTight = 34, /**< Header Buffer is too tight */
|
||||
IncompatibleFormat = 2, /**< Format is incompatible */
|
||||
IncompleteChecksum = 6, /**< Header checksum is incomplete */
|
||||
IncompleteDescBuffer = 29, /**< Description Buffer Size is incomplete */
|
||||
IncompleteDescMarker = 27, /**< Description Marker is incomplete */
|
||||
IncompleteDescOffset = 10, /**< Description Offset is incomplete */
|
||||
IncompleteEOF = 7, /**< End Of File Offset is incomplete */
|
||||
IncompleteHeader = 3, /**< Header is incomplete */
|
||||
IncompleteJendMarker = 32, /**< JEND Marker is incomplete */
|
||||
IncompleteJpegMarker = 11, /**< JPEG Marker is incomplete */
|
||||
IncompleteJsonBuffer = 19, /**< JSON Buffer Size is incomplete */
|
||||
IncompleteJsonMarker = 17, /**< JSON Marker incomplete */
|
||||
IncompleteJsonOffset = 8, /**< JSON Offset incomplete */
|
||||
IncompletePhotoBuffer = 13, /**< Photo Buffer Size is incomplete */
|
||||
IncompletePhotoSize = 14, /**< Photo Size is incomplete */
|
||||
IncompleteTitleBuffer = 24, /**< Title Buffer Size is incomplete */
|
||||
IncompleteTitleMarker = 22, /**< Title Marker is incomplete */
|
||||
IncompleteTitleOffset = 9, /**< Title Offset is incomplete */
|
||||
IncorrectDescMarker = 28, /**< Description Marker is incorrect */
|
||||
IncorrectJendMarker = 33, /**< JEND Marker is incorrect */
|
||||
IncorrectJpegMarker = 12, /**< JPEG Marker is incorrect */
|
||||
IncorrectJsonMarker = 18, /**< JSON Marker is incorrect */
|
||||
IncorrectTitleMarker = 23, /**< Title Marker is incorrect */
|
||||
JsonBufferTight = 36, /**< JSON Buffer is too tight */
|
||||
JsonMallocError = 20, /**< JSON Buffer can't be allocated */
|
||||
JsonReadError = 21, /**< JSON can't be read successfully */
|
||||
NoError = 255, /**< Finished without errors */
|
||||
NoFormatIdentifier = 1, /**< No format detected, empty file */
|
||||
PhotoBufferTight = 35, /**< Photo Buffer is too tight */
|
||||
PhotoMallocError = 15, /**< Photo Buffer can't be allocated */
|
||||
PhotoReadError = 16, /**< Photo can't be read */
|
||||
TitleBufferTight = 37, /**< Title Buffer is too tight */
|
||||
TitleMallocError = 25, /**< Title Buffer can't be allocated */
|
||||
TitleReadError = 26, /**< Title can't be read */
|
||||
UnicodeHeaderError = 5, /**< Header can't be decoded */
|
||||
UnicodeInitError = 4, /**< Failed to initialise Unicode decoder */
|
||||
Uninitialised = 0, /**< Uninitialised, file access failed */
|
||||
};
|
||||
/** Photo Formats */
|
||||
enum PhotoFormat : uint32_t {
|
||||
GTA5 = 0x01000000UL, /**< GTA V Photo Format */
|
||||
RDR2 = 0x04000000UL, /**< RDR 2 Photo Format */
|
||||
};
|
||||
RagePhoto();
|
||||
~RagePhoto();
|
||||
void clear(); /**< Resets the RagePhoto instance to default values. */
|
||||
/** Loads a Photo from a const char*.
|
||||
* \param data Photo data
|
||||
* \param size Photo data size
|
||||
*/
|
||||
bool load(const char *data, size_t size);
|
||||
/** Loads a Photo from a std::string.
|
||||
* \param data Photo data
|
||||
*/
|
||||
bool load(const std::string &data);
|
||||
/** Loads a Photo from a file.
|
||||
* \param filename File to load
|
||||
*/
|
||||
bool loadFile(const std::string &filename);
|
||||
Error error() const; /**< Returns the last error occurred. */
|
||||
uint32_t format() const; /**< Returns the Photo Format (GTA V or RDR 2). */
|
||||
const std::string photo() const; /**< Returns the Photo JPEG data. */
|
||||
const char *photoData() const; /**< Returns the Photo JPEG data. */
|
||||
uint32_t photoSize() const; /**< Returns the Photo JPEG data size. */
|
||||
const std::string& description() const; /**< Returns the Photo description. */
|
||||
const std::string& json() const; /**< Returns the Photo JSON data. */
|
||||
const std::string& header() const; /**< Returns the Photo header. */
|
||||
const std::string& title() const; /**< Returns the Photo title. */
|
||||
static const char* version(); /**< Returns the library version. */
|
||||
/** Saves a Photo to a char*.
|
||||
* \param data Photo data
|
||||
* \param photoFormat Photo Format (GTA V or RDR 2)
|
||||
*/
|
||||
bool save(char *data, uint32_t photoFormat);
|
||||
/** Saves a Photo to a char*.
|
||||
* \param data Photo data
|
||||
*/
|
||||
bool save(char *data);
|
||||
/** Saves a Photo to a std::string.
|
||||
* \param photoFormat Photo Format (GTA V or RDR 2)
|
||||
* \param ok \p true when saved successfully
|
||||
*/
|
||||
const std::string save(uint32_t photoFormat, bool *ok = nullptr);
|
||||
/** Saves a Photo to a std::string.
|
||||
* \param ok \p true when saved successfully
|
||||
*/
|
||||
const std::string save(bool *ok = nullptr);
|
||||
bool saveFile(const std::string &filename, uint32_t photoFormat); /**< Saves a Photo to a file. */
|
||||
bool saveFile(const std::string &filename); /**< Saves a Photo to a file. */
|
||||
static size_t saveSize(RagePhotoData *ragePhotoData, uint32_t photoFormat); /**< Returns the Photo save file size. */
|
||||
static size_t saveSize(RagePhotoData *ragePhotoData); /**< Returns the Photo save file size. */
|
||||
size_t saveSize(uint32_t photoFormat); /**< Returns the Photo save file size. */
|
||||
size_t saveSize(); /**< Returns the Photo save file size. */
|
||||
void setBufferDefault(); /**< Sets all cross-format Buffer to default size. */
|
||||
static void setBufferDefault(RagePhotoData *ragePhotoData); /**< Sets all cross-format Buffer to default size. */
|
||||
void setBufferOffsets(); /**< Moves all Buffer offsets to correct position. */
|
||||
static void setBufferOffsets(RagePhotoData *ragePhotoData); /**< Moves all Buffer offsets to correct position. */
|
||||
void setDescription(const std::string &description, uint32_t bufferSize = 0); /**< Sets the Photo description. */
|
||||
void setFormat(uint32_t photoFormat); /**< Sets the Photo Format (GTA V or RDR 2). */
|
||||
void setFormatLoadFunction(uint32_t photoFormat, RagePhotoLoadFunc func); /**< Sets a custom Photo Format load function. */
|
||||
void setJson(const std::string &json, uint32_t bufferSize = 0); /**< Sets the Photo JSON data. */
|
||||
void setHeader(const std::string &header, uint32_t headerSum); /**< Sets the Photo header. (EXPERT ONLY) */
|
||||
/** Sets the Photo JPEG data.
|
||||
* \param data JPEG data
|
||||
* \param size JPEG data size
|
||||
* \param bufferSize JPEG buffer size
|
||||
*/
|
||||
bool setPhoto(const char *data, uint32_t size, uint32_t bufferSize = 0);
|
||||
/** Sets the Photo JPEG data.
|
||||
* \param data JPEG data
|
||||
* \param bufferSize JPEG buffer size
|
||||
*/
|
||||
bool setPhoto(const std::string &data, uint32_t bufferSize = 0);
|
||||
void setTitle(const std::string &title, uint32_t bufferSize = 0); /**< Sets the Photo title. */
|
||||
|
||||
/** RagePhoto C instance/C++ class typedef. */
|
||||
typedef void* ragephoto_t;
|
||||
|
||||
/** Opens a \p ragephoto_t instance. */
|
||||
LIBRAGEPHOTO_C_PUBLIC ragephoto_t ragephoto_open();
|
||||
|
||||
/** Add a custom defined RagePhotoFormatParser.
|
||||
* \param instance \p ragephoto_t instance
|
||||
* \param rp_parser RagePhotoFormatParser parser to add
|
||||
*/
|
||||
LIBRAGEPHOTO_C_PUBLIC void ragephoto_addparser(ragephoto_t instance, RagePhotoFormatParser *rp_parser);
|
||||
|
||||
/** Resets the RagePhotoData object to default values.
|
||||
* \param instance \p ragephoto_t instance
|
||||
*/
|
||||
LIBRAGEPHOTO_C_PUBLIC void ragephoto_clear(ragephoto_t instance);
|
||||
|
||||
/** Resets the RagePhotoData object to default values.
|
||||
* \param rp_data RagePhotoData object
|
||||
*/
|
||||
LIBRAGEPHOTO_C_PUBLIC void ragephotodata_clear(RagePhotoData *rp_data);
|
||||
|
||||
/** Loads a Photo from a const char*.
|
||||
* \param instance \p ragephoto_t instance
|
||||
* \param data Photo data
|
||||
* \param size Photo data size
|
||||
*/
|
||||
LIBRAGEPHOTO_C_PUBLIC bool ragephoto_load(ragephoto_t instance, const char *data, size_t size);
|
||||
|
||||
/** Loads a Photo from a const char*.
|
||||
* \param rp_data RagePhotoData object
|
||||
* \param rp_parser RagePhotoFormatParser parser array
|
||||
* \param data Photo data
|
||||
* \param size Photo data 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.
|
||||
* \param instance \p ragephoto_t instance
|
||||
* \param filename File to load
|
||||
*/
|
||||
LIBRAGEPHOTO_C_PUBLIC bool ragephoto_loadfile(ragephoto_t instance, const char *filename);
|
||||
|
||||
/** Returns the last error occurred.
|
||||
* \param instance \p ragephoto_t instance
|
||||
*/
|
||||
LIBRAGEPHOTO_C_PUBLIC int32_t ragephoto_error(ragephoto_t instance);
|
||||
|
||||
/** Returns the GTA V default Photo Buffer Size. */
|
||||
LIBRAGEPHOTO_C_PUBLIC uint32_t ragephoto_defpbuf_gta5();
|
||||
|
||||
/** Returns the RDR 2 default Photo Buffer Size. */
|
||||
LIBRAGEPHOTO_C_PUBLIC uint32_t ragephoto_defpbuf_rdr2();
|
||||
|
||||
/** Returns the GTA V Photo Format. */
|
||||
LIBRAGEPHOTO_C_PUBLIC uint32_t ragephoto_format_gta5();
|
||||
|
||||
/** Returns the RDR 2 Photo Format. */
|
||||
LIBRAGEPHOTO_C_PUBLIC uint32_t ragephoto_format_rdr2();
|
||||
|
||||
/** Returns the internal RagePhotoData object.
|
||||
* \param instance \p ragephoto_t instance
|
||||
*/
|
||||
LIBRAGEPHOTO_C_PUBLIC RagePhotoData* ragephoto_getphotodata(ragephoto_t instance);
|
||||
|
||||
/** Returns the Photo description.
|
||||
* \param instance \p ragephoto_t instance
|
||||
*/
|
||||
LIBRAGEPHOTO_C_PUBLIC const char* ragephoto_getphotodesc(ragephoto_t instance);
|
||||
|
||||
/** Returns the Photo Format (GTA V or RDR 2).
|
||||
* \param instance \p ragephoto_t instance
|
||||
*/
|
||||
LIBRAGEPHOTO_C_PUBLIC uint32_t ragephoto_getphotoformat(ragephoto_t instance);
|
||||
|
||||
/** Returns the Photo JPEG data.
|
||||
* \param instance \p ragephoto_t instance
|
||||
*/
|
||||
LIBRAGEPHOTO_C_PUBLIC const char* ragephoto_getphotojpeg(ragephoto_t instance);
|
||||
|
||||
/** Returns the Photo JSON data.
|
||||
* \param instance \p ragephoto_t instance
|
||||
*/
|
||||
LIBRAGEPHOTO_C_PUBLIC const char* ragephoto_getphotojson(ragephoto_t instance);
|
||||
|
||||
/** Returns the Photo header.
|
||||
* \param instance \p ragephoto_t instance
|
||||
*/
|
||||
LIBRAGEPHOTO_C_PUBLIC const char* ragephoto_getphotoheader(ragephoto_t instance);
|
||||
|
||||
/** Returns the Photo JPEG sign.
|
||||
* \param instance \p ragephoto_t instance
|
||||
*/
|
||||
LIBRAGEPHOTO_C_PUBLIC uint64_t ragephoto_getphotosign(ragephoto_t instance);
|
||||
|
||||
/** Returns the Photo JPEG sign.
|
||||
* \param instance \p ragephoto_t instance
|
||||
* \param photoFormat Photo Format (GTA V or RDR 2)
|
||||
*/
|
||||
LIBRAGEPHOTO_C_PUBLIC uint64_t ragephoto_getphotosignf(ragephoto_t instance, uint32_t photoFormat);
|
||||
|
||||
/** Returns the Photo JPEG sign.
|
||||
* \param rp_data RagePhotoData object
|
||||
*/
|
||||
LIBRAGEPHOTO_C_PUBLIC uint64_t ragephotodata_getphotosign(RagePhotoData *rp_data);
|
||||
|
||||
/** Returns the Photo JPEG sign.
|
||||
* \param rp_data RagePhotoData object
|
||||
* \param photoFormat Photo Format (GTA V or RDR 2)
|
||||
*/
|
||||
LIBRAGEPHOTO_C_PUBLIC uint64_t ragephotodata_getphotosignf(RagePhotoData *rp_data, uint32_t photoFormat);
|
||||
|
||||
/** Returns the Photo JPEG data size.
|
||||
* \param instance \p ragephoto_t instance
|
||||
*/
|
||||
LIBRAGEPHOTO_C_PUBLIC uint32_t ragephoto_getphotosize(ragephoto_t instance);
|
||||
|
||||
/** Returns the Photo title.
|
||||
* \param instance \p ragephoto_t instance
|
||||
*/
|
||||
LIBRAGEPHOTO_C_PUBLIC const char* ragephoto_getphototitle(ragephoto_t instance);
|
||||
|
||||
/** Returns the Photo save file size.
|
||||
* \param instance \p ragephoto_t instance
|
||||
*/
|
||||
LIBRAGEPHOTO_C_PUBLIC size_t ragephoto_getsavesize(ragephoto_t instance);
|
||||
|
||||
/** Returns the Photo save file size.
|
||||
* \param rp_data RagePhotoData object
|
||||
* \param rp_parser RagePhotoFormatParser parser array
|
||||
*/
|
||||
LIBRAGEPHOTO_C_PUBLIC size_t ragephotodata_getsavesize(RagePhotoData *rp_data, RagePhotoFormatParser *rp_parser);
|
||||
|
||||
/** Returns the Photo save file size.
|
||||
* \param instance \p ragephoto_t instance
|
||||
* \param photoFormat Photo Format (GTA V or RDR 2)
|
||||
*/
|
||||
LIBRAGEPHOTO_C_PUBLIC size_t ragephoto_getsavesizef(ragephoto_t instance, uint32_t photoFormat);
|
||||
|
||||
/** Returns the Photo save file size.
|
||||
* \param rp_data RagePhotoData object
|
||||
* \param rp_parser RagePhotoFormatParser parser array
|
||||
* \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);
|
||||
|
||||
/** Saves a Photo to a char*.
|
||||
* \param instance \p ragephoto_t instance
|
||||
* \param data Photo data
|
||||
*/
|
||||
LIBRAGEPHOTO_C_PUBLIC bool ragephoto_save(ragephoto_t instance, char *data);
|
||||
|
||||
/** Saves a Photo to a char*.
|
||||
* \param rp_data RagePhotoData object
|
||||
* \param rp_parser RagePhotoFormatParser parser array
|
||||
* \param data Photo data
|
||||
*/
|
||||
LIBRAGEPHOTO_C_PUBLIC bool ragephotodata_save(RagePhotoData *rp_data, RagePhotoFormatParser *rp_parser, char *data);
|
||||
|
||||
/** Saves a Photo to a char*.
|
||||
* \param instance \p ragephoto_t instance
|
||||
* \param data Photo data
|
||||
* \param photoFormat Photo Format (GTA V or RDR 2)
|
||||
*/
|
||||
LIBRAGEPHOTO_C_PUBLIC bool ragephoto_savef(ragephoto_t instance, char *data, uint32_t photoFormat);
|
||||
|
||||
/** Saves a Photo to a char*.
|
||||
* \param rp_data RagePhotoData object
|
||||
* \param rp_parser RagePhotoFormatParser parser array
|
||||
* \param data Photo data
|
||||
* \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);
|
||||
|
||||
/** Saves a Photo to a file.
|
||||
* \param instance \p ragephoto_t instance
|
||||
* \param filename File to save
|
||||
*/
|
||||
LIBRAGEPHOTO_C_PUBLIC bool ragephoto_savefile(ragephoto_t instance, const char *filename);
|
||||
|
||||
/** Saves a Photo to a file.
|
||||
* \param instance \p ragephoto_t instance
|
||||
* \param filename File to save
|
||||
* \param photoFormat Photo Format (GTA V or RDR 2)
|
||||
*/
|
||||
LIBRAGEPHOTO_C_PUBLIC bool ragephoto_savefilef(ragephoto_t instance, const char *filename, uint32_t photoFormat);
|
||||
|
||||
/** Sets all cross-format Buffer to default size.
|
||||
* \param instance \p ragephoto_t instance
|
||||
*/
|
||||
LIBRAGEPHOTO_C_PUBLIC void ragephoto_setbufferdefault(ragephoto_t instance);
|
||||
|
||||
/** Sets all cross-format Buffer to default size.
|
||||
* \param rp_data RagePhotoData object
|
||||
*/
|
||||
LIBRAGEPHOTO_C_PUBLIC void ragephotodata_setbufferdefault(RagePhotoData *rp_data);
|
||||
|
||||
/** Moves all Buffer offsets to correct position.
|
||||
* \param instance \p ragephoto_t instance
|
||||
*/
|
||||
LIBRAGEPHOTO_C_PUBLIC void ragephoto_setbufferoffsets(ragephoto_t instance);
|
||||
|
||||
/** Moves all Buffer offsets to correct position.
|
||||
* \param rp_data RagePhotoData object
|
||||
*/
|
||||
LIBRAGEPHOTO_C_PUBLIC void ragephotodata_setbufferoffsets(RagePhotoData *rp_data);
|
||||
|
||||
/** Sets the internal RagePhotoData object.
|
||||
* \param instance \p ragephoto_t instance
|
||||
* \param rp_data RagePhotoData object being set
|
||||
*/
|
||||
LIBRAGEPHOTO_C_PUBLIC bool ragephoto_setphotodata(ragephoto_t instance, RagePhotoData *rp_data);
|
||||
|
||||
/** Copies RagePhotoData object to internal RagePhotoData object.
|
||||
* \param instance \p ragephoto_t instance
|
||||
* \param rp_data RagePhotoData object being copied
|
||||
*/
|
||||
LIBRAGEPHOTO_C_PUBLIC bool ragephoto_setphotodatac(ragephoto_t instance, RagePhotoData *rp_data);
|
||||
|
||||
/** Sets the Photo description.
|
||||
* \param instance \p ragephoto_t instance
|
||||
* \param description Description
|
||||
* \param bufferSize Description buffer size
|
||||
*
|
||||
* Default bufferSize: 256UL
|
||||
*/
|
||||
LIBRAGEPHOTO_C_PUBLIC void ragephoto_setphotodesc(ragephoto_t instance, const char *description, uint32_t bufferSize);
|
||||
|
||||
/** Sets the Photo Format (GTA V or RDR 2).
|
||||
* \param instance \p ragephoto_t instance
|
||||
* \param photoFormat Photo Format (GTA V or RDR 2)
|
||||
*/
|
||||
LIBRAGEPHOTO_C_PUBLIC void ragephoto_setphotoformat(ragephoto_t instance, uint32_t photoFormat);
|
||||
|
||||
/** Sets the Photo JPEG data.
|
||||
* \param instance \p ragephoto_t instance
|
||||
* \param data JPEG data
|
||||
* \param size JPEG data size
|
||||
* \param bufferSize JPEG buffer size
|
||||
*
|
||||
* Default bufferSize: ragephoto_defpbuf_gta5() or ragephoto_defpbuf_rdr2()
|
||||
*/
|
||||
LIBRAGEPHOTO_C_PUBLIC bool ragephoto_setphotojpeg(ragephoto_t instance, const char *data, uint32_t size, uint32_t bufferSize);
|
||||
|
||||
/** Sets the Photo JSON data.
|
||||
* \param instance \p ragephoto_t instance
|
||||
* \param json JSON data
|
||||
* \param bufferSize JSON data buffer size
|
||||
*
|
||||
* Default bufferSize: 3072UL
|
||||
*/
|
||||
LIBRAGEPHOTO_C_PUBLIC void ragephoto_setphotojson(ragephoto_t instance, const char *json, uint32_t bufferSize);
|
||||
|
||||
/** Sets the Photo header. */
|
||||
LIBRAGEPHOTO_C_PUBLIC void ragephoto_setphotoheader(ragephoto_t instance, const char *header, uint32_t headerSum);
|
||||
|
||||
/** Sets the Photo header. (RDR 2) */
|
||||
LIBRAGEPHOTO_C_PUBLIC void ragephoto_setphotoheader2(ragephoto_t instance, const char *header, uint32_t headerSum, uint32_t headerSum2);
|
||||
|
||||
/** Sets the Photo title.
|
||||
* \param instance \p ragephoto_t instance
|
||||
* \param title Title
|
||||
* \param bufferSize Title buffer size
|
||||
*
|
||||
* Default bufferSize: 256UL
|
||||
*/
|
||||
LIBRAGEPHOTO_C_PUBLIC void ragephoto_setphototitle(ragephoto_t instance, const char *title, uint32_t bufferSize);
|
||||
|
||||
/** Closes a \p ragephoto_t instance.
|
||||
* \param instance \p ragephoto_t instance
|
||||
*/
|
||||
LIBRAGEPHOTO_C_PUBLIC void ragephoto_close(ragephoto_t instance);
|
||||
|
||||
/** Returns the library version. */
|
||||
LIBRAGEPHOTO_C_PUBLIC const char* ragephoto_version();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
private:
|
||||
RagePhotoPrivate *m_rpp;
|
||||
};
|
||||
#else
|
||||
#include "RagePhotoC.h"
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // RAGEPHOTO_H
|
||||
|
|
|
@ -1,191 +0,0 @@
|
|||
/*****************************************************************************
|
||||
* libragephoto RAGE Photo Parser
|
||||
* Copyright (C) 2021-2023 Syping
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* This software is provided as-is, no warranties are given to you, we are not
|
||||
* responsible for anything with use of the software, you are self responsible.
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef RAGEPHOTO_HPP
|
||||
#define RAGEPHOTO_HPP
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include "RagePhotoLibrary.h"
|
||||
#include "RagePhotoTypedefs.h"
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
|
||||
/**
|
||||
* \brief GTA V and RDR 2 Photo Parser.
|
||||
*/
|
||||
class LIBRAGEPHOTO_CXX_PUBLIC RagePhoto
|
||||
{
|
||||
public:
|
||||
/** Default sizes */
|
||||
enum DefaultSize : uint32_t {
|
||||
DEFAULT_GTA5_PHOTOBUFFER = 524288UL, /**< GTA V default Photo Buffer Size */
|
||||
DEFAULT_RDR2_PHOTOBUFFER = 1048576UL, /**< RDR 2 default Photo Buffer Size */
|
||||
DEFAULT_DESCBUFFER = 256UL, /**< Default Description Buffer Size */
|
||||
DEFAULT_JSONBUFFER = 3072UL, /**< Default JSON Buffer Size */
|
||||
DEFAULT_TITLBUFFER = 256UL, /**< Default Title Buffer Size */
|
||||
GTA5_HEADERSIZE = 264UL, /**< GTA V Header Size */
|
||||
RDR2_HEADERSIZE = 272UL, /**< RDR 2 Header Size */
|
||||
};
|
||||
/** Parsing and set errors */
|
||||
enum Error : int32_t {
|
||||
DescBufferTight = 39L, /**< Description Buffer is too tight */
|
||||
DescMallocError = 31L, /**< Description Buffer can't be allocated */
|
||||
DescReadError = 32L, /**< Description can't be read successfully */
|
||||
HeaderBufferTight = 35L, /**< Header Buffer is too tight */
|
||||
HeaderMallocError = 4L, /**< Header Buffer can't be allocated */
|
||||
IncompatibleFormat = 2L, /**< Format is incompatible */
|
||||
IncompleteChecksum = 7L, /**< Header checksum is incomplete */
|
||||
IncompleteDescBuffer = 30L, /**< Description Buffer Size is incomplete */
|
||||
IncompleteDescMarker = 28L, /**< Description Marker is incomplete */
|
||||
IncompleteDescOffset = 11L, /**< Description Offset is incomplete */
|
||||
IncompleteEOF = 8L, /**< End Of File Offset is incomplete */
|
||||
IncompleteHeader = 3L, /**< Header is incomplete */
|
||||
IncompleteJendMarker = 33L, /**< JEND Marker is incomplete */
|
||||
IncompleteJpegMarker = 12L, /**< JPEG Marker is incomplete */
|
||||
IncompleteJsonBuffer = 20L, /**< JSON Buffer Size is incomplete */
|
||||
IncompleteJsonMarker = 18L, /**< JSON Marker incomplete */
|
||||
IncompleteJsonOffset = 9L, /**< JSON Offset incomplete */
|
||||
IncompletePhotoBuffer = 14L, /**< Photo Buffer Size is incomplete */
|
||||
IncompletePhotoSize = 15L, /**< Photo Size is incomplete */
|
||||
IncompleteTitleBuffer = 25L, /**< Title Buffer Size is incomplete */
|
||||
IncompleteTitleMarker = 23L, /**< Title Marker is incomplete */
|
||||
IncompleteTitleOffset = 10L, /**< Title Offset is incomplete */
|
||||
IncorrectDescMarker = 29L, /**< Description Marker is incorrect */
|
||||
IncorrectJendMarker = 34L, /**< JEND Marker is incorrect */
|
||||
IncorrectJpegMarker = 13L, /**< JPEG Marker is incorrect */
|
||||
IncorrectJsonMarker = 19L, /**< JSON Marker is incorrect */
|
||||
IncorrectTitleMarker = 24L, /**< Title Marker is incorrect */
|
||||
JsonBufferTight = 37L, /**< JSON Buffer is too tight */
|
||||
JsonMallocError = 21L, /**< JSON Buffer can't be allocated */
|
||||
JsonReadError = 22L, /**< JSON can't be read successfully */
|
||||
NoError = 255L, /**< Finished without errors */
|
||||
NoFormatIdentifier = 1L, /**< No format detected, empty file */
|
||||
PhotoBufferTight = 36L, /**< Photo Buffer is too tight */
|
||||
PhotoMallocError = 16L, /**< Photo Buffer can't be allocated */
|
||||
PhotoReadError = 17L, /**< Photo can't be read */
|
||||
TitleBufferTight = 38L, /**< Title Buffer is too tight */
|
||||
TitleMallocError = 26L, /**< Title Buffer can't be allocated */
|
||||
TitleReadError = 27L, /**< Title can't be read */
|
||||
UnicodeInitError = 5L, /**< Failed to initialise Unicode decoder */
|
||||
UnicodeHeaderError = 6L, /**< Header can't be encoded/decoded successfully */
|
||||
Uninitialised = 0L, /**< Uninitialised, file access failed */
|
||||
};
|
||||
/** Photo Formats */
|
||||
enum PhotoFormat : uint32_t {
|
||||
GTA5 = 0x01000000UL, /**< GTA V Photo Format */
|
||||
RDR2 = 0x04000000UL, /**< RDR 2 Photo Format */
|
||||
};
|
||||
/** Sign Initials */
|
||||
enum SignInitials : uint32_t {
|
||||
SIGTA5 = 0xE47AB81CUL, /**< GTA V Sign Initial */
|
||||
SIRDR2 = 0x00FEEB1EUL, /**< RDR 2 Sign Initial */
|
||||
};
|
||||
RagePhoto();
|
||||
~RagePhoto();
|
||||
void addParser(RagePhotoFormatParser *rp_parser); /**< Add a custom defined RagePhotoFormatParser. */
|
||||
static void clear(RagePhotoData *rp_data); /**< Resets the RagePhotoData object to default values. */
|
||||
void clear(); /**< Resets the RagePhotoData object to default values. */
|
||||
RagePhotoData* data(); /**< Returns the internal RagePhotoData object. */
|
||||
static bool load(const char *data, size_t size, RagePhotoData *rp_data, RagePhotoFormatParser *rp_parser); /**< Loads a Photo from a const char*. */
|
||||
/** Loads a Photo from a const char*.
|
||||
* \param data Photo data
|
||||
* \param size Photo data size
|
||||
*/
|
||||
bool load(const char *data, size_t size);
|
||||
/** Loads a Photo from a std::string.
|
||||
* \param data Photo data
|
||||
*/
|
||||
bool load(const std::string &data);
|
||||
/** Loads a Photo from a file.
|
||||
* \param filename File to load
|
||||
*/
|
||||
bool loadFile(const std::string &filename);
|
||||
int32_t error() const; /**< Returns the last error occurred. */
|
||||
uint32_t format() const; /**< Returns the Photo Format (GTA V or RDR 2). */
|
||||
const std::string jpeg() const; /**< Returns the Photo JPEG data. */
|
||||
#if (RAGEPHOTO_CXX_STD >= 17) && (__cplusplus >= 201703L)
|
||||
const std::string_view jpeg_view() const; /**< Returns the Photo JPEG data. */
|
||||
#endif
|
||||
const char* jpegData() const; /**< Returns the Photo JPEG data. */
|
||||
static uint64_t jpegSign(uint32_t photoFormat, RagePhotoData *rp_data); /**< Returns the Photo JPEG sign. */
|
||||
static uint64_t jpegSign(RagePhotoData *rp_data); /**< Returns the Photo JPEG sign. */
|
||||
uint64_t jpegSign(uint32_t photoFormat) const; /**< Returns the Photo JPEG sign. */
|
||||
uint64_t jpegSign() const; /**< Returns the Photo JPEG sign. */
|
||||
uint32_t jpegSize() const; /**< Returns the Photo JPEG data size. */
|
||||
const char* description() const; /**< Returns the Photo description. */
|
||||
const char* json() const; /**< Returns the Photo JSON data. */
|
||||
const char* header() const; /**< Returns the Photo header. */
|
||||
const char* title() const; /**< Returns the Photo title. */
|
||||
static const char* version(); /**< Returns the library version. */
|
||||
static bool save(char *data, uint32_t photoFormat, RagePhotoData *rp_data, RagePhotoFormatParser *rp_parser); /**< Saves a Photo to a char*. */
|
||||
static bool save(char *data, RagePhotoData *rp_data, RagePhotoFormatParser *rp_parser); /**< Saves a Photo to a char*. */
|
||||
/** Saves a Photo to a char*.
|
||||
* \param data Photo data
|
||||
* \param photoFormat Photo Format (GTA V or RDR 2)
|
||||
*/
|
||||
bool save(char *data, uint32_t photoFormat);
|
||||
/** Saves a Photo to a char*.
|
||||
* \param data Photo data
|
||||
*/
|
||||
bool save(char *data);
|
||||
/** Saves a Photo to a std::string.
|
||||
* \param photoFormat Photo Format (GTA V or RDR 2)
|
||||
* \param ok \p true when saved successfully
|
||||
*/
|
||||
const std::string save(uint32_t photoFormat, bool *ok = nullptr);
|
||||
/** Saves a Photo to a std::string.
|
||||
* \param ok \p true when saved successfully
|
||||
*/
|
||||
const std::string save(bool *ok = nullptr);
|
||||
bool saveFile(const std::string &filename, uint32_t photoFormat); /**< Saves a Photo to a file. */
|
||||
bool saveFile(const std::string &filename); /**< Saves a Photo to a file. */
|
||||
static size_t saveSize(uint32_t photoFormat, RagePhotoData *rp_data, RagePhotoFormatParser *rp_parser); /**< Returns the Photo save file size. */
|
||||
static size_t saveSize(RagePhotoData *rp_data, RagePhotoFormatParser *rp_parser); /**< Returns the Photo save file size. */
|
||||
size_t saveSize(uint32_t photoFormat); /**< Returns the Photo save file size. */
|
||||
size_t saveSize(); /**< Returns the Photo save file size. */
|
||||
static void setBufferDefault(RagePhotoData *rp_data); /**< Sets all cross-format Buffer to default size. */
|
||||
void setBufferDefault(); /**< Sets all cross-format Buffer to default size. */
|
||||
static void setBufferOffsets(RagePhotoData *rp_data); /**< Moves all Buffer offsets to correct position. */
|
||||
void setBufferOffsets(); /**< Moves all Buffer offsets to correct position. */
|
||||
bool setData(RagePhotoData *rp_data, bool takeCopy = true); /**< Sets the internal RagePhotoData object. */
|
||||
void setDescription(const char *description, uint32_t bufferSize = 0); /**< Sets the Photo description. */
|
||||
void setFormat(uint32_t photoFormat); /**< Sets the Photo Format (GTA V or RDR 2). */
|
||||
/** Sets the Photo JPEG data.
|
||||
* \param data JPEG data
|
||||
* \param size JPEG data size
|
||||
* \param bufferSize JPEG buffer size
|
||||
*/
|
||||
bool setJpeg(const char *data, uint32_t size, uint32_t bufferSize = 0);
|
||||
/** Sets the Photo JPEG data.
|
||||
* \param data JPEG data
|
||||
* \param bufferSize JPEG buffer size
|
||||
*/
|
||||
bool setJpeg(const std::string &data, uint32_t bufferSize = 0);
|
||||
void setJson(const char *json, uint32_t bufferSize = 0); /**< Sets the Photo JSON data. */
|
||||
void setHeader(const char *header, uint32_t headerSum, uint32_t headerSum2 = 0); /**< Sets the Photo header. */
|
||||
void setTitle(const char *title, uint32_t bufferSize = 0); /**< Sets the Photo title. */
|
||||
|
||||
private:
|
||||
RagePhotoData *m_data;
|
||||
RagePhotoFormatParser *m_parser;
|
||||
};
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // RAGEPHOTO_HPP
|
|
@ -1 +0,0 @@
|
|||
#include "RagePhotoA.hpp"
|
|
@ -0,0 +1,152 @@
|
|||
/*****************************************************************************
|
||||
* libragephoto RAGE Photo Parser
|
||||
* Copyright (C) 2021 Syping
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* This software is provided as-is, no warranties are given to you, we are not
|
||||
* responsible for anything with use of the software, you are self responsible.
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef RAGEPHOTOA_H
|
||||
#define RAGEPHOTOA_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include "RagePhotoC.h"
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
|
||||
/**
|
||||
* \brief ABI Stable Wrapper for RagePhoto.
|
||||
*
|
||||
* Using RagePhotoA instead of RagePhoto allows your library or application to survive more changes in the RagePhoto class,
|
||||
* disadvantages include worse performance, which should be pretty minimal, and not always include the newest features.
|
||||
*/
|
||||
class RagePhotoA
|
||||
{
|
||||
public:
|
||||
RagePhotoA() {
|
||||
instance = ragephoto_open();
|
||||
}
|
||||
~RagePhotoA() {
|
||||
ragephoto_close(instance);
|
||||
}
|
||||
void clear() {
|
||||
ragephoto_clear(instance);
|
||||
}
|
||||
bool load(const char *data, size_t size) {
|
||||
return ragephoto_load(instance, data, size);
|
||||
}
|
||||
bool load(const std::string &data) {
|
||||
return ragephoto_load(instance, data.data(), data.size());
|
||||
}
|
||||
bool loadFile(const char *filename) {
|
||||
return ragephoto_loadfile(instance, filename);
|
||||
}
|
||||
uint32_t error() const {
|
||||
return ragephoto_error(instance);
|
||||
}
|
||||
uint32_t format() const {
|
||||
return ragephoto_getphotoformat(instance);
|
||||
}
|
||||
const std::string photo() const {
|
||||
return std::string(ragephoto_getphotojpeg(instance), ragephoto_getphotosize(instance));
|
||||
}
|
||||
const char *photoData() const {
|
||||
return ragephoto_getphotojpeg(instance);
|
||||
}
|
||||
uint32_t photoSize() const {
|
||||
return ragephoto_getphotosize(instance);
|
||||
}
|
||||
const char* description() const {
|
||||
return ragephoto_getphotodesc(instance);
|
||||
}
|
||||
const char* json() const {
|
||||
return ragephoto_getphotojson(instance);
|
||||
}
|
||||
const char* header() const {
|
||||
return ragephoto_getphotoheader(instance);
|
||||
}
|
||||
const char* title() const {
|
||||
return ragephoto_getphototitle(instance);
|
||||
}
|
||||
static const char* version() {
|
||||
return ragephoto_version();
|
||||
}
|
||||
bool save(char *data, uint32_t photoFormat) {
|
||||
return ragephoto_savef(instance, data, photoFormat);
|
||||
}
|
||||
bool save(char *data) {
|
||||
return ragephoto_save(instance, data);
|
||||
}
|
||||
const std::string save(uint32_t photoFormat, bool *ok = nullptr) {
|
||||
std::string data;
|
||||
const size_t size = ragephoto_getsavesizef(instance, photoFormat);
|
||||
if (size == 0) {
|
||||
if (ok)
|
||||
*ok = false;
|
||||
return data;
|
||||
}
|
||||
data.resize(size);
|
||||
const bool saved = ragephoto_savef(instance, &data[0], photoFormat);
|
||||
if (ok)
|
||||
*ok = saved;
|
||||
return data;
|
||||
}
|
||||
const std::string save(bool *ok = nullptr) {
|
||||
return save(ragephoto_getphotoformat(instance), ok);
|
||||
}
|
||||
bool saveFile(const char *filename, uint32_t photoFormat) {
|
||||
return ragephoto_savefilef(instance, filename, photoFormat);
|
||||
}
|
||||
bool saveFile(const char *filename) {
|
||||
return ragephoto_savefile(instance, filename);
|
||||
}
|
||||
size_t saveSize(uint32_t photoFormat) {
|
||||
return ragephoto_getsavesizef(instance, photoFormat);
|
||||
}
|
||||
size_t saveSize() {
|
||||
return ragephoto_getsavesize(instance);
|
||||
}
|
||||
void setBufferDefault() {
|
||||
ragephoto_setbufferdefault(instance);
|
||||
}
|
||||
void setBufferOffsets() {
|
||||
ragephoto_setbufferoffsets(instance);
|
||||
}
|
||||
void setDescription(const char *description, uint32_t bufferSize = 0) {
|
||||
ragephoto_setphotodesc(instance, description, bufferSize);
|
||||
}
|
||||
void setFormat(uint32_t photoFormat) {
|
||||
ragephoto_setphotoformat(instance, photoFormat);
|
||||
}
|
||||
void setJson(const char *json, uint32_t bufferSize = 0) {
|
||||
ragephoto_setphotojson(instance, json, bufferSize);
|
||||
}
|
||||
void setHeader(const char *header, uint32_t headerSum) {
|
||||
ragephoto_setphotoheader(instance, header, headerSum);
|
||||
}
|
||||
bool setPhoto(const char *data, uint32_t size, uint32_t bufferSize = 0) {
|
||||
return ragephoto_setphotojpeg(instance, data, size, bufferSize);
|
||||
}
|
||||
bool setPhoto(const std::string &data, uint32_t bufferSize = 0) {
|
||||
return ragephoto_setphotojpeg(instance, data.data(), static_cast<uint32_t>(data.size()), bufferSize);
|
||||
}
|
||||
void setTitle(const char *title, uint32_t bufferSize = 0) {
|
||||
ragephoto_setphototitle(instance, title, bufferSize);
|
||||
}
|
||||
|
||||
private:
|
||||
ragephoto_t instance;
|
||||
};
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // RAGEPHOTOA_H
|
|
@ -1,345 +0,0 @@
|
|||
/*****************************************************************************
|
||||
* libragephoto RAGE Photo Parser
|
||||
* Copyright (C) 2021-2023 Syping
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* This software is provided as-is, no warranties are given to you, we are not
|
||||
* responsible for anything with use of the software, you are self responsible.
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef RAGEPHOTOA_HPP
|
||||
#define RAGEPHOTOA_HPP
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include "RagePhoto.h"
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
|
||||
/**
|
||||
* \brief GTA V and RDR 2 Photo Parser (C API wrapper).
|
||||
*/
|
||||
class RagePhotoA
|
||||
{
|
||||
public:
|
||||
/** Default sizes */
|
||||
enum DefaultSize : uint32_t {
|
||||
DEFAULT_GTA5_PHOTOBUFFER = 524288UL, /**< GTA V default Photo Buffer Size */
|
||||
DEFAULT_RDR2_PHOTOBUFFER = 1048576UL, /**< RDR 2 default Photo Buffer Size */
|
||||
DEFAULT_DESCBUFFER = 256UL, /**< Default Description Buffer Size */
|
||||
DEFAULT_JSONBUFFER = 3072UL, /**< Default JSON Buffer Size */
|
||||
DEFAULT_TITLBUFFER = 256UL, /**< Default Title Buffer Size */
|
||||
GTA5_HEADERSIZE = 264UL, /**< GTA V Header Size */
|
||||
RDR2_HEADERSIZE = 272UL, /**< RDR 2 Header Size */
|
||||
};
|
||||
/** Parsing and set errors */
|
||||
enum Error : int32_t {
|
||||
DescBufferTight = 39L, /**< Description Buffer is too tight */
|
||||
DescMallocError = 31L, /**< Description Buffer can't be allocated */
|
||||
DescReadError = 32L, /**< Description can't be read successfully */
|
||||
HeaderBufferTight = 35L, /**< Header Buffer is too tight */
|
||||
HeaderMallocError = 4L, /**< Header Buffer can't be allocated */
|
||||
IncompatibleFormat = 2L, /**< Format is incompatible */
|
||||
IncompleteChecksum = 7L, /**< Header checksum is incomplete */
|
||||
IncompleteDescBuffer = 30L, /**< Description Buffer Size is incomplete */
|
||||
IncompleteDescMarker = 28L, /**< Description Marker is incomplete */
|
||||
IncompleteDescOffset = 11L, /**< Description Offset is incomplete */
|
||||
IncompleteEOF = 8L, /**< End Of File Offset is incomplete */
|
||||
IncompleteHeader = 3L, /**< Header is incomplete */
|
||||
IncompleteJendMarker = 33L, /**< JEND Marker is incomplete */
|
||||
IncompleteJpegMarker = 12L, /**< JPEG Marker is incomplete */
|
||||
IncompleteJsonBuffer = 20L, /**< JSON Buffer Size is incomplete */
|
||||
IncompleteJsonMarker = 18L, /**< JSON Marker incomplete */
|
||||
IncompleteJsonOffset = 9L, /**< JSON Offset incomplete */
|
||||
IncompletePhotoBuffer = 14L, /**< Photo Buffer Size is incomplete */
|
||||
IncompletePhotoSize = 15L, /**< Photo Size is incomplete */
|
||||
IncompleteTitleBuffer = 25L, /**< Title Buffer Size is incomplete */
|
||||
IncompleteTitleMarker = 23L, /**< Title Marker is incomplete */
|
||||
IncompleteTitleOffset = 10L, /**< Title Offset is incomplete */
|
||||
IncorrectDescMarker = 29L, /**< Description Marker is incorrect */
|
||||
IncorrectJendMarker = 34L, /**< JEND Marker is incorrect */
|
||||
IncorrectJpegMarker = 13L, /**< JPEG Marker is incorrect */
|
||||
IncorrectJsonMarker = 19L, /**< JSON Marker is incorrect */
|
||||
IncorrectTitleMarker = 24L, /**< Title Marker is incorrect */
|
||||
JsonBufferTight = 37L, /**< JSON Buffer is too tight */
|
||||
JsonMallocError = 21L, /**< JSON Buffer can't be allocated */
|
||||
JsonReadError = 22L, /**< JSON can't be read successfully */
|
||||
NoError = 255L, /**< Finished without errors */
|
||||
NoFormatIdentifier = 1L, /**< No format detected, empty file */
|
||||
PhotoBufferTight = 36L, /**< Photo Buffer is too tight */
|
||||
PhotoMallocError = 16L, /**< Photo Buffer can't be allocated */
|
||||
PhotoReadError = 17L, /**< Photo can't be read */
|
||||
TitleBufferTight = 38L, /**< Title Buffer is too tight */
|
||||
TitleMallocError = 26L, /**< Title Buffer can't be allocated */
|
||||
TitleReadError = 27L, /**< Title can't be read */
|
||||
UnicodeInitError = 5L, /**< Failed to initialise Unicode decoder */
|
||||
UnicodeHeaderError = 6L, /**< Header can't be encoded/decoded successfully */
|
||||
Uninitialised = 0L, /**< Uninitialised, file access failed */
|
||||
};
|
||||
/** Photo Formats */
|
||||
enum PhotoFormat : uint32_t {
|
||||
GTA5 = 0x01000000UL, /**< GTA V Photo Format */
|
||||
RDR2 = 0x04000000UL, /**< RDR 2 Photo Format */
|
||||
};
|
||||
/** Sign Initials */
|
||||
enum SignInitials : uint32_t {
|
||||
SIGTA5 = 0xE47AB81CUL, /**< GTA V Sign Initial */
|
||||
SIRDR2 = 0x00FEEB1EUL, /**< RDR 2 Sign Initial */
|
||||
};
|
||||
RagePhotoA() {
|
||||
instance = ragephoto_open();
|
||||
}
|
||||
~RagePhotoA() {
|
||||
ragephoto_close(instance);
|
||||
}
|
||||
/** Add a custom defined RagePhotoFormatParser. */
|
||||
void addParser(RagePhotoFormatParser *rp_parser) {
|
||||
ragephoto_addparser(instance, rp_parser);
|
||||
}
|
||||
/** Resets the RagePhotoData object to default values. */
|
||||
static void clear(RagePhotoData *rp_data) {
|
||||
ragephotodata_clear(rp_data);
|
||||
}
|
||||
/** Resets the RagePhotoData object to default values. */
|
||||
void clear() {
|
||||
ragephoto_clear(instance);
|
||||
}
|
||||
/** Returns the internal RagePhotoData object. */
|
||||
RagePhotoData* data() {
|
||||
return ragephoto_getphotodata(instance);
|
||||
}
|
||||
/** Loads a Photo from a const char*. */
|
||||
static bool load(const char *data, size_t size, RagePhotoData *rp_data, RagePhotoFormatParser *rp_parser) {
|
||||
return ragephotodata_load(rp_data, rp_parser, data, size);
|
||||
}
|
||||
/** Loads a Photo from a const char*.
|
||||
* \param data Photo data
|
||||
* \param size Photo data size
|
||||
*/
|
||||
bool load(const char *data, size_t size) {
|
||||
return ragephoto_load(instance, data, size);
|
||||
}
|
||||
/** Loads a Photo from a std::string.
|
||||
* \param data Photo data
|
||||
*/
|
||||
bool load(const std::string &data) {
|
||||
return ragephoto_load(instance, data.data(), data.size());
|
||||
}
|
||||
/** Loads a Photo from a file.
|
||||
* \param filename File to load
|
||||
*/
|
||||
bool loadFile(const char *filename) {
|
||||
return ragephoto_loadfile(instance, filename);
|
||||
}
|
||||
/** Returns the last error occurred. */
|
||||
int32_t error() const {
|
||||
return ragephoto_error(instance);
|
||||
}
|
||||
/** Returns the Photo Format (GTA V or RDR 2). */
|
||||
uint32_t format() const {
|
||||
return ragephoto_getphotoformat(instance);
|
||||
}
|
||||
/** Returns the Photo JPEG data. */
|
||||
const std::string jpeg() const {
|
||||
const char *jpegData = ragephoto_getphotojpeg(instance);
|
||||
if (jpegData)
|
||||
return std::string(jpegData, ragephoto_getphotosize(instance));
|
||||
else
|
||||
return std::string();
|
||||
}
|
||||
#if (__cplusplus >= 201703L)
|
||||
/** Returns the Photo JPEG data. */
|
||||
const std::string_view jpeg_view() const {
|
||||
const char *jpegData = ragephoto_getphotojpeg(instance);
|
||||
if (jpegData)
|
||||
return std::string_view(jpegData, ragephoto_getphotosize(instance));
|
||||
else
|
||||
return std::string_view();
|
||||
}
|
||||
#endif
|
||||
/** Returns the Photo JPEG data. */
|
||||
const char* jpegData() const {
|
||||
return ragephoto_getphotojpeg(instance);
|
||||
}
|
||||
/** Returns the Photo JPEG sign. */
|
||||
static uint64_t jpegSign(uint32_t photoFormat, RagePhotoData *rp_data) {
|
||||
return ragephotodata_getphotosignf(rp_data, photoFormat);
|
||||
}
|
||||
/** Returns the Photo JPEG sign. */
|
||||
static uint64_t jpegSign(RagePhotoData *rp_data) {
|
||||
return ragephotodata_getphotosign(rp_data);
|
||||
}
|
||||
/** Returns the Photo JPEG sign. */
|
||||
uint64_t jpegSign(uint32_t photoFormat) const {
|
||||
return ragephoto_getphotosignf(instance, photoFormat);
|
||||
}
|
||||
/** Returns the Photo JPEG sign. */
|
||||
uint64_t jpegSign() const {
|
||||
return ragephoto_getphotosign(instance);
|
||||
}
|
||||
/** Returns the Photo JPEG data size. */
|
||||
uint32_t jpegSize() const {
|
||||
return ragephoto_getphotosize(instance);
|
||||
}
|
||||
/** Returns the Photo description. */
|
||||
const char* description() const {
|
||||
return ragephoto_getphotodesc(instance);
|
||||
}
|
||||
/** Returns the Photo JSON data. */
|
||||
const char* json() const {
|
||||
return ragephoto_getphotojson(instance);
|
||||
}
|
||||
/** Returns the Photo header. */
|
||||
const char* header() const {
|
||||
return ragephoto_getphotoheader(instance);
|
||||
}
|
||||
/** Returns the Photo title. */
|
||||
const char* title() const {
|
||||
return ragephoto_getphototitle(instance);
|
||||
}
|
||||
/** Returns the library version. */
|
||||
static const char* version() {
|
||||
return ragephoto_version();
|
||||
}
|
||||
/** Saves a Photo to a char*. */
|
||||
static bool save(char *data, uint32_t photoFormat, RagePhotoData *rp_data, RagePhotoFormatParser *rp_parser) {
|
||||
return ragephotodata_savef(rp_data, rp_parser, data, photoFormat);
|
||||
}
|
||||
/** Saves a Photo to a char*. */
|
||||
static bool save(char *data, RagePhotoData *rp_data, RagePhotoFormatParser *rp_parser) {
|
||||
return ragephotodata_save(rp_data, rp_parser, data);
|
||||
}
|
||||
/** Saves a Photo to a char*.
|
||||
* \param data Photo data
|
||||
* \param photoFormat Photo Format (GTA V or RDR 2)
|
||||
*/
|
||||
bool save(char *data, uint32_t photoFormat) {
|
||||
return ragephoto_savef(instance, data, photoFormat);
|
||||
}
|
||||
/** Saves a Photo to a char*.
|
||||
* \param data Photo data
|
||||
*/
|
||||
bool save(char *data) {
|
||||
return ragephoto_save(instance, data);
|
||||
}
|
||||
/** Saves a Photo to a std::string.
|
||||
* \param photoFormat Photo Format (GTA V or RDR 2)
|
||||
* \param ok \p true when saved successfully
|
||||
*/
|
||||
const std::string save(uint32_t photoFormat, bool *ok = nullptr) {
|
||||
std::string sdata;
|
||||
const size_t size = ragephoto_getsavesizef(instance, photoFormat);
|
||||
if (size == 0) {
|
||||
if (ok)
|
||||
*ok = false;
|
||||
return sdata;
|
||||
}
|
||||
sdata.resize(size);
|
||||
const bool saved = ragephoto_savef(instance, &sdata[0], photoFormat);
|
||||
if (ok)
|
||||
*ok = saved;
|
||||
return sdata;
|
||||
}
|
||||
/** Saves a Photo to a std::string.
|
||||
* \param ok \p true when saved successfully
|
||||
*/
|
||||
const std::string save(bool *ok = nullptr) {
|
||||
return save(ragephoto_getphotoformat(instance), ok);
|
||||
}
|
||||
/** Saves a Photo to a file. */
|
||||
bool saveFile(const char *filename, uint32_t photoFormat) {
|
||||
return ragephoto_savefilef(instance, filename, photoFormat);
|
||||
}
|
||||
/** Saves a Photo to a file. */
|
||||
bool saveFile(const char *filename) {
|
||||
return ragephoto_savefile(instance, filename);
|
||||
}
|
||||
/** Returns the Photo save file size. */
|
||||
static size_t saveSize(uint32_t photoFormat, RagePhotoData *rp_data, RagePhotoFormatParser *rp_parser) {
|
||||
return ragephotodata_getsavesizef(rp_data, rp_parser, photoFormat);
|
||||
}
|
||||
/** Returns the Photo save file size. */
|
||||
static size_t saveSize(RagePhotoData *rp_data, RagePhotoFormatParser *rp_parser) {
|
||||
return ragephotodata_getsavesize(rp_data, rp_parser);
|
||||
}
|
||||
/** Returns the Photo save file size. */
|
||||
size_t saveSize(uint32_t photoFormat) {
|
||||
return ragephoto_getsavesizef(instance, photoFormat);
|
||||
}
|
||||
/** Returns the Photo save file size. */
|
||||
size_t saveSize() {
|
||||
return ragephoto_getsavesize(instance);
|
||||
}
|
||||
/** Sets all cross-format Buffer to default size. */
|
||||
static void setBufferDefault(RagePhotoData *rp_data) {
|
||||
ragephotodata_setbufferdefault(rp_data);
|
||||
}
|
||||
/** Sets all cross-format Buffer to default size. */
|
||||
void setBufferDefault() {
|
||||
ragephoto_setbufferdefault(instance);
|
||||
}
|
||||
/** Moves all Buffer offsets to correct position. */
|
||||
static void setBufferOffsets(RagePhotoData *rp_data) {
|
||||
ragephotodata_setbufferoffsets(rp_data);
|
||||
}
|
||||
/** Moves all Buffer offsets to correct position. */
|
||||
void setBufferOffsets() {
|
||||
ragephoto_setbufferoffsets(instance);
|
||||
}
|
||||
/** Sets the internal RagePhotoData object. */
|
||||
bool setData(RagePhotoData *ragePhotoData, bool takeCopy = true) {
|
||||
if (takeCopy)
|
||||
return ragephoto_setphotodatac(instance, ragePhotoData);
|
||||
else
|
||||
return ragephoto_setphotodata(instance, ragePhotoData);
|
||||
}
|
||||
/** Sets the Photo description. */
|
||||
void setDescription(const char *description, uint32_t bufferSize = 0) {
|
||||
ragephoto_setphotodesc(instance, description, bufferSize);
|
||||
}
|
||||
/** Sets the Photo Format (GTA V or RDR 2). */
|
||||
void setFormat(uint32_t photoFormat) {
|
||||
ragephoto_setphotoformat(instance, photoFormat);
|
||||
}
|
||||
/** Sets the Photo JPEG data.
|
||||
* \param data JPEG data
|
||||
* \param size JPEG data size
|
||||
* \param bufferSize JPEG buffer size
|
||||
*/
|
||||
bool setJpeg(const char *data, uint32_t size, uint32_t bufferSize = 0) {
|
||||
return ragephoto_setphotojpeg(instance, data, size, bufferSize);
|
||||
}
|
||||
/** Sets the Photo JPEG data.
|
||||
* \param data JPEG data
|
||||
* \param bufferSize JPEG buffer size
|
||||
*/
|
||||
bool setJpeg(const std::string &data, uint32_t bufferSize = 0) {
|
||||
return ragephoto_setphotojpeg(instance, data.data(), static_cast<uint32_t>(data.size()), bufferSize);
|
||||
}
|
||||
/** Sets the Photo JSON data. */
|
||||
void setJson(const char *json, uint32_t bufferSize = 0) {
|
||||
ragephoto_setphotojson(instance, json, bufferSize);
|
||||
}
|
||||
/** Sets the Photo header. */
|
||||
void setHeader(const char *header, uint32_t headerSum, uint32_t headerSum2 = 0) {
|
||||
ragephoto_setphotoheader2(instance, header, headerSum, headerSum2);
|
||||
}
|
||||
/** Sets the Photo title. */
|
||||
void setTitle(const char *title, uint32_t bufferSize = 0) {
|
||||
ragephoto_setphototitle(instance, title, bufferSize);
|
||||
}
|
||||
|
||||
private:
|
||||
ragephoto_t instance;
|
||||
};
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // RAGEPHOTOA_HPP
|
|
@ -1 +0,0 @@
|
|||
#include "RagePhotoB.hpp"
|
|
@ -0,0 +1,215 @@
|
|||
/*****************************************************************************
|
||||
* libragephoto RAGE Photo Parser
|
||||
* Copyright (C) 2021 Syping
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* This software is provided as-is, no warranties are given to you, we are not
|
||||
* responsible for anything with use of the software, you are self responsible.
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef RAGEPHOTOC_H
|
||||
#define RAGEPHOTOC_H
|
||||
|
||||
#include "libragephoto_global.h"
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef LIBRAGEPHOTO_C_NOAPI
|
||||
#error "libragephoto was built without C API"
|
||||
#endif // LIBRAGEPHOTO_C_NOAPI
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
/** \file RagePhotoC.h */
|
||||
/** RagePhoto C++ class typedef for C API. */
|
||||
typedef void* ragephoto_t;
|
||||
|
||||
/** Opens a \p ragephoto_t instance. */
|
||||
LIBRAGEPHOTO_C_EXPORT ragephoto_t ragephoto_open();
|
||||
|
||||
/** Resets the \p ragephoto_t instance to default values.
|
||||
* \param instance \p ragephoto_t instance
|
||||
*/
|
||||
LIBRAGEPHOTO_C_EXPORT void ragephoto_clear(ragephoto_t instance);
|
||||
|
||||
/** Loads a Photo from a const char*.
|
||||
* \param instance \p ragephoto_t instance
|
||||
* \param data Photo data
|
||||
* \param size Photo data size
|
||||
*/
|
||||
LIBRAGEPHOTO_C_EXPORT int ragephoto_load(ragephoto_t instance, const char *data, size_t size);
|
||||
|
||||
/** Loads a Photo from a file.
|
||||
* \param instance \p ragephoto_t instance
|
||||
* \param filename File to load
|
||||
*/
|
||||
LIBRAGEPHOTO_C_EXPORT int ragephoto_loadfile(ragephoto_t instance, const char *filename);
|
||||
|
||||
/** Returns the last error occurred.
|
||||
* \param instance \p ragephoto_t instance
|
||||
*/
|
||||
LIBRAGEPHOTO_C_EXPORT uint8_t ragephoto_error(ragephoto_t instance);
|
||||
|
||||
/** Returns the GTA V default Photo Buffer Size. */
|
||||
LIBRAGEPHOTO_C_EXPORT uint32_t ragephoto_defpbuf_gta5();
|
||||
|
||||
/** Returns the RDR 2 default Photo Buffer Size. */
|
||||
LIBRAGEPHOTO_C_EXPORT uint32_t ragephoto_defpbuf_rdr2();
|
||||
|
||||
/** Returns the GTA V Photo Format. */
|
||||
LIBRAGEPHOTO_C_EXPORT uint32_t ragephoto_format_gta5();
|
||||
|
||||
/** Returns the RDR 2 Photo Format. */
|
||||
LIBRAGEPHOTO_C_EXPORT uint32_t ragephoto_format_rdr2();
|
||||
|
||||
/** Returns the Photo description.
|
||||
* \param instance \p ragephoto_t instance
|
||||
*/
|
||||
LIBRAGEPHOTO_C_EXPORT const char* ragephoto_getphotodesc(ragephoto_t instance);
|
||||
|
||||
/** Returns the Photo Format (GTA V or RDR 2).
|
||||
* \param instance \p ragephoto_t instance
|
||||
*/
|
||||
LIBRAGEPHOTO_C_EXPORT uint32_t ragephoto_getphotoformat(ragephoto_t instance);
|
||||
|
||||
/** Returns the Photo JPEG data.
|
||||
* \param instance \p ragephoto_t instance
|
||||
*/
|
||||
LIBRAGEPHOTO_C_EXPORT const char* ragephoto_getphotojpeg(ragephoto_t instance);
|
||||
|
||||
/** Returns the Photo JSON data.
|
||||
* \param instance \p ragephoto_t instance
|
||||
*/
|
||||
LIBRAGEPHOTO_C_EXPORT const char* ragephoto_getphotojson(ragephoto_t instance);
|
||||
|
||||
/** Returns the Photo header.
|
||||
* \param instance \p ragephoto_t instance
|
||||
*/
|
||||
LIBRAGEPHOTO_C_EXPORT const char* ragephoto_getphotoheader(ragephoto_t instance);
|
||||
|
||||
/** Returns the Photo JPEG data size.
|
||||
* \param instance \p ragephoto_t instance
|
||||
*/
|
||||
LIBRAGEPHOTO_C_EXPORT uint32_t ragephoto_getphotosize(ragephoto_t instance);
|
||||
|
||||
/** Returns the Photo title.
|
||||
* \param instance \p ragephoto_t instance
|
||||
*/
|
||||
LIBRAGEPHOTO_C_EXPORT const char* ragephoto_getphototitle(ragephoto_t instance);
|
||||
|
||||
/** Returns the Photo save file size.
|
||||
* \param instance \p ragephoto_t instance
|
||||
*/
|
||||
LIBRAGEPHOTO_C_EXPORT size_t ragephoto_getsavesize(ragephoto_t instance);
|
||||
|
||||
/** Returns the Photo save file size.
|
||||
* \param instance \p ragephoto_t instance
|
||||
* \param photoFormat Photo Format (GTA V or RDR 2)
|
||||
*/
|
||||
LIBRAGEPHOTO_C_EXPORT size_t ragephoto_getsavesizef(ragephoto_t instance, uint32_t photoFormat);
|
||||
|
||||
/** Saves a Photo to a char*.
|
||||
* \param instance \p ragephoto_t instance
|
||||
* \param data Photo data
|
||||
*/
|
||||
LIBRAGEPHOTO_C_EXPORT int ragephoto_save(ragephoto_t instance, char *data);
|
||||
|
||||
/** Saves a Photo to a char*.
|
||||
* \param instance \p ragephoto_t instance
|
||||
* \param data Photo data
|
||||
* \param photoFormat Photo Format (GTA V or RDR 2)
|
||||
*/
|
||||
LIBRAGEPHOTO_C_EXPORT int ragephoto_savef(ragephoto_t instance, char *data, uint32_t photoFormat);
|
||||
|
||||
/** Saves a Photo to a file.
|
||||
* \param instance \p ragephoto_t instance
|
||||
* \param filename File to save
|
||||
*/
|
||||
LIBRAGEPHOTO_C_EXPORT int ragephoto_savefile(ragephoto_t instance, const char *filename);
|
||||
|
||||
/** Saves a Photo to a file.
|
||||
* \param instance \p ragephoto_t instance
|
||||
* \param filename File to save
|
||||
* \param photoFormat Photo Format (GTA V or RDR 2)
|
||||
*/
|
||||
LIBRAGEPHOTO_C_EXPORT int ragephoto_savefilef(ragephoto_t instance, const char *filename, uint32_t photoFormat);
|
||||
|
||||
/** Sets all cross-format Buffer to default size.
|
||||
* \param instance \p ragephoto_t instance
|
||||
*/
|
||||
LIBRAGEPHOTO_C_EXPORT void ragephoto_setbufferdefault(ragephoto_t instance);
|
||||
|
||||
/** Moves all Buffer offsets to correct position.
|
||||
* \param instance \p ragephoto_t instance
|
||||
*/
|
||||
LIBRAGEPHOTO_C_EXPORT void ragephoto_setbufferoffsets(ragephoto_t instance);
|
||||
|
||||
/** Sets the Photo description.
|
||||
* \param instance \p ragephoto_t instance
|
||||
* \param description Description
|
||||
* \param bufferSize Description buffer size
|
||||
*
|
||||
* Default bufferSize: 256UL
|
||||
*/
|
||||
LIBRAGEPHOTO_C_EXPORT void ragephoto_setphotodesc(ragephoto_t instance, const char *description, uint32_t bufferSize);
|
||||
|
||||
/** Sets the Photo Format (GTA V or RDR 2).
|
||||
* \param instance \p ragephoto_t instance
|
||||
* \param photoFormat Photo Format (GTA V or RDR 2)
|
||||
*/
|
||||
LIBRAGEPHOTO_C_EXPORT void ragephoto_setphotoformat(ragephoto_t instance, uint32_t photoFormat);
|
||||
|
||||
/** Sets the Photo JPEG data.
|
||||
* \param instance \p ragephoto_t instance
|
||||
* \param data JPEG data
|
||||
* \param size JPEG data size
|
||||
* \param bufferSize JPEG buffer size
|
||||
*
|
||||
* Default bufferSize: ragephoto_defpbuf_gta5() or ragephoto_defpbuf_rdr2()
|
||||
*/
|
||||
LIBRAGEPHOTO_C_EXPORT int ragephoto_setphotojpeg(ragephoto_t instance, const char *data, uint32_t size, uint32_t bufferSize);
|
||||
|
||||
/** Sets the Photo JSON data.
|
||||
* \param instance \p ragephoto_t instance
|
||||
* \param json JSON data
|
||||
* \param bufferSize JSON data buffer size
|
||||
*
|
||||
* Default bufferSize: 3072UL
|
||||
*/
|
||||
LIBRAGEPHOTO_C_EXPORT void ragephoto_setphotojson(ragephoto_t instance, const char *json, uint32_t bufferSize);
|
||||
|
||||
/** Sets the Photo header. (EXPERT ONLY) */
|
||||
LIBRAGEPHOTO_C_EXPORT void ragephoto_setphotoheader(ragephoto_t instance, const char *header, uint32_t headerSum);
|
||||
|
||||
/** Sets the Photo title.
|
||||
* \param instance \p ragephoto_t instance
|
||||
* \param title Title
|
||||
* \param bufferSize Title buffer size
|
||||
*
|
||||
* Default bufferSize: 256UL
|
||||
*/
|
||||
LIBRAGEPHOTO_C_EXPORT void ragephoto_setphototitle(ragephoto_t instance, const char *title, uint32_t bufferSize);
|
||||
|
||||
/** Closes a \p ragephoto_t instance.
|
||||
* \param instance \p ragephoto_t instance
|
||||
*/
|
||||
LIBRAGEPHOTO_C_EXPORT void ragephoto_close(ragephoto_t instance);
|
||||
|
||||
/** Returns the library version. */
|
||||
LIBRAGEPHOTO_C_EXPORT const char* ragephoto_version();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // RAGEPHOTOC_H
|
|
@ -1,6 +1,6 @@
|
|||
/*****************************************************************************
|
||||
* libragephoto RAGE Photo Parser
|
||||
* Copyright (C) 2023 Syping
|
||||
* Copyright (C) 2021 Syping
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
@ -16,28 +16,40 @@
|
|||
* responsible for anything with use of the software, you are self responsible.
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef RAGEPHOTOB_HPP
|
||||
#define RAGEPHOTOB_HPP
|
||||
#ifndef RAGEPHOTODATA_H
|
||||
#define RAGEPHOTODATA_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include "RagePhotoLibrary.h"
|
||||
#ifdef LIBRAGEPHOTO_CXX_ONLY
|
||||
#include "RagePhoto.hpp"
|
||||
typedef RagePhoto RagePhotoB;
|
||||
#elif defined LIBRAGEPHOTO_CXX_C
|
||||
#ifdef LIBRAGEPHOTO_STATIC
|
||||
#include "RagePhoto.hpp"
|
||||
typedef RagePhoto RagePhotoB;
|
||||
#else
|
||||
#include "RagePhotoA.hpp"
|
||||
typedef RagePhotoA RagePhotoB;
|
||||
#endif // LIBRAGEPHOTO_STATIC
|
||||
#elif defined LIBRAGEPHOTO_C_ONLY
|
||||
#include "RagePhotoA.hpp"
|
||||
typedef RagePhotoA RagePhotoB;
|
||||
#else
|
||||
#error "Could not determine best RagePhoto implementation, libragephoto installation might be corrupt!"
|
||||
#endif // LIBRAGEPHOTO_CXX_ONLY
|
||||
#include "libragephoto_global.h"
|
||||
#include <cstdint>
|
||||
#include <iostream>
|
||||
#include <functional>
|
||||
|
||||
struct LIBRAGEPHOTO_CXX_EXPORT RagePhotoData
|
||||
{
|
||||
bool photoLoaded;
|
||||
char* photoData;
|
||||
std::string description;
|
||||
std::string json;
|
||||
std::string header;
|
||||
std::string title;
|
||||
uint8_t error;
|
||||
uint32_t descBuffer;
|
||||
uint32_t descOffset;
|
||||
uint32_t endOfFile;
|
||||
uint32_t headerSum;
|
||||
uint32_t jsonBuffer;
|
||||
uint32_t jsonOffset;
|
||||
uint32_t photoBuffer;
|
||||
uint32_t photoFormat;
|
||||
uint32_t photoSize;
|
||||
uint32_t titlBuffer;
|
||||
uint32_t titlOffset;
|
||||
uint32_t unnamedSum1;
|
||||
uint32_t unnamedSum2;
|
||||
};
|
||||
|
||||
typedef std::function<bool(const char*, size_t, RagePhotoData*)> RagePhotoLoadFunc;
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // RAGEPHOTOB_HPP
|
||||
#endif // RAGEPHOTODATA_H
|
|
@ -1,69 +0,0 @@
|
|||
/*****************************************************************************
|
||||
* libragephoto RAGE Photo Parser
|
||||
* Copyright (C) 2023 Syping
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* This software is provided as-is, no warranties are given to you, we are not
|
||||
* responsible for anything with use of the software, you are self responsible.
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef RAGEPHOTOLIBRARY_H
|
||||
#define RAGEPHOTOLIBRARY_H
|
||||
|
||||
#include "RagePhotoConfig.h"
|
||||
|
||||
/* RAGEPHOTO LIBRARY BINDING BEGIN */
|
||||
#ifdef _WIN32
|
||||
#ifndef LIBRAGEPHOTO_STATIC
|
||||
#ifdef LIBRAGEPHOTO_LIBRARY
|
||||
#define LIBRAGEPHOTO_C_PUBLIC __declspec(dllexport)
|
||||
#define LIBRAGEPHOTO_CXX_PUBLIC __declspec(dllexport)
|
||||
#else
|
||||
#define LIBRAGEPHOTO_C_PUBLIC __declspec(dllimport)
|
||||
#define LIBRAGEPHOTO_CXX_PUBLIC __declspec(dllimport)
|
||||
#endif // LIBRAGEPHOTO_LIBRARY
|
||||
#else
|
||||
#define LIBRAGEPHOTO_C_PUBLIC
|
||||
#define LIBRAGEPHOTO_CXX_PUBLIC
|
||||
#endif // LIBRAGEPHOTO_STATIC
|
||||
#else
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten/emscripten.h>
|
||||
#define LIBRAGEPHOTO_C_PUBLIC EMSCRIPTEN_KEEPALIVE
|
||||
#define LIBRAGEPHOTO_CXX_PUBLIC
|
||||
#else
|
||||
#ifdef __GNUC__
|
||||
#ifndef LIBRAGEPHOTO_STATIC
|
||||
#define LIBRAGEPHOTO_C_PUBLIC __attribute__((visibility("default")))
|
||||
#define LIBRAGEPHOTO_CXX_PUBLIC __attribute__((visibility("default")))
|
||||
#else
|
||||
#define LIBRAGEPHOTO_C_PUBLIC
|
||||
#define LIBRAGEPHOTO_CXX_PUBLIC
|
||||
#endif // LIBRAGEPHOTO_STATIC
|
||||
#else
|
||||
#define LIBRAGEPHOTO_C_PUBLIC
|
||||
#define LIBRAGEPHOTO_CXX_PUBLIC
|
||||
#endif // __GNUC__
|
||||
#endif // __EMSCRIPTEN__
|
||||
#endif // _WIN32
|
||||
/* RAGEPHOTO LIBRARY BINDING END */
|
||||
|
||||
/* ENABLE C API FOR LIBRAGEPHOTO WASM LIBRARY BEGIN */
|
||||
#ifdef LIBRAGEPHOTO_WASM
|
||||
#ifdef LIBRAGEPHOTO_CXX_ONLY
|
||||
#undef LIBRAGEPHOTO_CXX_ONLY
|
||||
#define LIBRAGEPHOTO_CXX_C
|
||||
#endif // LIBRAGEPHOTO_CXX_ONLY
|
||||
#endif // LIBRAGEPHOTO_WASM
|
||||
/* ENABLE C API FOR LIBRAGEPHOTO WASM LIBRARY END */
|
||||
|
||||
#endif // RAGEPHOTOLIBRARY_H
|
|
@ -1,143 +0,0 @@
|
|||
/*****************************************************************************
|
||||
* libragephoto RAGE Photo Parser
|
||||
* Copyright (C) 2021-2023 Syping
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* This software is provided as-is, no warranties are given to you, we are not
|
||||
* responsible for anything with use of the software, you are self responsible.
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef RAGEPHOTOTYPEDEFS_H
|
||||
#define RAGEPHOTOTYPEDEFS_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
/** RagePhoto data struct for storing internal data. */
|
||||
typedef struct RagePhotoData {
|
||||
char* jpeg; /**< Pointer for internal JPEG buffer */
|
||||
char* description; /**< Pointer for internal Description buffer */
|
||||
char* json; /**< Pointer for internal JSON buffer */
|
||||
char* header; /**< Pointer for internal Header buffer */
|
||||
char* title; /**< Pointer for internal Title buffer */
|
||||
int32_t error; /**< RagePhoto error code */
|
||||
uint32_t descBuffer; /**< Description buffer length */
|
||||
uint32_t descOffset; /**< Description buffer offset */
|
||||
uint32_t endOfFile; /**< End Of File offset */
|
||||
uint32_t headerSum; /**< Checksum of the header 1 */
|
||||
uint32_t headerSum2; /**< Checksum of the header 2 (RDR 2 only) */
|
||||
uint32_t jpegBuffer; /**< JPEG buffer length */
|
||||
uint32_t jpegSize; /**< Internal JPEG buffer length and size of JPEG */
|
||||
uint32_t jsonBuffer; /**< JSON buffer length */
|
||||
uint32_t jsonOffset; /**< JSON buffer offset */
|
||||
uint32_t photoFormat; /**< Photo file format magic */
|
||||
uint32_t titlBuffer; /**< Title buffer length */
|
||||
uint32_t titlOffset; /**< Title buffer offset */
|
||||
} RagePhotoData;
|
||||
|
||||
/** RagePhoto load function typedef. */
|
||||
typedef bool (*ragephoto_loadfunc_t)(RagePhotoData*, const char*, size_t);
|
||||
|
||||
/** RagePhoto save function typedef (char* allocated by caller). */
|
||||
typedef bool (*ragephoto_savefunc_t)(RagePhotoData*, char*, uint32_t);
|
||||
|
||||
/** RagePhoto save function typedef (char* allocated by function). */
|
||||
typedef bool (*ragephoto_savepfunc_t)(RagePhotoData*, char**, uint32_t);
|
||||
|
||||
/** RagePhoto saveSize function typedef. */
|
||||
typedef size_t (*ragephoto_saveszfunc_t)(RagePhotoData*, uint32_t);
|
||||
|
||||
/** RagePhoto format parser struct for registering custom formats. */
|
||||
typedef struct RagePhotoFormatParser {
|
||||
uint32_t photoFormat; /**< Photo file format magic */
|
||||
ragephoto_loadfunc_t funcLoad; /**< Pointer to load function */
|
||||
ragephoto_savefunc_t funcSave; /**< Pointer to save function */
|
||||
ragephoto_savepfunc_t funcSavep; /**< Pointer to savep function */
|
||||
ragephoto_saveszfunc_t funcSaveSz; /**< Pointer to saveSize function */
|
||||
} RagePhotoFormatParser;
|
||||
|
||||
/** RagePhoto instance struct for storing data and format parser pointer. */
|
||||
typedef struct RagePhotoInstance {
|
||||
RagePhotoData *data; /**< Pointer for data */
|
||||
RagePhotoFormatParser *parser; /**< Pointer for format parser */
|
||||
} RagePhotoInstance;
|
||||
|
||||
/* RagePhoto default sizes */
|
||||
#define RAGEPHOTO_DEFAULT_GTA5_PHOTOBUFFER 524288UL /**< GTA V default Photo Buffer Size */
|
||||
#define RAGEPHOTO_DEFAULT_RDR2_PHOTOBUFFER 1048576UL /**< RDR 2 default Photo Buffer Size */
|
||||
#define RAGEPHOTO_DEFAULT_DESCBUFFER 256UL /**< Default Description Buffer Size */
|
||||
#define RAGEPHOTO_DEFAULT_JSONBUFFER 3072UL /**< Default JSON Buffer Size */
|
||||
#define RAGEPHOTO_DEFAULT_TITLBUFFER 256UL /**< Default Title Buffer Size */
|
||||
#define RAGEPHOTO_GTA5_HEADERSIZE 264UL /**< GTA V Header Size */
|
||||
#define RAGEPHOTO_RDR2_HEADERSIZE 272UL /**< RDR 2 Header Size */
|
||||
|
||||
/* RagePhoto error codes */
|
||||
#define RAGEPHOTO_ERROR_DESCBUFFERTIGHT 39L /**< Description Buffer is too tight */
|
||||
#define RAGEPHOTO_ERROR_DESCMALLOCERROR 31L /**< Description Buffer can't be allocated */
|
||||
#define RAGEPHOTO_ERROR_DESCREADERROR 32L /**< Description can't be read successfully */
|
||||
#define RAGEPHOTO_ERROR_HEADERBUFFERTIGHT 35L /**< Header Buffer is too tight */
|
||||
#define RAGEPHOTO_ERROR_HEADERMALLOCERROR 4L /**< Header Buffer can't be allocated */
|
||||
#define RAGEPHOTO_ERROR_INCOMPATIBLEFORMAT 2L /**< Format is incompatible */
|
||||
#define RAGEPHOTO_ERROR_INCOMPLETECHECKSUM 7L /**< Header checksum is incomplete */
|
||||
#define RAGEPHOTO_ERROR_INCOMPLETEDESCBUFFER 30L /**< Description Buffer Size is incomplete */
|
||||
#define RAGEPHOTO_ERROR_INCOMPLETEDESCMARKER 28L /**< Description Marker is incomplete */
|
||||
#define RAGEPHOTO_ERROR_INCOMPLETEDESCOFFSET 11L /**< Description Offset is incomplete */
|
||||
#define RAGEPHOTO_ERROR_INCOMPLETEEOF 8L /**< End Of File Offset is incomplete */
|
||||
#define RAGEPHOTO_ERROR_INCOMPLETEHEADER 3L /**< Header is incomplete */
|
||||
#define RAGEPHOTO_ERROR_INCOMPLETEJENDMARKER 33L /**< JEND Marker is incomplete */
|
||||
#define RAGEPHOTO_ERROR_INCOMPLETEJPEGMARKER 12L /**< JPEG Marker is incomplete */
|
||||
#define RAGEPHOTO_ERROR_INCOMPLETEJSONBUFFER 20L /**< JSON Buffer Size is incomplete */
|
||||
#define RAGEPHOTO_ERROR_INCOMPLETEJSONMARKER 18L /**< JSON Marker incomplete */
|
||||
#define RAGEPHOTO_ERROR_INCOMPLETEJSONOFFSET 9L /**< JSON Offset incomplete */
|
||||
#define RAGEPHOTO_ERROR_INCOMPLETEPHOTOBUFFER 14L /**< Photo Buffer Size is incomplete */
|
||||
#define RAGEPHOTO_ERROR_INCOMPLETEPHOTOSIZE 15L /**< Photo Size is incomplete */
|
||||
#define RAGEPHOTO_ERROR_INCOMPLETETITLEBUFFER 25L /**< Title Buffer Size is incomplete */
|
||||
#define RAGEPHOTO_ERROR_INCOMPLETETITLEMARKER 23L /**< Title Marker is incomplete */
|
||||
#define RAGEPHOTO_ERROR_INCOMPLETETITLEOFFSET 10L /**< Title Offset is incomplete */
|
||||
#define RAGEPHOTO_ERROR_INCORRECTDESCMARKER 29L /**< Description Marker is incorrect */
|
||||
#define RAGEPHOTO_ERROR_INCORRECTJENDMARKER 34L /**< JEND Marker is incorrect */
|
||||
#define RAGEPHOTO_ERROR_INCORRECTJPEGMARKER 13L /**< JPEG Marker is incorrect */
|
||||
#define RAGEPHOTO_ERROR_INCORRECTJSONMARKER 19L /**< JSON Marker is incorrect */
|
||||
#define RAGEPHOTO_ERROR_INCORRECTTITLEMARKER 24L /**< Title Marker is incorrect */
|
||||
#define RAGEPHOTO_ERROR_JSONBUFFERTIGHT 37L /**< JSON Buffer is too tight */
|
||||
#define RAGEPHOTO_ERROR_JSONMALLOCERROR 21L /**< JSON Buffer can't be allocated */
|
||||
#define RAGEPHOTO_ERROR_JSONREADERROR 22L /**< JSON can't be read successfully */
|
||||
#define RAGEPHOTO_ERROR_NOERROR 255L /**< Finished without errors */
|
||||
#define RAGEPHOTO_ERROR_NOFORMATIDENTIFIER 1L /**< No format detected, empty file */
|
||||
#define RAGEPHOTO_ERROR_PHOTOBUFFERTIGHT 36L /**< Photo Buffer is too tight */
|
||||
#define RAGEPHOTO_ERROR_PHOTOMALLOCERROR 16L /**< Photo Buffer can't be allocated */
|
||||
#define RAGEPHOTO_ERROR_PHOTOREADERROR 17L /**< Photo can't be read */
|
||||
#define RAGEPHOTO_ERROR_TITLEBUFFERTIGHT 38L /**< Title Buffer is too tight */
|
||||
#define RAGEPHOTO_ERROR_TITLEMALLOCERROR 26L /**< Title Buffer can't be allocated */
|
||||
#define RAGEPHOTO_ERROR_TITLEREADERROR 27L /**< Title can't be read */
|
||||
#define RAGEPHOTO_ERROR_UNICODEINITERROR 5L /**< Failed to initialise Unicode decoder */
|
||||
#define RAGEPHOTO_ERROR_UNICODEHEADERERROR 6L /**< Header can't be encoded/decoded successfully */
|
||||
#define RAGEPHOTO_ERROR_UNINITIALISED 0L /**< Uninitialised, file access failed */
|
||||
|
||||
/* RagePhoto formats */
|
||||
#define RAGEPHOTO_FORMAT_GTA5 0x01000000UL /**< GTA V Photo Format */
|
||||
#define RAGEPHOTO_FORMAT_RDR2 0x04000000UL /**< RDR 2 Photo Format */
|
||||
|
||||
/* RagePhoto sign initials */
|
||||
#define RAGEPHOTO_SIGNINITIAL_GTA5 0xE47AB81CUL /**< GTA V Sign Initial */
|
||||
#define RAGEPHOTO_SIGNINITIAL_RDR2 0x00FEEB1EUL /**< RDR 2 Sign Initial */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // RAGEPHOTOTYPEDEFS_H
|
|
@ -1,6 +1,6 @@
|
|||
#[[**************************************************************************
|
||||
/*****************************************************************************
|
||||
* libragephoto RAGE Photo Parser
|
||||
* Copyright (C) 2023 Syping
|
||||
* Copyright (C) 2021 Syping
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
@ -14,8 +14,18 @@
|
|||
*
|
||||
* This software is provided as-is, no warranties are given to you, we are not
|
||||
* responsible for anything with use of the software, you are self responsible.
|
||||
****************************************************************************]]
|
||||
*****************************************************************************/
|
||||
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
set(CMAKE_CXX_STANDARD 11 CACHE STRING "libragephoto C++ standard")
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
#ifndef RAGEPHOTO_P_H
|
||||
#define RAGEPHOTO_P_H
|
||||
|
||||
#include "RagePhotoData.h"
|
||||
#include <iostream>
|
||||
#include <unordered_map>
|
||||
|
||||
class RagePhotoPrivate {
|
||||
public:
|
||||
std::unordered_map<uint8_t, RagePhotoLoadFunc> m_loadFuncs;
|
||||
RagePhotoData m_data;
|
||||
};
|
||||
#endif // RAGEPHOTO_P_H
|
|
@ -1,6 +1,6 @@
|
|||
/*****************************************************************************
|
||||
* libragephoto RAGE Photo Parser
|
||||
* Copyright (C) 2023 Syping
|
||||
* Copyright (C) 2021 Syping
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
@ -16,17 +16,42 @@
|
|||
* responsible for anything with use of the software, you are self responsible.
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef RAGEPHOTOCONFIG_H
|
||||
#define RAGEPHOTOCONFIG_H
|
||||
#ifndef LIBRAGEPHOTO_GLOBAL_H
|
||||
#define LIBRAGEPHOTO_GLOBAL_H
|
||||
|
||||
/* CMAKE CONFIG BEGIN */
|
||||
#define @LIBRAGEPHOTO_API@
|
||||
#define @LIBRAGEPHOTO_LIBTYPE@
|
||||
#define RAGEPHOTO_CXX_STD @CMAKE_CXX_STANDARD@
|
||||
#define RAGEPHOTO_VERSION "@ragephoto_VERSION@"
|
||||
#define RAGEPHOTO_VERSION_MAJOR @ragephoto_VERSION_MAJOR@
|
||||
#define RAGEPHOTO_VERSION_MINOR @ragephoto_VERSION_MINOR@
|
||||
#define RAGEPHOTO_VERSION_PATCH @ragephoto_VERSION_PATCH@
|
||||
/* CMAKE CONFIG END */
|
||||
|
||||
#endif // RAGEPHOTOCONFIG_H
|
||||
/* RAGEPHOTO LIBRARY EXPORT BEGIN */
|
||||
#ifdef _WIN32
|
||||
#ifndef LIBRAGEPHOTO_STATIC
|
||||
#ifdef LIBRAGEPHOTO_LIBRARY
|
||||
#define LIBRAGEPHOTO_C_EXPORT __declspec(dllexport)
|
||||
#define LIBRAGEPHOTO_CXX_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define LIBRAGEPHOTO_C_EXPORT __declspec(dllimport)
|
||||
#define LIBRAGEPHOTO_CXX_EXPORT __declspec(dllimport)
|
||||
#endif // LIBRAGEPHOTO_LIBRARY
|
||||
#else
|
||||
#define LIBRAGEPHOTO_C_EXPORT
|
||||
#define LIBRAGEPHOTO_CXX_EXPORT
|
||||
#endif // LIBRAGEPHOTO_STATIC
|
||||
#else
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten/emscripten.h>
|
||||
#define LIBRAGEPHOTO_C_EXPORT EMSCRIPTEN_KEEPALIVE
|
||||
#define LIBRAGEPHOTO_CXX_EXPORT
|
||||
#else
|
||||
#define LIBRAGEPHOTO_C_EXPORT
|
||||
#define LIBRAGEPHOTO_CXX_EXPORT
|
||||
#endif // __EMSCRIPTEN__
|
||||
#endif // _WIN32
|
||||
/* RAGEPHOTO LIBRARY EXPORT END */
|
||||
|
||||
#endif // LIBRAGEPHOTO_GLOBAL_H
|
|
@ -1,6 +1,6 @@
|
|||
/*****************************************************************************
|
||||
* libragephoto RAGE Photo Parser
|
||||
* Copyright (C) 2021-2022 Syping
|
||||
* Copyright (C) 2021 Syping
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
@ -23,7 +23,7 @@
|
|||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
const unsigned char photoHeader_english[256] = {
|
||||
char photoHeader[256] = {
|
||||
0x50, 0x00, 0x48, 0x00, 0x4f, 0x00, 0x54, 0x00,
|
||||
0x4f, 0x00, 0x20, 0x00, 0x2d, 0x00, 0x20, 0x00,
|
||||
0x30, 0x00, 0x32, 0x00, 0x2f, 0x00, 0x30, 0x00,
|
||||
|
@ -57,184 +57,10 @@ int main(int argc, char *argv[])
|
|||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
const unsigned char photoHeader_japanese[256] = {
|
||||
0x99, 0x51, 0x1f, 0x77, 0x20, 0x00, 0x2d, 0x00,
|
||||
0x20, 0x00, 0x31, 0x00, 0x32, 0x00, 0x2f, 0x00,
|
||||
0x32, 0x00, 0x38, 0x00, 0x2f, 0x00, 0x32, 0x00,
|
||||
0x32, 0x00, 0x20, 0x00, 0x30, 0x00, 0x34, 0x00,
|
||||
0x3a, 0x00, 0x32, 0x00, 0x32, 0x00, 0x3a, 0x00,
|
||||
0x35, 0x00, 0x37, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
const unsigned char photoHeader_korean[256] = {
|
||||
0xac, 0xc0, 0xc4, 0xc9, 0x20, 0x00, 0x2d, 0x00,
|
||||
0x20, 0x00, 0x31, 0x00, 0x32, 0x00, 0x2f, 0x00,
|
||||
0x32, 0x00, 0x38, 0x00, 0x2f, 0x00, 0x32, 0x00,
|
||||
0x32, 0x00, 0x20, 0x00, 0x30, 0x00, 0x34, 0x00,
|
||||
0x3a, 0x00, 0x31, 0x00, 0x38, 0x00, 0x3a, 0x00,
|
||||
0x32, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
const unsigned char photoHeader_russian[256] = {
|
||||
0x24, 0x04, 0x1e, 0x04, 0x22, 0x04, 0x1e, 0x04,
|
||||
0x20, 0x00, 0x2d, 0x00, 0x20, 0x00, 0x31, 0x00,
|
||||
0x32, 0x00, 0x2f, 0x00, 0x32, 0x00, 0x38, 0x00,
|
||||
0x2f, 0x00, 0x32, 0x00, 0x32, 0x00, 0x20, 0x00,
|
||||
0x30, 0x00, 0x34, 0x00, 0x3a, 0x00, 0x32, 0x00,
|
||||
0x35, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x30, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
const unsigned char photoHeader_taiwanese[256] = {
|
||||
0xf8, 0x76, 0x47, 0x72, 0x20, 0x00, 0x2d, 0x00,
|
||||
0x20, 0x00, 0x31, 0x00, 0x32, 0x00, 0x2f, 0x00,
|
||||
0x32, 0x00, 0x38, 0x00, 0x2f, 0x00, 0x32, 0x00,
|
||||
0x32, 0x00, 0x20, 0x00, 0x30, 0x00, 0x34, 0x00,
|
||||
0x3a, 0x00, 0x32, 0x00, 0x31, 0x00, 0x3a, 0x00,
|
||||
0x30, 0x00, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>,char16_t> convert;
|
||||
std::string photoString;
|
||||
|
||||
// English
|
||||
photoString = convert.to_bytes(reinterpret_cast<const char16_t*>(photoHeader_english));
|
||||
if (convert.converted() == 0)
|
||||
return 1;
|
||||
if (strcmp(photoString.c_str(), "PHOTO - 02/01/17 08:42:44") != 0)
|
||||
return 2;
|
||||
|
||||
// Japanese
|
||||
photoString = convert.to_bytes(reinterpret_cast<const char16_t*>(photoHeader_japanese));
|
||||
if (convert.converted() == 0)
|
||||
return 3;
|
||||
if (strcmp(photoString.c_str(), "写真 - 12/28/22 04:22:57") != 0)
|
||||
return 4;
|
||||
|
||||
// Korean
|
||||
photoString = convert.to_bytes(reinterpret_cast<const char16_t*>(photoHeader_korean));
|
||||
if (convert.converted() == 0)
|
||||
return 5;
|
||||
if (strcmp(photoString.c_str(), "사진 - 12/28/22 04:18:28") != 0)
|
||||
return 6;
|
||||
|
||||
// Russian
|
||||
photoString = convert.to_bytes(reinterpret_cast<const char16_t*>(photoHeader_russian));
|
||||
if (convert.converted() == 0)
|
||||
return 7;
|
||||
if (strcmp(photoString.c_str(), "ФОТО - 12/28/22 04:25:10") != 0)
|
||||
return 8;
|
||||
|
||||
// Taiwanese
|
||||
photoString = convert.to_bytes(reinterpret_cast<const char16_t*>(photoHeader_taiwanese));
|
||||
if (convert.converted() == 0)
|
||||
return 9;
|
||||
if (strcmp(photoString.c_str(), "相片 - 12/28/22 04:21:01") != 0)
|
||||
return 10;
|
||||
|
||||
return 0;
|
||||
std::string photoString = convert.to_bytes(reinterpret_cast<char16_t*>(photoHeader));
|
||||
if (convert.converted() == 0) {
|
||||
return -1;
|
||||
}
|
||||
return strcmp(photoString.c_str(), "PHOTO - 02/01/17 08:42:44");
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*****************************************************************************
|
||||
* libragephoto RAGE Photo Parser
|
||||
* Copyright (C) 2021-2022 Syping
|
||||
* Copyright (C) 2021 Syping
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
@ -22,7 +22,7 @@
|
|||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
unsigned char photoHeader_english[256] = {
|
||||
char photoHeader[256] = {
|
||||
0x50, 0x00, 0x48, 0x00, 0x4f, 0x00, 0x54, 0x00,
|
||||
0x4f, 0x00, 0x20, 0x00, 0x2d, 0x00, 0x20, 0x00,
|
||||
0x30, 0x00, 0x32, 0x00, 0x2f, 0x00, 0x30, 0x00,
|
||||
|
@ -56,207 +56,18 @@ int main(int argc, char *argv[])
|
|||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
unsigned char photoHeader_japanese[256] = {
|
||||
0x99, 0x51, 0x1f, 0x77, 0x20, 0x00, 0x2d, 0x00,
|
||||
0x20, 0x00, 0x31, 0x00, 0x32, 0x00, 0x2f, 0x00,
|
||||
0x32, 0x00, 0x38, 0x00, 0x2f, 0x00, 0x32, 0x00,
|
||||
0x32, 0x00, 0x20, 0x00, 0x30, 0x00, 0x34, 0x00,
|
||||
0x3a, 0x00, 0x32, 0x00, 0x32, 0x00, 0x3a, 0x00,
|
||||
0x35, 0x00, 0x37, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
unsigned char photoHeader_korean[256] = {
|
||||
0xac, 0xc0, 0xc4, 0xc9, 0x20, 0x00, 0x2d, 0x00,
|
||||
0x20, 0x00, 0x31, 0x00, 0x32, 0x00, 0x2f, 0x00,
|
||||
0x32, 0x00, 0x38, 0x00, 0x2f, 0x00, 0x32, 0x00,
|
||||
0x32, 0x00, 0x20, 0x00, 0x30, 0x00, 0x34, 0x00,
|
||||
0x3a, 0x00, 0x31, 0x00, 0x38, 0x00, 0x3a, 0x00,
|
||||
0x32, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
unsigned char photoHeader_russian[256] = {
|
||||
0x24, 0x04, 0x1e, 0x04, 0x22, 0x04, 0x1e, 0x04,
|
||||
0x20, 0x00, 0x2d, 0x00, 0x20, 0x00, 0x31, 0x00,
|
||||
0x32, 0x00, 0x2f, 0x00, 0x32, 0x00, 0x38, 0x00,
|
||||
0x2f, 0x00, 0x32, 0x00, 0x32, 0x00, 0x20, 0x00,
|
||||
0x30, 0x00, 0x34, 0x00, 0x3a, 0x00, 0x32, 0x00,
|
||||
0x35, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x30, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
unsigned char photoHeader_taiwanese[256] = {
|
||||
0xf8, 0x76, 0x47, 0x72, 0x20, 0x00, 0x2d, 0x00,
|
||||
0x20, 0x00, 0x31, 0x00, 0x32, 0x00, 0x2f, 0x00,
|
||||
0x32, 0x00, 0x38, 0x00, 0x2f, 0x00, 0x32, 0x00,
|
||||
0x32, 0x00, 0x20, 0x00, 0x30, 0x00, 0x34, 0x00,
|
||||
0x3a, 0x00, 0x32, 0x00, 0x31, 0x00, 0x3a, 0x00,
|
||||
0x30, 0x00, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
size_t src_s, dst_s, ret;
|
||||
char photoString[256];
|
||||
char photoHeader_string[256];
|
||||
iconv_t iconv_in = iconv_open("UTF-8", "UTF-16LE");
|
||||
if (iconv_in == (iconv_t)-1)
|
||||
return -1;
|
||||
|
||||
// English
|
||||
src_s = sizeof(photoHeader_english);
|
||||
dst_s = sizeof(photoString);
|
||||
char *src_english = (char*)photoHeader_english;
|
||||
char *dst_english = photoString;
|
||||
ret = iconv(iconv_in, &src_english, &src_s, &dst_english, &dst_s);
|
||||
if (ret == static_cast<size_t>(-1))
|
||||
return 1;
|
||||
if (strcmp(photoString, "PHOTO - 02/01/17 08:42:44") != 0)
|
||||
return 2;
|
||||
|
||||
// Japanese
|
||||
src_s = sizeof(photoHeader_japanese);
|
||||
dst_s = sizeof(photoString);
|
||||
char *src_japanese = (char*)photoHeader_japanese;
|
||||
char *dst_japanese = photoString;
|
||||
ret = iconv(iconv_in, &src_japanese, &src_s, &dst_japanese, &dst_s);
|
||||
if (ret == static_cast<size_t>(-1))
|
||||
return 3;
|
||||
if (strcmp(photoString, "写真 - 12/28/22 04:22:57") != 0)
|
||||
return 4;
|
||||
|
||||
// Korean
|
||||
src_s = sizeof(photoHeader_korean);
|
||||
dst_s = sizeof(photoString);
|
||||
char *src_korean = (char*)photoHeader_korean;
|
||||
char *dst_korean = photoString;
|
||||
ret = iconv(iconv_in, &src_korean, &src_s, &dst_korean, &dst_s);
|
||||
if (ret == static_cast<size_t>(-1))
|
||||
return 5;
|
||||
if (strcmp(photoString, "사진 - 12/28/22 04:18:28") != 0)
|
||||
return 6;
|
||||
|
||||
// Russian
|
||||
src_s = sizeof(photoHeader_russian);
|
||||
dst_s = sizeof(photoString);
|
||||
char *src_russian = (char*)photoHeader_russian;
|
||||
char *dst_russian = photoString;
|
||||
ret = iconv(iconv_in, &src_russian, &src_s, &dst_russian, &dst_s);
|
||||
if (ret == static_cast<size_t>(-1))
|
||||
return 7;
|
||||
if (strcmp(photoString, "ФОТО - 12/28/22 04:25:10") != 0)
|
||||
return 8;
|
||||
|
||||
// Taiwanese
|
||||
src_s = sizeof(photoHeader_taiwanese);
|
||||
dst_s = sizeof(photoString);
|
||||
char *src_taiwanese = (char*)photoHeader_taiwanese;
|
||||
char *dst_taiwanese = photoString;
|
||||
ret = iconv(iconv_in, &src_taiwanese, &src_s, &dst_taiwanese, &dst_s);
|
||||
if (ret == static_cast<size_t>(-1))
|
||||
return 9;
|
||||
if (strcmp(photoString, "相片 - 12/28/22 04:21:01") != 0)
|
||||
return 10;
|
||||
|
||||
return 0;
|
||||
size_t src_s = sizeof(photoHeader);
|
||||
size_t dst_s = sizeof(photoHeader_string);
|
||||
char *src = photoHeader;
|
||||
char *dst = photoHeader_string;
|
||||
const size_t ret = iconv(iconv_in, &src, &src_s, &dst, &dst_s);
|
||||
iconv_close(iconv_in);
|
||||
if (ret == static_cast<size_t>(-1)) {
|
||||
return -1;
|
||||
}
|
||||
return strcmp(photoHeader_string, "PHOTO - 02/01/17 08:42:44");
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*****************************************************************************
|
||||
* libragephoto RAGE Photo Parser
|
||||
* Copyright (C) 2021-2022 Syping
|
||||
* Copyright (C) 2021 Syping
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
@ -22,7 +22,7 @@
|
|||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
const unsigned char photoHeader_english[256] = {
|
||||
char photoHeader[256] = {
|
||||
0x50, 0x00, 0x48, 0x00, 0x4f, 0x00, 0x54, 0x00,
|
||||
0x4f, 0x00, 0x20, 0x00, 0x2d, 0x00, 0x20, 0x00,
|
||||
0x30, 0x00, 0x32, 0x00, 0x2f, 0x00, 0x30, 0x00,
|
||||
|
@ -56,184 +56,10 @@ int main(int argc, char *argv[])
|
|||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
const unsigned char photoHeader_japanese[256] = {
|
||||
0x99, 0x51, 0x1f, 0x77, 0x20, 0x00, 0x2d, 0x00,
|
||||
0x20, 0x00, 0x31, 0x00, 0x32, 0x00, 0x2f, 0x00,
|
||||
0x32, 0x00, 0x38, 0x00, 0x2f, 0x00, 0x32, 0x00,
|
||||
0x32, 0x00, 0x20, 0x00, 0x30, 0x00, 0x34, 0x00,
|
||||
0x3a, 0x00, 0x32, 0x00, 0x32, 0x00, 0x3a, 0x00,
|
||||
0x35, 0x00, 0x37, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
const unsigned char photoHeader_korean[256] = {
|
||||
0xac, 0xc0, 0xc4, 0xc9, 0x20, 0x00, 0x2d, 0x00,
|
||||
0x20, 0x00, 0x31, 0x00, 0x32, 0x00, 0x2f, 0x00,
|
||||
0x32, 0x00, 0x38, 0x00, 0x2f, 0x00, 0x32, 0x00,
|
||||
0x32, 0x00, 0x20, 0x00, 0x30, 0x00, 0x34, 0x00,
|
||||
0x3a, 0x00, 0x31, 0x00, 0x38, 0x00, 0x3a, 0x00,
|
||||
0x32, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
const unsigned char photoHeader_russian[256] = {
|
||||
0x24, 0x04, 0x1e, 0x04, 0x22, 0x04, 0x1e, 0x04,
|
||||
0x20, 0x00, 0x2d, 0x00, 0x20, 0x00, 0x31, 0x00,
|
||||
0x32, 0x00, 0x2f, 0x00, 0x32, 0x00, 0x38, 0x00,
|
||||
0x2f, 0x00, 0x32, 0x00, 0x32, 0x00, 0x20, 0x00,
|
||||
0x30, 0x00, 0x34, 0x00, 0x3a, 0x00, 0x32, 0x00,
|
||||
0x35, 0x00, 0x3a, 0x00, 0x31, 0x00, 0x30, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
const unsigned char photoHeader_taiwanese[256] = {
|
||||
0xf8, 0x76, 0x47, 0x72, 0x20, 0x00, 0x2d, 0x00,
|
||||
0x20, 0x00, 0x31, 0x00, 0x32, 0x00, 0x2f, 0x00,
|
||||
0x32, 0x00, 0x38, 0x00, 0x2f, 0x00, 0x32, 0x00,
|
||||
0x32, 0x00, 0x20, 0x00, 0x30, 0x00, 0x34, 0x00,
|
||||
0x3a, 0x00, 0x32, 0x00, 0x31, 0x00, 0x3a, 0x00,
|
||||
0x30, 0x00, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
int converted;
|
||||
char photoString[256];
|
||||
|
||||
// English
|
||||
converted = WideCharToMultiByte(CP_UTF8, 0, reinterpret_cast<const wchar_t*>(photoHeader_english), -1, photoString, 256, NULL, NULL);
|
||||
if (converted == 0)
|
||||
return 1;
|
||||
if (strcmp(photoString, "PHOTO - 02/01/17 08:42:44") != 0)
|
||||
return 2;
|
||||
|
||||
// Japanese
|
||||
converted = WideCharToMultiByte(CP_UTF8, 0, reinterpret_cast<const wchar_t*>(photoHeader_japanese), -1, photoString, 256, NULL, NULL);
|
||||
if (converted == 0)
|
||||
return 3;
|
||||
if (strcmp(photoString, "写真 - 12/28/22 04:22:57") != 0)
|
||||
return 4;
|
||||
|
||||
// Korean
|
||||
converted = WideCharToMultiByte(CP_UTF8, 0, reinterpret_cast<const wchar_t*>(photoHeader_korean), -1, photoString, 256, NULL, NULL);
|
||||
if (converted == 0)
|
||||
return 5;
|
||||
if (strcmp(photoString, "사진 - 12/28/22 04:18:28") != 0)
|
||||
return 6;
|
||||
|
||||
// Russian
|
||||
converted = WideCharToMultiByte(CP_UTF8, 0, reinterpret_cast<const wchar_t*>(photoHeader_russian), -1, photoString, 256, NULL, NULL);
|
||||
if (converted == 0)
|
||||
return 7;
|
||||
if (strcmp(photoString, "ФОТО - 12/28/22 04:25:10") != 0)
|
||||
return 8;
|
||||
|
||||
// Taiwanese
|
||||
converted = WideCharToMultiByte(CP_UTF8, 0, reinterpret_cast<const wchar_t*>(photoHeader_taiwanese), -1, photoString, 256, NULL, NULL);
|
||||
if (converted == 0)
|
||||
return 9;
|
||||
if (strcmp(photoString, "相片 - 12/28/22 04:21:01") != 0)
|
||||
return 10;
|
||||
|
||||
return 0;
|
||||
char photoHeader_string[256];
|
||||
const int converted = WideCharToMultiByte(CP_UTF8, 0, reinterpret_cast<wchar_t*>(photoHeader), -1, photoHeader_string, 256, NULL, NULL);
|
||||
if (converted == 0) {
|
||||
return -1;
|
||||
}
|
||||
return strcmp(photoHeader_string, "PHOTO - 02/01/17 08:42:44");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue