Compare commits
1 commit
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
af37275bad |
8 changed files with 97 additions and 34 deletions
77
.github/workflows/dotnet.yml
vendored
77
.github/workflows/dotnet.yml
vendored
|
|
@ -2,9 +2,68 @@ name: .NET
|
|||
on: push
|
||||
env:
|
||||
BUILD_TYPE: Release
|
||||
FREEBSD_DEPLOYMENT_TARGET: "13.2"
|
||||
OSX_DEPLOYMENT_TARGET: "11.0"
|
||||
|
||||
jobs:
|
||||
FreeBSD:
|
||||
runs-on: ${{matrix.runner}}
|
||||
container:
|
||||
image: almalinux:8
|
||||
strategy:
|
||||
matrix:
|
||||
arch: [arm64, x64]
|
||||
include:
|
||||
- arch: arm64
|
||||
runner: ubuntu-24.04-arm
|
||||
image-arch: arm64
|
||||
triplet-arch: aarch64
|
||||
- arch: x64
|
||||
runner: ubuntu-24.04
|
||||
image-arch: amd64
|
||||
triplet-arch: x86_64
|
||||
steps:
|
||||
- name: Cloning
|
||||
uses: actions/checkout@v5
|
||||
- name: Install packages
|
||||
run: dnf install -y bsdtar clang cmake lld wget
|
||||
- name: Install FreeBSD sysroot
|
||||
run: |
|
||||
mkdir -p /opt/freebsd/${{matrix.triplet-arch}}-pc-freebsd${{env.FREEBSD_DEPLOYMENT_TARGET}}
|
||||
cat > /opt/freebsd/${{matrix.triplet-arch}}-pc-freebsd${{env.FREEBSD_DEPLOYMENT_TARGET}}/toolchain.cmake << 'EOF'
|
||||
set(CMAKE_SYSTEM_NAME FreeBSD)
|
||||
set(CMAKE_SYSTEM_VERSION ${{env.FREEBSD_DEPLOYMENT_TARGET}})
|
||||
set(CMAKE_SYSTEM_PROCESSOR ${{matrix.triplet-arch}})
|
||||
set(CMAKE_C_COMPILER /usr/bin/clang)
|
||||
set(CMAKE_CXX_COMPILER /usr/bin/clang++)
|
||||
set(CMAKE_C_COMPILER_TARGET ${CMAKE_SYSTEM_PROCESSOR}-pc-freebsd${CMAKE_SYSTEM_VERSION})
|
||||
set(CMAKE_CXX_COMPILER_TARGET ${CMAKE_SYSTEM_PROCESSOR}-pc-freebsd${CMAKE_SYSTEM_VERSION})
|
||||
set(CMAKE_SYSROOT /opt/freebsd/${CMAKE_SYSTEM_PROCESSOR}-pc-freebsd${CMAKE_SYSTEM_VERSION}/sysroot)
|
||||
set(CMAKE_EXE_LINKER_FLAGS_INIT -fuse-ld=lld)
|
||||
set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT})
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
EOF
|
||||
mkdir -p /opt/freebsd/${{matrix.triplet-arch}}-pc-freebsd${{env.FREEBSD_DEPLOYMENT_TARGET}}/sysroot
|
||||
wget -q https://www.syping.de/freebsd-${{env.FREEBSD_DEPLOYMENT_TARGET}}/${{matrix.image-arch}}/base.txz
|
||||
bsdtar xfJ base.txz -C /opt/freebsd/${{matrix.triplet-arch}}-pc-freebsd${{env.FREEBSD_DEPLOYMENT_TARGET}}/sysroot
|
||||
rm -f base.txz
|
||||
- name: Configure CMake
|
||||
run: cmake -B "build/shared" -DRAGEPHOTO_C_LIBRARY=ON -DRAGEPHOTO_EXTRACT=OFF -DRAGEPHOTO_UNICODE=iconv -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=/opt/freebsd/${{matrix.triplet-arch}}-pc-freebsd${{env.FREEBSD_DEPLOYMENT_TARGET}}/toolchain.cmake
|
||||
- name: Build
|
||||
run: cmake --build "build/shared" --config ${{env.BUILD_TYPE}}
|
||||
- name: Install
|
||||
run: cmake --install "build/shared" --config ${{env.BUILD_TYPE}} --prefix "install/shared/"
|
||||
- name: Preparing for Upload
|
||||
run: |
|
||||
mkdir "artifacts"
|
||||
cp "install/shared/lib/libragephoto.so" "artifacts/"
|
||||
- name: Upload
|
||||
uses: actions/upload-artifact@v5
|
||||
with:
|
||||
name: FreeBSD ${{matrix.arch}}
|
||||
path: ${{github.workspace}}/artifacts/
|
||||
Linux:
|
||||
runs-on: ${{matrix.runner}}
|
||||
container:
|
||||
|
|
@ -36,8 +95,7 @@ jobs:
|
|||
- name: Preparing for Upload
|
||||
run: |
|
||||
mkdir "artifacts"
|
||||
cp "install/shared/${{matrix.libdir}}/libragephoto.so" \
|
||||
"artifacts/"
|
||||
cp "install/shared/${{matrix.libdir}}/libragephoto.so" "artifacts/"
|
||||
- name: Upload
|
||||
uses: actions/upload-artifact@v5
|
||||
with:
|
||||
|
|
@ -67,8 +125,7 @@ jobs:
|
|||
- name: Preparing for Upload
|
||||
run: |
|
||||
mkdir "artifacts"
|
||||
cp "install/shared/lib/libragephoto.dylib" \
|
||||
"artifacts/"
|
||||
cp "install/shared/lib/libragephoto.dylib" "artifacts/"
|
||||
- name: Upload
|
||||
uses: actions/upload-artifact@v5
|
||||
with:
|
||||
|
|
@ -109,11 +166,21 @@ jobs:
|
|||
name: Windows ${{matrix.arch}}
|
||||
path: ${{github.workspace}}/artifacts/
|
||||
Release:
|
||||
needs: [Linux, macOS, Windows]
|
||||
needs: [FreeBSD, Linux, macOS, Windows]
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- name: Cloning
|
||||
uses: actions/checkout@v5
|
||||
- name: Download FreeBSD arm64 Artifacts
|
||||
uses: actions/download-artifact@v6
|
||||
with:
|
||||
name: FreeBSD arm64
|
||||
path: ${{github.workspace}}/src/dotnet/runtimes/freebsd-arm64/native
|
||||
- name: Download FreeBSD x64 Artifacts
|
||||
uses: actions/download-artifact@v6
|
||||
with:
|
||||
name: FreeBSD x64
|
||||
path: ${{github.workspace}}/src/dotnet/runtimes/freebsd-x64/native
|
||||
- name: Download Linux arm64 glibc Artifacts
|
||||
uses: actions/download-artifact@v6
|
||||
with:
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
cmake_policy(VERSION 3.16...3.28)
|
||||
project(ragephoto VERSION 0.8.2 LANGUAGES C CXX)
|
||||
project(ragephoto VERSION 0.8.1 LANGUAGES C CXX)
|
||||
include(GNUInstallDirs)
|
||||
|
||||
# RagePhoto CMake includes
|
||||
|
|
|
|||
|
|
@ -66,16 +66,13 @@ const char* nullchar = "";
|
|||
|
||||
/* BEGIN OF STATIC LIBRARY FUNCTIONS */
|
||||
#if defined(_WIN32) && ((RAGEPHOTO_CXX_STD < 17) || (__cplusplus < 201703L))
|
||||
inline std::wstring convertPath(const char *path)
|
||||
inline std::unique_ptr<wchar_t> convertPath(const char *path)
|
||||
{
|
||||
int wideCharSize = MultiByteToWideChar(CP_UTF8, 0, path, -1, nullptr, 0);
|
||||
if (wideCharSize <= 0)
|
||||
return {};
|
||||
std::wstring wideCharPath;
|
||||
wideCharPath.resize(wideCharSize);
|
||||
if (!MultiByteToWideChar(CP_UTF8, 0, path, -1, &wideCharPath[0], wideCharSize))
|
||||
return {};
|
||||
wideCharPath.resize(wideCharSize - 1);
|
||||
return std::unique_ptr<wchar_t>(new wchar_t[1]());
|
||||
std::unique_ptr<wchar_t> wideCharPath(new wchar_t[wideCharSize]);
|
||||
MultiByteToWideChar(CP_UTF8, 0, path, -1, wideCharPath.get(), wideCharSize);
|
||||
return wideCharPath;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -295,7 +292,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.data(), photoHeader_size);
|
||||
memcpy(rp_data->header, photoHeader_string.c_str(), photoHeader_size);
|
||||
#elif defined UNICODE_ICONV
|
||||
iconv_t iconv_in = iconv_open("UTF-8", "UTF-16LE");
|
||||
if (iconv_in == (iconv_t)-1) {
|
||||
|
|
@ -613,7 +610,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).data(), std::ios::in | std::ios::binary);
|
||||
std::ifstream ifs(convertPath(filename).get(), std::ios::in | std::ios::binary);
|
||||
#else
|
||||
std::ifstream ifs(filename, std::ios::in | std::ios::binary);
|
||||
#endif
|
||||
|
|
@ -1015,7 +1012,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).data(), std::ios::out | std::ios::binary | std::ios::trunc);
|
||||
std::ofstream ofs(convertPath(filename).get(), std::ios::out | std::ios::binary | std::ios::trunc);
|
||||
#else
|
||||
std::ofstream ofs(filename, std::ios::out | std::ios::binary | std::ios::trunc);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*****************************************************************************
|
||||
* libragephoto RAGE Photo Parser
|
||||
* Copyright (C) 2021-2025 Syping
|
||||
* Copyright (C) 2021-2024 Syping
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*****************************************************************************
|
||||
* libragephoto RAGE Photo Parser
|
||||
* Copyright (C) 2023-2025 Syping
|
||||
* Copyright (C) 2023-2024 Syping
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*****************************************************************************
|
||||
* libragephoto RAGE Photo Parser
|
||||
* Copyright (C) 2023-2025 Syping
|
||||
* 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,18 +1,17 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netstandard2.1;net47</TargetFrameworks>
|
||||
<TargetFrameworks>netstandard2.1;net47;net8.0</TargetFrameworks>
|
||||
<AssemblyName>RagePhoto.Core</AssemblyName>
|
||||
<RootNamespace>RagePhoto</RootNamespace>
|
||||
<Version>0.8.2</Version>
|
||||
<AssemblyVersion>0.8.2</AssemblyVersion>
|
||||
<FileVersion>0.8.2</FileVersion>
|
||||
<Version>0.8.1</Version>
|
||||
<AssemblyVersion>0.8.1</AssemblyVersion>
|
||||
<FileVersion>0.8.1</FileVersion>
|
||||
<Authors>Syping</Authors>
|
||||
<Copyright>Copyright © 2025 Syping</Copyright>
|
||||
<Description>Open Source RAGE Photo Parser for GTA V and RDR 2</Description>
|
||||
<PackageLicenseExpression>BSD-2-Clause</PackageLicenseExpression>
|
||||
<PackageReadmeFile>README.md</PackageReadmeFile>
|
||||
<PackageTags>libragephoto;gta5;gtav;snapmatic;rdr2;photo</PackageTags>
|
||||
<RepositoryUrl>https://github.com/Syping/libragephoto</RepositoryUrl>
|
||||
<Nullable>disable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ namespace RagePhoto {
|
|||
|
||||
public class Photo : IDisposable {
|
||||
|
||||
private Boolean _disposed;
|
||||
private bool _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 Boolean ragephoto_load(IntPtr instance, Byte[] data, UIntPtr size);
|
||||
private static extern bool ragephoto_load(IntPtr instance, Byte[] data, UIntPtr size);
|
||||
[DllImport(_library, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
private static extern Boolean ragephoto_loadfile(IntPtr instance, [MarshalAs(UnmanagedType.LPUTF8Str)] String filename);
|
||||
private static extern bool 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 Boolean ragephoto_save(IntPtr instance, [Out] Byte[] data);
|
||||
private static extern bool ragephoto_save(IntPtr instance, [Out] Byte[] data);
|
||||
[DllImport(_library, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
private static extern Boolean ragephoto_savef(IntPtr instance, [Out] Byte[] data, UInt32 photoFormat);
|
||||
private static extern bool ragephoto_savef(IntPtr instance, [Out] Byte[] data, UInt32 photoFormat);
|
||||
[DllImport(_library, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
private static extern Boolean ragephoto_savefile(IntPtr instance, [MarshalAs(UnmanagedType.LPUTF8Str)] String filename);
|
||||
private static extern bool ragephoto_savefile(IntPtr instance, [MarshalAs(UnmanagedType.LPUTF8Str)] String filename);
|
||||
[DllImport(_library, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
|
||||
[return: MarshalAs(UnmanagedType.I1)]
|
||||
private static extern Boolean ragephoto_savefilef(IntPtr instance, [MarshalAs(UnmanagedType.LPUTF8Str)] String filename, UInt32 photoFormat);
|
||||
private static extern bool 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 Boolean ragephoto_setphotodatac(IntPtr instance, IntPtr data);
|
||||
private static extern bool 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 Boolean ragephoto_setphotojpeg(IntPtr instance, Byte[] jpeg, UInt32 size, UInt32 bufferSize);
|
||||
private static extern bool 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(Boolean disposing) {
|
||||
protected virtual void Dispose(bool disposing) {
|
||||
if (_disposed)
|
||||
return;
|
||||
ragephoto_close(_instance);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue