From 02ad50b373dbdb68b05628e35a2cd1edbc3b4e48 Mon Sep 17 00:00:00 2001 From: Syping Date: Sun, 9 Nov 2025 12:15:20 +0100 Subject: [PATCH 01/10] GitHub Actions: simplify .NET workflow artifact management --- .github/workflows/dotnet.yml | 49 +++++++++++------------------------- 1 file changed, 15 insertions(+), 34 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 2202f2f..9285e15 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -92,63 +92,44 @@ jobs: Release: needs: [Linux, macOS, Windows] runs-on: windows-latest - defaults: - run: - shell: pwsh steps: - name: Cloning uses: actions/checkout@v5 - - name: Download Linux arm64 Assets + - name: Download Linux arm64 Artifacts uses: actions/download-artifact@v6 with: name: Linux arm64 - path: assets/linux-arm64 - - name: Download Linux x64 Assets + path: ${{github.workspace}}/src/dotnet/runtimes/linux-arm64 + - name: Download Linux x64 Artifacts uses: actions/download-artifact@v6 with: name: Linux x64 - path: assets/linux-x64 - - name: Download macOS arm64 Assets + path: ${{github.workspace}}/src/dotnet/runtimes/linux-x64 + - name: Download macOS arm64 Artifacts uses: actions/download-artifact@v6 with: name: macOS arm64 - path: assets/osx-arm64 - - name: Download macOS x64 Assets + path: ${{github.workspace}}/src/dotnet/runtimes/osx-arm64 + - name: Download macOS x64 Artifacts uses: actions/download-artifact@v6 with: name: macOS x64 - path: assets/osx-x64 - - name: Download Windows arm64 Assets + path: ${{github.workspace}}/src/dotnet/runtimes/osx-x64 + - name: Download Windows arm64 Artifacts uses: actions/download-artifact@v6 with: name: Windows MSVC arm64 - path: assets/win-arm64 - - name: Download Windows x64 Assets + path: ${{github.workspace}}/src/dotnet/runtimes/win-arm64 + - name: Download Windows x64 Artifacts uses: actions/download-artifact@v6 with: name: Windows MSVC x64 - path: assets/win-x64 - - name: Download Windows x86 Assets + path: ${{github.workspace}}/src/dotnet/runtimes/win-x64 + - name: Download Windows x86 Artifacts uses: actions/download-artifact@v6 with: name: Windows MSVC x86 - path: assets/win-x86 - - name: Copy Assets - run: | - mkdir -p "${{github.workspace}}\src\dotnet\runtimes\linux-arm64\native" - mkdir -p "${{github.workspace}}\src\dotnet\runtimes\linux-x64\native" - mkdir -p "${{github.workspace}}\src\dotnet\runtimes\osx-arm64\native" - mkdir -p "${{github.workspace}}\src\dotnet\runtimes\osx-x64\native" - mkdir -p "${{github.workspace}}\src\dotnet\runtimes\win-arm64\native" - mkdir -p "${{github.workspace}}\src\dotnet\runtimes\win-x64\native" - mkdir -p "${{github.workspace}}\src\dotnet\runtimes\win-x86\native" - cp "${{github.workspace}}\assets\linux-arm64\libragephoto.so" "${{github.workspace}}\src\dotnet\runtimes\linux-arm64\native\libragephoto.so" - cp "${{github.workspace}}\assets\linux-x64\libragephoto.so" "${{github.workspace}}\src\dotnet\runtimes\linux-x64\native\libragephoto.so" - cp "${{github.workspace}}\assets\osx-arm64\libragephoto.dylib" "${{github.workspace}}\src\dotnet\runtimes\osx-arm64\native\libragephoto.dylib" - cp "${{github.workspace}}\assets\osx-x64\libragephoto.dylib" "${{github.workspace}}\src\dotnet\runtimes\osx-x64\native\libragephoto.dylib" - cp "${{github.workspace}}\assets\win-arm64\libragephoto.dll" "${{github.workspace}}\src\dotnet\runtimes\win-arm64\native\libragephoto.dll" - cp "${{github.workspace}}\assets\win-x64\libragephoto.dll" "${{github.workspace}}\src\dotnet\runtimes\win-x64\native\libragephoto.dll" - cp "${{github.workspace}}\assets\win-x86\libragephoto.dll" "${{github.workspace}}\src\dotnet\runtimes\win-x86\native\libragephoto.dll" + path: ${{github.workspace}}/src/dotnet/runtimes/win-x86 - name: Setup MSBuild uses: microsoft/setup-msbuild@v2 - name: Setup .NET @@ -161,4 +142,4 @@ jobs: uses: actions/upload-artifact@v5 with: name: NuGet Package - path: ${{github.workspace}}\src\dotnet\bin\${{env.BUILD_TYPE}}\RagePhoto.Core.*.nupkg + path: ${{github.workspace}}/src/dotnet/bin/${{env.BUILD_TYPE}}/RagePhoto.Core.*.nupkg From 926a49033c89983824186e45dbd859283bd85f0b Mon Sep 17 00:00:00 2001 From: Syping Date: Sun, 9 Nov 2025 13:34:12 +0100 Subject: [PATCH 02/10] GitHub Actions: add static build to .NET workflow --- .github/workflows/dotnet.yml | 59 ++++++++++++++++++++++++++++-------- 1 file changed, 47 insertions(+), 12 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 9285e15..ea30f3c 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -23,16 +23,28 @@ jobs: - name: Install packages run: dnf install -y cmake gcc gcc-c++ - name: Configure CMake - run: cmake -B "build" -DRAGEPHOTO_C_LIBRARY=ON -DRAGEPHOTO_EXTRACT=OFF -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} + run: | + cmake -B "build/shared" -DRAGEPHOTO_C_LIBRARY=ON -DRAGEPHOTO_EXTRACT=OFF -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} + cmake -B "build/static" -DRAGEPHOTO_C_LIBRARY=ON -DRAGEPHOTO_EXTRACT=OFF -DRAGEPHOTO_STATIC=ON -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} - name: Build - run: cmake --build "build" --config ${{env.BUILD_TYPE}} + run: | + cmake --build "build/shared" --config ${{env.BUILD_TYPE}} + cmake --build "build/static" --config ${{env.BUILD_TYPE}} - name: Install - run: cmake --install "build" --config ${{env.BUILD_TYPE}} --prefix "install/" + run: | + cmake --install "build/shared" --config ${{env.BUILD_TYPE}} --prefix "install/shared/" + cmake --install "build/static" --config ${{env.BUILD_TYPE}} --prefix "install/static/" + - name: Preparing for Upload + run: | + mkdir "artifacts" + cp "install/shared/lib64/libragephoto.so" \ + "install/static/lib64/libragephoto.a" \ + "artifacts/" - name: Upload uses: actions/upload-artifact@v5 with: name: Linux ${{matrix.arch}} - path: ${{github.workspace}}/install/lib64/libragephoto.so + path: ${{github.workspace}}/artifacts/ macOS: runs-on: ${{matrix.runner}} env: @@ -49,16 +61,28 @@ jobs: - name: Cloning uses: actions/checkout@v5 - name: Configure CMake - run: cmake -B "${{github.workspace}}/build" -DRAGEPHOTO_C_LIBRARY=ON -DRAGEPHOTO_EXTRACT=OFF -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_OSX_DEPLOYMENT_TARGET=${{env.OSX_DEPLOYMENT_TARGET}} -GNinja + run: | + cmake -B "${{github.workspace}}/build/shared" -DRAGEPHOTO_C_LIBRARY=ON -DRAGEPHOTO_EXTRACT=OFF -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_OSX_DEPLOYMENT_TARGET=${{env.OSX_DEPLOYMENT_TARGET}} + cmake -B "${{github.workspace}}/build/static" -DRAGEPHOTO_C_LIBRARY=ON -DRAGEPHOTO_EXTRACT=OFF -DRAGEPHOTO_STATIC=ON -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_OSX_DEPLOYMENT_TARGET=${{env.OSX_DEPLOYMENT_TARGET}} - name: Build - run: cmake --build "${{github.workspace}}/build" --config ${{env.BUILD_TYPE}} + run: | + cmake --build "${{github.workspace}}/build/shared" --config ${{env.BUILD_TYPE}} + cmake --build "${{github.workspace}}/build/static" --config ${{env.BUILD_TYPE}} - name: Install - run: cmake --install "${{github.workspace}}/build" --config ${{env.BUILD_TYPE}} --prefix "${{github.workspace}}/install/" + run: | + cmake --install "${{github.workspace}}/build/shared" --config ${{env.BUILD_TYPE}} --prefix "${{github.workspace}}/install/shared/" + cmake --install "${{github.workspace}}/build/static" --config ${{env.BUILD_TYPE}} --prefix "${{github.workspace}}/install/static/" + - name: Preparing for Upload + run: | + mkdir "artifacts" + cp "install/shared/lib/libragephoto.dylib" \ + "install/static/lib/libragephoto.a" \ + "artifacts/" - name: Upload uses: actions/upload-artifact@v5 with: name: macOS ${{matrix.arch}} - path: ${{github.workspace}}/install/lib/libragephoto.dylib + path: ${{github.workspace}}/artifacts/ Windows: runs-on: windows-latest strategy: @@ -79,16 +103,27 @@ jobs: with: arch: ${{matrix.msvc}} - name: Configure CMake - run: cmake -B "${{github.workspace}}/build" -DRAGEPHOTO_C_LIBRARY=ON -DRAGEPHOTO_EXTRACT=OFF -DRAGEPHOTO_UNICODE=wincvt -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -GNinja + run: | + cmake -B "${{github.workspace}}/build/shared" -DRAGEPHOTO_C_LIBRARY=ON -DRAGEPHOTO_EXTRACT=OFF -DRAGEPHOTO_UNICODE=wincvt -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} + cmake -B "${{github.workspace}}/build/static" -DRAGEPHOTO_C_LIBRARY=ON -DRAGEPHOTO_EXTRACT=OFF -DRAGEPHOTO_STATIC=ON -DRAGEPHOTO_UNICODE=wincvt -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} - name: Build - run: cmake --build "${{github.workspace}}/build" --config ${{env.BUILD_TYPE}} + run: | + cmake --build "${{github.workspace}}/build/shared" --config ${{env.BUILD_TYPE}} + cmake --build "${{github.workspace}}/build/static" --config ${{env.BUILD_TYPE}} - name: Install - run: cmake --install "${{github.workspace}}/build" --config ${{env.BUILD_TYPE}} --prefix "${{github.workspace}}/install" + run: | + cmake --install "${{github.workspace}}/build/shared" --config ${{env.BUILD_TYPE}} --prefix "${{github.workspace}}/install/shared/" + cmake --install "${{github.workspace}}/build/static" --config ${{env.BUILD_TYPE}} --prefix "${{github.workspace}}/install/static/" + - name: Preparing for Upload + run: | + mkdir "artifacts" + Copy-Item "install\shared\bin\libragephoto.dll" "artifacts\" + Copy-Item "install\static\lib\ragephoto.lib" "artifacts\" - name: Upload uses: actions/upload-artifact@v5 with: name: Windows MSVC ${{matrix.arch}} - path: ${{github.workspace}}/install/bin/libragephoto.dll + path: ${{github.workspace}}/artifacts/ Release: needs: [Linux, macOS, Windows] runs-on: windows-latest From 33dbe75e24679792d9bcf00f97d66ada5e9dde33 Mon Sep 17 00:00:00 2001 From: Syping Date: Sun, 9 Nov 2025 13:40:50 +0100 Subject: [PATCH 03/10] RagePhoto.Core.csproj: catch ragephoto.lib in wildcard pattern --- src/dotnet/RagePhoto.Core.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dotnet/RagePhoto.Core.csproj b/src/dotnet/RagePhoto.Core.csproj index 0cb99f7..7b92550 100644 --- a/src/dotnet/RagePhoto.Core.csproj +++ b/src/dotnet/RagePhoto.Core.csproj @@ -20,7 +20,7 @@ - + PreserveNewest From f747a19f3c6ff7ad6e83aa3a7f890a47d2002208 Mon Sep 17 00:00:00 2001 From: Syping Date: Sun, 9 Nov 2025 13:45:26 +0100 Subject: [PATCH 04/10] GitHub Actions: add missing native folder in .NET workflow --- .github/workflows/dotnet.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index ea30f3c..8e13024 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -134,37 +134,37 @@ jobs: uses: actions/download-artifact@v6 with: name: Linux arm64 - path: ${{github.workspace}}/src/dotnet/runtimes/linux-arm64 + path: ${{github.workspace}}/src/dotnet/runtimes/linux-arm64/native - name: Download Linux x64 Artifacts uses: actions/download-artifact@v6 with: name: Linux x64 - path: ${{github.workspace}}/src/dotnet/runtimes/linux-x64 + path: ${{github.workspace}}/src/dotnet/runtimes/linux-x64/native - name: Download macOS arm64 Artifacts uses: actions/download-artifact@v6 with: name: macOS arm64 - path: ${{github.workspace}}/src/dotnet/runtimes/osx-arm64 + path: ${{github.workspace}}/src/dotnet/runtimes/osx-arm64/native - name: Download macOS x64 Artifacts uses: actions/download-artifact@v6 with: name: macOS x64 - path: ${{github.workspace}}/src/dotnet/runtimes/osx-x64 + path: ${{github.workspace}}/src/dotnet/runtimes/osx-x64/native - name: Download Windows arm64 Artifacts uses: actions/download-artifact@v6 with: name: Windows MSVC arm64 - path: ${{github.workspace}}/src/dotnet/runtimes/win-arm64 + path: ${{github.workspace}}/src/dotnet/runtimes/win-arm64/native - name: Download Windows x64 Artifacts uses: actions/download-artifact@v6 with: name: Windows MSVC x64 - path: ${{github.workspace}}/src/dotnet/runtimes/win-x64 + path: ${{github.workspace}}/src/dotnet/runtimes/win-x64/native - name: Download Windows x86 Artifacts uses: actions/download-artifact@v6 with: name: Windows MSVC x86 - path: ${{github.workspace}}/src/dotnet/runtimes/win-x86 + path: ${{github.workspace}}/src/dotnet/runtimes/win-x86/native - name: Setup MSBuild uses: microsoft/setup-msbuild@v2 - name: Setup .NET From 3ea95bab44cb714a5de9a880675f61cbed7db152 Mon Sep 17 00:00:00 2001 From: Syping Date: Sun, 9 Nov 2025 22:20:48 +0100 Subject: [PATCH 05/10] GitHub Actions: simplify .NET workflow artifact management --- .github/workflows/dotnet.yml | 110 +++++++++++++++++------------------ 1 file changed, 55 insertions(+), 55 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 2202f2f..f73bac1 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -8,31 +8,41 @@ jobs: Linux: runs-on: ${{matrix.runner}} container: - image: almalinux:8 + image: ${{matrix.image}} strategy: matrix: arch: [arm64, x64] + libc: [glibc] include: - arch: arm64 runner: ubuntu-24.04-arm - arch: x64 runner: ubuntu-24.04 + - libc: glibc + image: almalinux:8 + install: dnf install -y cmake gcc gcc-c++ + libdir: lib64 steps: - name: Cloning uses: actions/checkout@v5 - name: Install packages - run: dnf install -y cmake gcc gcc-c++ + run: ${{matrix.install}} - name: Configure CMake - run: cmake -B "build" -DRAGEPHOTO_C_LIBRARY=ON -DRAGEPHOTO_EXTRACT=OFF -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} + run: cmake -B "build/shared" -DRAGEPHOTO_C_LIBRARY=ON -DRAGEPHOTO_EXTRACT=OFF -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} - name: Build - run: cmake --build "build" --config ${{env.BUILD_TYPE}} + run: cmake --build "build/shared" --config ${{env.BUILD_TYPE}} - name: Install - run: cmake --install "build" --config ${{env.BUILD_TYPE}} --prefix "install/" + run: cmake --install "build/shared" --config ${{env.BUILD_TYPE}} --prefix "install/shared/" + - name: Preparing for Upload + run: | + mkdir "artifacts" + cp "install/shared/${{matrix.libdir}}/libragephoto.so" \ + "artifacts/" - name: Upload uses: actions/upload-artifact@v5 with: - name: Linux ${{matrix.arch}} - path: ${{github.workspace}}/install/lib64/libragephoto.so + name: Linux ${{matrix.arch}} ${{matrix.libc}} + path: ${{github.workspace}}/artifacts/ macOS: runs-on: ${{matrix.runner}} env: @@ -49,16 +59,21 @@ jobs: - name: Cloning uses: actions/checkout@v5 - name: Configure CMake - run: cmake -B "${{github.workspace}}/build" -DRAGEPHOTO_C_LIBRARY=ON -DRAGEPHOTO_EXTRACT=OFF -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_OSX_DEPLOYMENT_TARGET=${{env.OSX_DEPLOYMENT_TARGET}} -GNinja + run: cmake -B "${{github.workspace}}/build/shared" -DRAGEPHOTO_C_LIBRARY=ON -DRAGEPHOTO_EXTRACT=OFF -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_OSX_DEPLOYMENT_TARGET=${{env.OSX_DEPLOYMENT_TARGET}} - name: Build - run: cmake --build "${{github.workspace}}/build" --config ${{env.BUILD_TYPE}} + run: cmake --build "${{github.workspace}}/build/shared" --config ${{env.BUILD_TYPE}} - name: Install - run: cmake --install "${{github.workspace}}/build" --config ${{env.BUILD_TYPE}} --prefix "${{github.workspace}}/install/" + run: cmake --install "${{github.workspace}}/build/shared" --config ${{env.BUILD_TYPE}} --prefix "${{github.workspace}}/install/shared/" + - name: Preparing for Upload + run: | + mkdir "artifacts" + cp "install/shared/lib/libragephoto.dylib" \ + "artifacts/" - name: Upload uses: actions/upload-artifact@v5 with: name: macOS ${{matrix.arch}} - path: ${{github.workspace}}/install/lib/libragephoto.dylib + path: ${{github.workspace}}/artifacts/ Windows: runs-on: windows-latest strategy: @@ -79,76 +94,61 @@ jobs: with: arch: ${{matrix.msvc}} - name: Configure CMake - run: cmake -B "${{github.workspace}}/build" -DRAGEPHOTO_C_LIBRARY=ON -DRAGEPHOTO_EXTRACT=OFF -DRAGEPHOTO_UNICODE=wincvt -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -GNinja + run: cmake -B "${{github.workspace}}/build/shared" -DRAGEPHOTO_C_LIBRARY=ON -DRAGEPHOTO_EXTRACT=OFF -DRAGEPHOTO_UNICODE=wincvt -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -GNinja - name: Build - run: cmake --build "${{github.workspace}}/build" --config ${{env.BUILD_TYPE}} + run: cmake --build "${{github.workspace}}/build/shared" --config ${{env.BUILD_TYPE}} - name: Install - run: cmake --install "${{github.workspace}}/build" --config ${{env.BUILD_TYPE}} --prefix "${{github.workspace}}/install" + run: cmake --install "${{github.workspace}}/build/shared" --config ${{env.BUILD_TYPE}} --prefix "${{github.workspace}}/install/shared/" + - name: Preparing for Upload + run: | + mkdir "artifacts" + Copy-Item "install\shared\bin\libragephoto.dll" "artifacts\" - name: Upload uses: actions/upload-artifact@v5 with: - name: Windows MSVC ${{matrix.arch}} - path: ${{github.workspace}}/install/bin/libragephoto.dll + name: Windows ${{matrix.arch}} + path: ${{github.workspace}}/artifacts/ Release: needs: [Linux, macOS, Windows] runs-on: windows-latest - defaults: - run: - shell: pwsh steps: - name: Cloning uses: actions/checkout@v5 - - name: Download Linux arm64 Assets + - name: Download Linux arm64 glibc Artifacts uses: actions/download-artifact@v6 with: - name: Linux arm64 - path: assets/linux-arm64 - - name: Download Linux x64 Assets + name: Linux arm64 glibc + path: ${{github.workspace}}/src/dotnet/runtimes/linux-arm64/native + - name: Download Linux x64 glibc Artifacts uses: actions/download-artifact@v6 with: - name: Linux x64 - path: assets/linux-x64 - - name: Download macOS arm64 Assets + name: Linux x64 glibc + path: ${{github.workspace}}/src/dotnet/runtimes/linux-x64/native + - name: Download macOS arm64 Artifacts uses: actions/download-artifact@v6 with: name: macOS arm64 - path: assets/osx-arm64 - - name: Download macOS x64 Assets + path: ${{github.workspace}}/src/dotnet/runtimes/osx-arm64/native + - name: Download macOS x64 Artifacts uses: actions/download-artifact@v6 with: name: macOS x64 - path: assets/osx-x64 - - name: Download Windows arm64 Assets + path: ${{github.workspace}}/src/dotnet/runtimes/osx-x64/native + - name: Download Windows arm64 Artifacts uses: actions/download-artifact@v6 with: - name: Windows MSVC arm64 - path: assets/win-arm64 - - name: Download Windows x64 Assets + name: Windows arm64 + path: ${{github.workspace}}/src/dotnet/runtimes/win-arm64/native + - name: Download Windows x64 Artifacts uses: actions/download-artifact@v6 with: - name: Windows MSVC x64 - path: assets/win-x64 - - name: Download Windows x86 Assets + name: Windows x64 + path: ${{github.workspace}}/src/dotnet/runtimes/win-x64/native + - name: Download Windows x86 Artifacts uses: actions/download-artifact@v6 with: - name: Windows MSVC x86 - path: assets/win-x86 - - name: Copy Assets - run: | - mkdir -p "${{github.workspace}}\src\dotnet\runtimes\linux-arm64\native" - mkdir -p "${{github.workspace}}\src\dotnet\runtimes\linux-x64\native" - mkdir -p "${{github.workspace}}\src\dotnet\runtimes\osx-arm64\native" - mkdir -p "${{github.workspace}}\src\dotnet\runtimes\osx-x64\native" - mkdir -p "${{github.workspace}}\src\dotnet\runtimes\win-arm64\native" - mkdir -p "${{github.workspace}}\src\dotnet\runtimes\win-x64\native" - mkdir -p "${{github.workspace}}\src\dotnet\runtimes\win-x86\native" - cp "${{github.workspace}}\assets\linux-arm64\libragephoto.so" "${{github.workspace}}\src\dotnet\runtimes\linux-arm64\native\libragephoto.so" - cp "${{github.workspace}}\assets\linux-x64\libragephoto.so" "${{github.workspace}}\src\dotnet\runtimes\linux-x64\native\libragephoto.so" - cp "${{github.workspace}}\assets\osx-arm64\libragephoto.dylib" "${{github.workspace}}\src\dotnet\runtimes\osx-arm64\native\libragephoto.dylib" - cp "${{github.workspace}}\assets\osx-x64\libragephoto.dylib" "${{github.workspace}}\src\dotnet\runtimes\osx-x64\native\libragephoto.dylib" - cp "${{github.workspace}}\assets\win-arm64\libragephoto.dll" "${{github.workspace}}\src\dotnet\runtimes\win-arm64\native\libragephoto.dll" - cp "${{github.workspace}}\assets\win-x64\libragephoto.dll" "${{github.workspace}}\src\dotnet\runtimes\win-x64\native\libragephoto.dll" - cp "${{github.workspace}}\assets\win-x86\libragephoto.dll" "${{github.workspace}}\src\dotnet\runtimes\win-x86\native\libragephoto.dll" + name: Windows x86 + path: ${{github.workspace}}/src/dotnet/runtimes/win-x86/native - name: Setup MSBuild uses: microsoft/setup-msbuild@v2 - name: Setup .NET @@ -161,4 +161,4 @@ jobs: uses: actions/upload-artifact@v5 with: name: NuGet Package - path: ${{github.workspace}}\src\dotnet\bin\${{env.BUILD_TYPE}}\RagePhoto.Core.*.nupkg + path: ${{github.workspace}}/src/dotnet/bin/${{env.BUILD_TYPE}}/RagePhoto.Core.*.nupkg From c8cd8112f0584202086c5a01dc043751ed9256c8 Mon Sep 17 00:00:00 2001 From: Syping Date: Mon, 10 Nov 2025 17:58:06 +0100 Subject: [PATCH 06/10] libragephoto 0.8.0 release - CMakeLists.txt: update version to 0.8.0 - src/dotnet: add .NET 8.0 target - src/dotnet: add README.md - src/dotnet: fix .targets file for .NET Framework 4.7 - src/dotnet: simplify exception string handling - src/dotnet: update version to 0.8.0 --- CMakeLists.txt | 2 +- src/dotnet/README.md | 21 ++++++++ src/dotnet/RagePhoto.Core.csproj | 27 +++++----- src/dotnet/RagePhoto.cs | 52 +++++++++---------- src/dotnet/RagePhotoException.cs | 2 +- src/dotnet/{ => net47}/RagePhoto.Core.targets | 19 ++++--- 6 files changed, 73 insertions(+), 50 deletions(-) create mode 100644 src/dotnet/README.md rename src/dotnet/{ => net47}/RagePhoto.Core.targets (65%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 02e262c..10258be 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,7 @@ cmake_minimum_required(VERSION 3.16) cmake_policy(VERSION 3.16...3.28) -project(ragephoto VERSION 0.7.1 LANGUAGES C CXX) +project(ragephoto VERSION 0.8.0 LANGUAGES C CXX) include(GNUInstallDirs) # RagePhoto CMake includes diff --git a/src/dotnet/README.md b/src/dotnet/README.md new file mode 100644 index 0000000..a4198e4 --- /dev/null +++ b/src/dotnet/README.md @@ -0,0 +1,21 @@ +## RagePhoto.Core +Open Source RAGE Photo Parser for GTA V and RDR 2 + +- Read/Write RAGE Photos error free and correct +- Support for metadata stored in RAGE Photos +- Simple .NET API +- Based on libragephoto + +#### How to Use RagePhoto.Core + +```c# +using RagePhoto; + +/* Get Image from Photo */ +static Image GetImageFromPhoto(String inputFile) { + using Photo photo = new(); + photo.LoadFile(inputFile); + using MemoryStream jpegStream = new(photo.Jpeg); + return Image.FromStream(jpegStream); +} +``` diff --git a/src/dotnet/RagePhoto.Core.csproj b/src/dotnet/RagePhoto.Core.csproj index 0cb99f7..05b3401 100644 --- a/src/dotnet/RagePhoto.Core.csproj +++ b/src/dotnet/RagePhoto.Core.csproj @@ -1,16 +1,17 @@  - netstandard2.1;net47 + netstandard2.1;net47;net8.0 RagePhoto.Core RagePhoto - 0.7.1 - 0.7.1 - 0.7.1 + 0.8.0 + 0.8.0 + 0.8.0 Syping Copyright © 2025 Syping Open Source RAGE Photo Parser for GTA V and RDR 2 BSD-2-Clause + README.md https://github.com/Syping/libragephoto disable @@ -20,16 +21,14 @@ - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - + + + + + + + + diff --git a/src/dotnet/RagePhoto.cs b/src/dotnet/RagePhoto.cs index d70f26e..033db5c 100644 --- a/src/dotnet/RagePhoto.cs +++ b/src/dotnet/RagePhoto.cs @@ -98,7 +98,7 @@ namespace RagePhoto { if (_instance == IntPtr.Zero) throw new RagePhotoException("Failed to initialize libragephoto"); if (!ragephoto_setphotodatac(_instance, ragephoto_getphotodata(photo._instance))) - throw new RagePhotoException(this, String.Format("Failed to copy Photo: {0}", Error), Error); + throw new RagePhotoException(this, "Failed to copy Photo", Error); } catch (Exception exception) { throw new RagePhotoException("Failed to initialize libragephoto", exception); @@ -127,12 +127,12 @@ namespace RagePhoto { public void Load(Byte[] data) { if (!ragephoto_load(_instance, data, (UIntPtr)data.LongLength)) - throw new RagePhotoException(this, String.Format("Failed to load Photo: {0}", Error), Error); + throw new RagePhotoException(this, "Failed to load Photo", Error); } public void LoadFile(String path) { if (!ragephoto_loadfile(_instance, path)) - throw new RagePhotoException(this, String.Format("Failed to load Photo: {0}", Error), Error); + throw new RagePhotoException(this, "Failed to load Photo", Error); } public String Description { @@ -159,7 +159,16 @@ namespace RagePhoto { Marshal.Copy(ptr, buffer, 0, (Int32)size); return buffer; } - set => SetJpeg(value); + set { + UInt32 size = (UInt32)value.Length; + UInt32 bufferSize = Format switch { + PhotoFormat.GTA5 => size > (UInt32)DefaultSize.DEFAULT_GTA5_PHOTOBUFFER ? size : (UInt32)DefaultSize.DEFAULT_GTA5_PHOTOBUFFER, + PhotoFormat.RDR2 => size > (UInt32)DefaultSize.DEFAULT_RDR2_PHOTOBUFFER ? size : (UInt32)DefaultSize.DEFAULT_RDR2_PHOTOBUFFER, + _ => size + }; + if (!ragephoto_setphotojpeg(_instance, value, size, bufferSize)) + throw new RagePhotoException(this, "Failed to set Jpeg", Error); + } } public UInt32 JpegSize { @@ -199,25 +208,25 @@ namespace RagePhoto { public Byte[] Save() { Byte[] photo = new Byte[Environment.Is64BitProcess ? (UInt64)GetSaveSize() : (UInt32)GetSaveSize()]; if (!ragephoto_save(_instance, photo)) - throw new RagePhotoException(this, string.Format("Failed to save Photo: {0}", Error), Error); + throw new RagePhotoException(this, "Failed to save Photo", Error); return photo; } public Byte[] Save(PhotoFormat photoFormat) { Byte[] photo = new Byte[Environment.Is64BitProcess ? (UInt64)GetSaveSize(photoFormat) : (UInt32)GetSaveSize(photoFormat)]; if (!ragephoto_savef(_instance, photo, (UInt32)photoFormat)) - throw new RagePhotoException(this, string.Format("Failed to save Photo: {0}", Error), Error); + throw new RagePhotoException(this, "Failed to save Photo", Error); return photo; } public void SaveFile(String path) { if (!ragephoto_savefile(_instance, path)) - throw new RagePhotoException(this, string.Format("Failed to save Photo: {0}", Error), Error); + throw new RagePhotoException(this, "Failed to save Photo", Error); } public void SaveFile(String path, PhotoFormat photoFormat) { if (!ragephoto_savefilef(_instance, path, (UInt32)photoFormat)) - throw new RagePhotoException(this, string.Format("Failed to save Photo: {0}", Error), Error); + throw new RagePhotoException(this, "Failed to save Photo", Error); } public void SetBufferDefault() { @@ -241,32 +250,19 @@ namespace RagePhoto { } public void SetJpeg(Byte[] jpeg) { - UInt32 bufferSize; UInt32 size = (UInt32)jpeg.Length; - switch (Format) { - case PhotoFormat.GTA5: - if (size > (UInt32)DefaultSize.DEFAULT_GTA5_PHOTOBUFFER) - bufferSize = size; - else - bufferSize = (UInt32)DefaultSize.DEFAULT_GTA5_PHOTOBUFFER; - break; - case PhotoFormat.RDR2: - if (size > (UInt32)DefaultSize.DEFAULT_RDR2_PHOTOBUFFER) - bufferSize = size; - else - bufferSize = (UInt32)DefaultSize.DEFAULT_RDR2_PHOTOBUFFER; - break; - default: - bufferSize = size; - break; - } + UInt32 bufferSize = Format switch { + PhotoFormat.GTA5 => size > (UInt32)DefaultSize.DEFAULT_GTA5_PHOTOBUFFER ? size : (UInt32)DefaultSize.DEFAULT_GTA5_PHOTOBUFFER, + PhotoFormat.RDR2 => size > (UInt32)DefaultSize.DEFAULT_RDR2_PHOTOBUFFER ? size : (UInt32)DefaultSize.DEFAULT_RDR2_PHOTOBUFFER, + _ => size + }; if (!ragephoto_setphotojpeg(_instance, jpeg, size, bufferSize)) - throw new RagePhotoException(this, String.Format("Failed to set Jpeg: {0}", Error), Error); + throw new RagePhotoException(this, "Failed to set Jpeg", Error); } public void SetJpeg(Byte[] jpeg, UInt32 bufferSize) { if (!ragephoto_setphotojpeg(_instance, jpeg, (UInt32)jpeg.Length, bufferSize)) - throw new RagePhotoException(this, String.Format("Failed to set Jpeg: {0}", Error), Error); + throw new RagePhotoException(this, "Failed to set Jpeg", Error); } public void SetJson(String json) { diff --git a/src/dotnet/RagePhotoException.cs b/src/dotnet/RagePhotoException.cs index 4f8fdf6..7aeb2e1 100644 --- a/src/dotnet/RagePhotoException.cs +++ b/src/dotnet/RagePhotoException.cs @@ -15,7 +15,7 @@ namespace RagePhoto { _error = PhotoError.Uninitialised; } - public RagePhotoException(Photo photo, String message, PhotoError error) : base(message) { + public RagePhotoException(Photo photo, String message, PhotoError error) : base(String.Format("{0}: {1}", message, error)) { _error = error; _photo = photo; } diff --git a/src/dotnet/RagePhoto.Core.targets b/src/dotnet/net47/RagePhoto.Core.targets similarity index 65% rename from src/dotnet/RagePhoto.Core.targets rename to src/dotnet/net47/RagePhoto.Core.targets index 9e84d18..25e9065 100644 --- a/src/dotnet/RagePhoto.Core.targets +++ b/src/dotnet/net47/RagePhoto.Core.targets @@ -1,21 +1,28 @@ - + + + + libragephoto.dll PreserveNewest - false - + + + + libragephoto.dll PreserveNewest - false - + + + + libragephoto.dll PreserveNewest - false + From b1509597271e5373a19f477f4f3d487527b9c777 Mon Sep 17 00:00:00 2001 From: Syping Date: Mon, 10 Nov 2025 20:03:45 +0100 Subject: [PATCH 07/10] libragephoto: fix jpegSize not set to 0 when being cleared --- src/core/RagePhoto.c | 1 + src/core/RagePhoto.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/src/core/RagePhoto.c b/src/core/RagePhoto.c index 659a192..f3da886 100644 --- a/src/core/RagePhoto.c +++ b/src/core/RagePhoto.c @@ -1235,6 +1235,7 @@ bool ragephoto_setphotojpeg(ragephoto_t instance, const char *data, uint32_t siz else if (instance->data->jpeg) { free(instance->data->jpeg); instance->data->jpeg = NULL; + instance->data->jpegSize = 0; } if (bufferSize != 0) { diff --git a/src/core/RagePhoto.cpp b/src/core/RagePhoto.cpp index 5dbdd98..345836a 100644 --- a/src/core/RagePhoto.cpp +++ b/src/core/RagePhoto.cpp @@ -1231,6 +1231,7 @@ bool RagePhoto::setJpeg(const char *data, uint32_t size, uint32_t bufferSize) else if (m_data->jpeg) { free(m_data->jpeg); m_data->jpeg = nullptr; + m_data->jpegSize = 0; } if (bufferSize != 0) { From b87fd1d8fd0b0c5f77094166c43e4fd77ee1ba3c Mon Sep 17 00:00:00 2001 From: Syping Date: Mon, 10 Nov 2025 20:16:25 +0100 Subject: [PATCH 08/10] libragephoto: fix memory issues with Jpeg saving - RagePhoto.c: return PHOTOREADERROR when no Jpeg is being set when ragephotodata_savef is being called with Jpeg format - RagePhoto.cpp: return PhotoReadError when no Jpeg is being set when RagePhoto::save is being called with Jpeg format --- src/core/RagePhoto.c | 12 ++++++++---- src/core/RagePhoto.cpp | 12 ++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/core/RagePhoto.c b/src/core/RagePhoto.c index f3da886..a0fe93c 100644 --- a/src/core/RagePhoto.c +++ b/src/core/RagePhoto.c @@ -972,10 +972,14 @@ bool ragephotodata_savef(RagePhotoData *rp_data, RagePhotoFormatParser *rp_parse #endif } else if (photoFormat == RAGEPHOTO_FORMAT_JPEG) { - const size_t length = ragephotodata_getsavesizef(rp_data, NULL, photoFormat); - size_t pos = 0; - - writeBuffer(rp_data->jpeg, data, &pos, length, rp_data->jpegSize); + if (rp_data->jpeg) { + size_t pos = 0; + writeBuffer(rp_data->jpeg, data, &pos, rp_data->jpegSize, rp_data->jpegSize); + } + else { + rp_data->error = RAGEPHOTO_ERROR_PHOTOREADERROR; // 17 + return false; + } rp_data->error = RAGEPHOTO_ERROR_NOERROR; // 255 return true; diff --git a/src/core/RagePhoto.cpp b/src/core/RagePhoto.cpp index 345836a..7a0b5e7 100644 --- a/src/core/RagePhoto.cpp +++ b/src/core/RagePhoto.cpp @@ -943,10 +943,14 @@ bool RagePhoto::save(char *data, uint32_t photoFormat, RagePhotoData *rp_data, R #endif } else if (photoFormat == PhotoFormat::JPEG) { - const size_t length = saveSize(photoFormat, rp_data, nullptr); - size_t pos = 0; - - writeBuffer(rp_data->jpeg, data, &pos, length, rp_data->jpegSize); + if (rp_data->jpeg) { + size_t pos = 0; + writeBuffer(rp_data->jpeg, data, &pos, rp_data->jpegSize, rp_data->jpegSize); + } + else { + rp_data->error = Error::PhotoReadError; // 17 + return false; + } rp_data->error = Error::NoError; // 255 return true; From 728a3dff6cfe28c63ad252efe92f9dfc8bc5b896 Mon Sep 17 00:00:00 2001 From: Syping Date: Tue, 11 Nov 2025 19:22:47 +0100 Subject: [PATCH 09/10] libragephoto 0.8.1 release - CMakeLists.txt: update version to 0.8.1 - doc: depend on CMake >= 3.16 - ragephoto-gtkviewer: depend on CMake >= 3.16 and ragephoto >= 0.8 - ragephoto-qtviewer: depend on CMake >= 3.16 and ragephoto >= 0.8 - src/dotnet: update version to 0.8.1 --- CMakeLists.txt | 2 +- doc/CMakeLists.txt | 5 +++-- examples/ragephoto-gtkviewer/CMakeLists.txt | 11 +++++------ examples/ragephoto-qtviewer/CMakeLists.txt | 11 +++++------ src/dotnet/RagePhoto.Core.csproj | 6 +++--- 5 files changed, 17 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 10258be..a128bc8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,7 @@ cmake_minimum_required(VERSION 3.16) cmake_policy(VERSION 3.16...3.28) -project(ragephoto VERSION 0.8.0 LANGUAGES C CXX) +project(ragephoto VERSION 0.8.1 LANGUAGES C CXX) include(GNUInstallDirs) # RagePhoto CMake includes diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 377196c..0f9a734 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -1,6 +1,6 @@ #[[************************************************************************** * libragephoto RAGE Photo Parser -* Copyright (C) 2021-2024 Syping +* Copyright (C) 2021-2025 Syping * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: @@ -16,7 +16,8 @@ * responsible for anything with use of the software, you are self responsible. ****************************************************************************]] -cmake_minimum_required(VERSION 3.7) +cmake_minimum_required(VERSION 3.16) +cmake_policy(VERSION 3.16...3.28) find_package(Doxygen REQUIRED) include(GNUInstallDirs) diff --git a/examples/ragephoto-gtkviewer/CMakeLists.txt b/examples/ragephoto-gtkviewer/CMakeLists.txt index 55b52bc..9e7ae29 100644 --- a/examples/ragephoto-gtkviewer/CMakeLists.txt +++ b/examples/ragephoto-gtkviewer/CMakeLists.txt @@ -1,6 +1,6 @@ #[[************************************************************************** * libragephoto RAGE Photo Parser -* Copyright (C) 2021-2022 Syping +* Copyright (C) 2021-2025 Syping * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: @@ -16,7 +16,8 @@ * responsible for anything with use of the software, you are self responsible. ****************************************************************************]] -cmake_minimum_required(VERSION 3.7) +cmake_minimum_required(VERSION 3.16) +cmake_policy(VERSION 3.16...3.28) project(ragephoto-gtkviewer LANGUAGES CXX) include(GNUInstallDirs) @@ -35,7 +36,7 @@ if (TARGET ragephoto) set(RAGEPHOTO_LIBRARIES ragephoto) set(RAGEPHOTO_LIBRARY_DIRS ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}) else() - pkg_check_modules(RAGEPHOTO REQUIRED ragephoto>=0.6) + pkg_check_modules(RAGEPHOTO REQUIRED ragephoto>=0.8) endif() add_executable(ragephoto-gtkviewer WIN32 ${GTKVIEWER_SOURCES}) @@ -44,8 +45,6 @@ set_target_properties(ragephoto-gtkviewer PROPERTIES ) target_compile_options(ragephoto-gtkviewer PRIVATE ${GTKMM_CFLAGS} ${RAGEPHOTO_CFLAGS}) target_link_libraries(ragephoto-gtkviewer PRIVATE ${GTKMM_LIBRARIES} ${RAGEPHOTO_LIBRARIES}) -if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.13.0") - target_link_directories(ragephoto-gtkviewer PRIVATE ${GTKMM_LIBRARY_DIRS} ${RAGEPHOTO_LIBRARY_DIRS}) -endif() +target_link_directories(ragephoto-gtkviewer PRIVATE ${GTKMM_LIBRARY_DIRS} ${RAGEPHOTO_LIBRARY_DIRS}) target_include_directories(ragephoto-gtkviewer PRIVATE ${GTKMM_INCLUDE_DIRS} ${RAGEPHOTO_INCLUDE_DIRS}) install(TARGETS ragephoto-gtkviewer DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/examples/ragephoto-qtviewer/CMakeLists.txt b/examples/ragephoto-qtviewer/CMakeLists.txt index eed3390..6c21e56 100644 --- a/examples/ragephoto-qtviewer/CMakeLists.txt +++ b/examples/ragephoto-qtviewer/CMakeLists.txt @@ -1,6 +1,6 @@ #[[************************************************************************** * libragephoto RAGE Photo Parser -* Copyright (C) 2021-2022 Syping +* Copyright (C) 2021-2025 Syping * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: @@ -16,7 +16,8 @@ * responsible for anything with use of the software, you are self responsible. ****************************************************************************]] -cmake_minimum_required(VERSION 3.7) +cmake_minimum_required(VERSION 3.16) +cmake_policy(VERSION 3.16...3.28) project(ragephoto-qtviewer LANGUAGES CXX) include(GNUInstallDirs) @@ -41,7 +42,7 @@ if (TARGET ragephoto) set(RAGEPHOTO_LIBRARY_DIRS ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}) else() find_package(PkgConfig REQUIRED) - pkg_check_modules(RAGEPHOTO REQUIRED ragephoto>=0.6) + pkg_check_modules(RAGEPHOTO REQUIRED ragephoto>=0.8) endif() add_executable(ragephoto-qtviewer WIN32 ${QTVIEWER_SOURCES}) @@ -50,8 +51,6 @@ set_target_properties(ragephoto-qtviewer PROPERTIES ) target_compile_options(ragephoto-qtviewer PRIVATE ${RAGEPHOTO_CFLAGS}) target_link_libraries(ragephoto-qtviewer PRIVATE Qt${QT_VERSION_MAJOR}::Widgets ${RAGEPHOTO_LIBRARIES}) -if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.13.0") - target_link_directories(ragephoto-qtviewer PRIVATE ${RAGEPHOTO_LIBRARY_DIRS}) -endif() +target_link_directories(ragephoto-qtviewer PRIVATE ${RAGEPHOTO_LIBRARY_DIRS}) target_include_directories(ragephoto-qtviewer PRIVATE ${RAGEPHOTO_INCLUDE_DIRS}) install(TARGETS ragephoto-qtviewer DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/src/dotnet/RagePhoto.Core.csproj b/src/dotnet/RagePhoto.Core.csproj index 05b3401..c0e2bb5 100644 --- a/src/dotnet/RagePhoto.Core.csproj +++ b/src/dotnet/RagePhoto.Core.csproj @@ -4,9 +4,9 @@ netstandard2.1;net47;net8.0 RagePhoto.Core RagePhoto - 0.8.0 - 0.8.0 - 0.8.0 + 0.8.1 + 0.8.1 + 0.8.1 Syping Copyright © 2025 Syping Open Source RAGE Photo Parser for GTA V and RDR 2 From 5c43a39d1322c8cc943758d6173a8a177e76ddd2 Mon Sep 17 00:00:00 2001 From: Syping Date: Sun, 30 Nov 2025 08:13:17 +0100 Subject: [PATCH 10/10] libragephoto 0.8.2 release - CMakeLists.txt: update version to 0.8.2 - RagePhoto.cpp: fix memory issue on Windows convertPath function for C+ +11 support - RagePhoto.cs: code style changes for Boolean - RagePhoto.h: update copyright header - RagePhoto.hpp: update copyright header - RagePhotoLibrary.h: update copyright header - src/dotnet: add package tags and update version to 0.8.2 --- CMakeLists.txt | 2 +- src/core/RagePhoto.cpp | 17 ++++++++++------- src/core/RagePhoto.h | 2 +- src/core/RagePhoto.hpp | 2 +- src/core/RagePhotoLibrary.h | 2 +- src/dotnet/RagePhoto.Core.csproj | 9 +++++---- src/dotnet/RagePhoto.cs | 20 ++++++++++---------- 7 files changed, 29 insertions(+), 25 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a128bc8..0a7726a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,7 @@ cmake_minimum_required(VERSION 3.16) cmake_policy(VERSION 3.16...3.28) -project(ragephoto VERSION 0.8.1 LANGUAGES C CXX) +project(ragephoto VERSION 0.8.2 LANGUAGES C CXX) include(GNUInstallDirs) # RagePhoto CMake includes diff --git a/src/core/RagePhoto.cpp b/src/core/RagePhoto.cpp index 7a0b5e7..b76ed75 100644 --- a/src/core/RagePhoto.cpp +++ b/src/core/RagePhoto.cpp @@ -66,13 +66,16 @@ const char* nullchar = ""; /* BEGIN OF STATIC LIBRARY FUNCTIONS */ #if defined(_WIN32) && ((RAGEPHOTO_CXX_STD < 17) || (__cplusplus < 201703L)) -inline std::unique_ptr convertPath(const char *path) +inline std::wstring convertPath(const char *path) { int wideCharSize = MultiByteToWideChar(CP_UTF8, 0, path, -1, nullptr, 0); if (wideCharSize <= 0) - return std::unique_ptr(new wchar_t[1]()); - std::unique_ptr wideCharPath(new wchar_t[wideCharSize]); - MultiByteToWideChar(CP_UTF8, 0, path, -1, wideCharPath.get(), wideCharSize); + return {}; + std::wstring wideCharPath; + wideCharPath.resize(wideCharSize); + if (!MultiByteToWideChar(CP_UTF8, 0, path, -1, &wideCharPath[0], wideCharSize)) + return {}; + wideCharPath.resize(wideCharSize - 1); return wideCharPath; } #endif @@ -292,7 +295,7 @@ bool RagePhoto::load(const char *data, size_t length, RagePhotoData *rp_data, Ra rp_data->error = Error::HeaderMallocError; // 4 return false; } - memcpy(rp_data->header, photoHeader_string.c_str(), photoHeader_size); + memcpy(rp_data->header, photoHeader_string.data(), photoHeader_size); #elif defined UNICODE_ICONV iconv_t iconv_in = iconv_open("UTF-8", "UTF-16LE"); if (iconv_in == (iconv_t)-1) { @@ -610,7 +613,7 @@ bool RagePhoto::loadFile(const char *filename) #if defined(_WIN32) && (RAGEPHOTO_CXX_STD >= 17) && (__cplusplus >= 201703L) std::ifstream ifs(std::filesystem::u8path(filename), std::ios::in | std::ios::binary); #elif defined(_WIN32) - std::ifstream ifs(convertPath(filename).get(), std::ios::in | std::ios::binary); + std::ifstream ifs(convertPath(filename).data(), std::ios::in | std::ios::binary); #else std::ifstream ifs(filename, std::ios::in | std::ios::binary); #endif @@ -1012,7 +1015,7 @@ bool RagePhoto::saveFile(const char *filename, uint32_t photoFormat) #if defined(_WIN32) && (RAGEPHOTO_CXX_STD >= 17) && (__cplusplus >= 201703L) std::ofstream ofs(std::filesystem::u8path(filename), std::ios::out | std::ios::binary | std::ios::trunc); #elif defined(_WIN32) - std::ofstream ofs(convertPath(filename).get(), std::ios::out | std::ios::binary | std::ios::trunc); + std::ofstream ofs(convertPath(filename).data(), std::ios::out | std::ios::binary | std::ios::trunc); #else std::ofstream ofs(filename, std::ios::out | std::ios::binary | std::ios::trunc); #endif diff --git a/src/core/RagePhoto.h b/src/core/RagePhoto.h index 68429be..4047de9 100644 --- a/src/core/RagePhoto.h +++ b/src/core/RagePhoto.h @@ -1,6 +1,6 @@ /***************************************************************************** * libragephoto RAGE Photo Parser -* Copyright (C) 2021-2024 Syping +* Copyright (C) 2021-2025 Syping * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: diff --git a/src/core/RagePhoto.hpp b/src/core/RagePhoto.hpp index ad1b52d..b36287d 100644 --- a/src/core/RagePhoto.hpp +++ b/src/core/RagePhoto.hpp @@ -1,6 +1,6 @@ /***************************************************************************** * libragephoto RAGE Photo Parser -* Copyright (C) 2023-2024 Syping +* Copyright (C) 2023-2025 Syping * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: diff --git a/src/core/RagePhotoLibrary.h b/src/core/RagePhotoLibrary.h index 66896eb..3058cc7 100644 --- a/src/core/RagePhotoLibrary.h +++ b/src/core/RagePhotoLibrary.h @@ -1,6 +1,6 @@ /***************************************************************************** * libragephoto RAGE Photo Parser -* Copyright (C) 2023 Syping +* Copyright (C) 2023-2025 Syping * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: diff --git a/src/dotnet/RagePhoto.Core.csproj b/src/dotnet/RagePhoto.Core.csproj index c0e2bb5..7e178bd 100644 --- a/src/dotnet/RagePhoto.Core.csproj +++ b/src/dotnet/RagePhoto.Core.csproj @@ -1,17 +1,18 @@  - netstandard2.1;net47;net8.0 + netstandard2.1;net47 RagePhoto.Core RagePhoto - 0.8.1 - 0.8.1 - 0.8.1 + 0.8.2 + 0.8.2 + 0.8.2 Syping Copyright © 2025 Syping Open Source RAGE Photo Parser for GTA V and RDR 2 BSD-2-Clause README.md + libragephoto;gta5;gtav;snapmatic;rdr2;photo https://github.com/Syping/libragephoto disable diff --git a/src/dotnet/RagePhoto.cs b/src/dotnet/RagePhoto.cs index 033db5c..ddb1dd7 100644 --- a/src/dotnet/RagePhoto.cs +++ b/src/dotnet/RagePhoto.cs @@ -6,7 +6,7 @@ namespace RagePhoto { public class Photo : IDisposable { - private bool _disposed; + private Boolean _disposed; private readonly IntPtr _instance; private const String _library = "libragephoto"; @@ -18,10 +18,10 @@ namespace RagePhoto { private static extern void ragephoto_close(IntPtr instance); [DllImport(_library, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.I1)] - private static extern bool ragephoto_load(IntPtr instance, Byte[] data, UIntPtr size); + private static extern Boolean ragephoto_load(IntPtr instance, Byte[] data, UIntPtr size); [DllImport(_library, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.I1)] - private static extern bool ragephoto_loadfile(IntPtr instance, [MarshalAs(UnmanagedType.LPUTF8Str)] String filename); + private static extern Boolean ragephoto_loadfile(IntPtr instance, [MarshalAs(UnmanagedType.LPUTF8Str)] String filename); [DllImport(_library, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] private static extern Int32 ragephoto_error(IntPtr instance); [DllImport(_library, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] @@ -48,30 +48,30 @@ namespace RagePhoto { private static extern UIntPtr ragephoto_getsavesizef(IntPtr instance, UInt32 photoFormat); [DllImport(_library, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.I1)] - private static extern bool ragephoto_save(IntPtr instance, [Out] Byte[] data); + private static extern Boolean ragephoto_save(IntPtr instance, [Out] Byte[] data); [DllImport(_library, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.I1)] - private static extern bool ragephoto_savef(IntPtr instance, [Out] Byte[] data, UInt32 photoFormat); + private static extern Boolean ragephoto_savef(IntPtr instance, [Out] Byte[] data, UInt32 photoFormat); [DllImport(_library, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.I1)] - private static extern bool ragephoto_savefile(IntPtr instance, [MarshalAs(UnmanagedType.LPUTF8Str)] String filename); + private static extern Boolean ragephoto_savefile(IntPtr instance, [MarshalAs(UnmanagedType.LPUTF8Str)] String filename); [DllImport(_library, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.I1)] - private static extern bool ragephoto_savefilef(IntPtr instance, [MarshalAs(UnmanagedType.LPUTF8Str)] String filename, UInt32 photoFormat); + private static extern Boolean ragephoto_savefilef(IntPtr instance, [MarshalAs(UnmanagedType.LPUTF8Str)] String filename, UInt32 photoFormat); [DllImport(_library, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] private static extern void ragephoto_setbufferdefault(IntPtr instance); [DllImport(_library, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] private static extern void ragephoto_setbufferoffsets(IntPtr instance); [DllImport(_library, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.I1)] - private static extern bool ragephoto_setphotodatac(IntPtr instance, IntPtr data); + private static extern Boolean ragephoto_setphotodatac(IntPtr instance, IntPtr data); [DllImport(_library, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] private static extern void ragephoto_setphotodesc(IntPtr instance, [MarshalAs(UnmanagedType.LPUTF8Str)] String description, UInt32 bufferSize); [DllImport(_library, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] private static extern void ragephoto_setphotoformat(IntPtr instance, UInt32 photoFormat); [DllImport(_library, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.I1)] - private static extern bool ragephoto_setphotojpeg(IntPtr instance, Byte[] jpeg, UInt32 size, UInt32 bufferSize); + private static extern Boolean ragephoto_setphotojpeg(IntPtr instance, Byte[] jpeg, UInt32 size, UInt32 bufferSize); [DllImport(_library, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] private static extern void ragephoto_setphotojson(IntPtr instance, [MarshalAs(UnmanagedType.LPUTF8Str)] String json, UInt32 bufferSize); [DllImport(_library, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] @@ -114,7 +114,7 @@ namespace RagePhoto { GC.SuppressFinalize(this); } - protected virtual void Dispose(bool disposing) { + protected virtual void Dispose(Boolean disposing) { if (_disposed) return; ragephoto_close(_instance);