diff --git a/src/dotnet/RagePhoto.cs b/src/dotnet/RagePhoto.cs
index 7ad6d69..8fc0b34 100644
--- a/src/dotnet/RagePhoto.cs
+++ b/src/dotnet/RagePhoto.cs
@@ -1,7 +1,8 @@
using System;
using System.Runtime.InteropServices;
-namespace Syping.RagePhoto {
+namespace Syping.RagePhoto {
+
public class Photo : IDisposable {
private bool _disposed;
@@ -45,12 +46,16 @@ namespace Syping.RagePhoto {
[DllImport(_library)]
private static extern UIntPtr ragephoto_getsavesizef(IntPtr instance, UInt32 photoFormat);
[DllImport(_library)]
+ [return: MarshalAs(UnmanagedType.Bool)]
private static extern bool ragephoto_save(IntPtr instance, [Out] Byte[] data);
[DllImport(_library)]
+ [return: MarshalAs(UnmanagedType.Bool)]
private static extern bool ragephoto_savef(IntPtr instance, [Out] Byte[] data, UInt32 photoFormat);
[DllImport(_library)]
+ [return: MarshalAs(UnmanagedType.Bool)]
private static extern bool ragephoto_savefile(IntPtr instance, [MarshalAs(UnmanagedType.LPUTF8Str)] String filename);
[DllImport(_library)]
+ [return: MarshalAs(UnmanagedType.Bool)]
private static extern bool ragephoto_savefilef(IntPtr instance, [MarshalAs(UnmanagedType.LPUTF8Str)] String filename, UInt32 photoFormat);
[DllImport(_library)]
private static extern void ragephoto_setbufferdefault(IntPtr instance);
@@ -72,65 +77,6 @@ namespace Syping.RagePhoto {
[DllImport(_library)]
private static extern IntPtr ragephoto_version();
- public enum DefaultSize : UInt32 {
- DEFAULT_GTA5_PHOTOBUFFER = 524288U,
- DEFAULT_RDR2_PHOTOBUFFER = 1048576U,
- DEFAULT_DESCBUFFER = 256U,
- DEFAULT_JSONBUFFER = 3072U,
- DEFAULT_TITLBUFFER = 256U,
- GTA5_HEADERSIZE = 264U,
- RDR2_HEADERSIZE = 272U
- }
-
- public enum PhotoError : Int32 {
- DescBufferTight = 39,
- DescMallocError = 31,
- DescReadError = 32,
- HeaderBufferTight = 35,
- HeaderMallocError = 4,
- IncompatibleFormat = 2,
- IncompleteChecksum = 7,
- IncompleteDescBuffer = 30,
- IncompleteDescMarker = 28,
- IncompleteDescOffset = 11,
- IncompleteEOF = 8,
- IncompleteHeader = 3,
- IncompleteJendMarker = 33,
- IncompleteJpegMarker = 12,
- IncompleteJsonBuffer = 20,
- IncompleteJsonMarker = 18,
- IncompleteJsonOffset = 9,
- IncompletePhotoBuffer = 14,
- IncompletePhotoSize = 15,
- IncompleteTitleBuffer = 25,
- IncompleteTitleMarker = 23,
- IncompleteTitleOffset = 10,
- IncorrectDescMarker = 29,
- IncorrectJendMarker = 34,
- IncorrectJpegMarker = 13,
- IncorrectJsonMarker = 19,
- IncorrectTitleMarker = 24,
- JsonBufferTight = 37,
- JsonMallocError = 21,
- JsonReadError = 22,
- NoError = 255,
- NoFormatIdentifier = 1,
- PhotoBufferTight = 36,
- PhotoMallocError = 16,
- PhotoReadError = 17,
- TitleBufferTight = 38,
- TitleMallocError = 26,
- TitleReadError = 27,
- UnicodeInitError = 5,
- UnicodeHeaderError = 6,
- Uninitialised = 0
- }
-
- public enum PhotoFormat : UInt32 {
- GTA5 = 0x01000000U,
- RDR2 = 0x04000000U
- }
-
public Photo() {
try {
_instance = ragephoto_open();
@@ -169,8 +115,8 @@ namespace Syping.RagePhoto {
throw new RagePhotoException(this, string.Format("Failed to load Photo: {0}", Error.ToString()));
}
- public void LoadFile(String filePath) {
- bool result = ragephoto_loadfile(_instance, filePath);
+ public void LoadFile(String path) {
+ bool result = ragephoto_loadfile(_instance, path);
if (!result)
throw new RagePhotoException(this, string.Format("Failed to load Photo: {0}", Error.ToString()));
}
@@ -291,14 +237,14 @@ namespace Syping.RagePhoto {
return photo;
}
- public void SaveFile(String filePath) {
- bool result = ragephoto_savefile(_instance, filePath);
+ public void SaveFile(String path) {
+ bool result = ragephoto_savefile(_instance, path);
if (!result)
throw new RagePhotoException(this, string.Format("Failed to save Photo: {0}", Error.ToString()));
}
- public void SaveFile(String filePath, PhotoFormat photoFormat) {
- bool result = ragephoto_savefilef(_instance, filePath, (UInt32)photoFormat);
+ public void SaveFile(String path, PhotoFormat photoFormat) {
+ bool result = ragephoto_savefilef(_instance, path, (UInt32)photoFormat);
if (!result)
throw new RagePhotoException(this, string.Format("Failed to save Photo: {0}", Error.ToString()));
}
diff --git a/src/dotnet/RagePhotoData.cs b/src/dotnet/RagePhotoData.cs
index 4127744..1a164a5 100644
--- a/src/dotnet/RagePhotoData.cs
+++ b/src/dotnet/RagePhotoData.cs
@@ -2,17 +2,14 @@
using System.Runtime.InteropServices;
namespace Syping.RagePhoto {
+
[StructLayout(LayoutKind.Sequential)]
public readonly struct RagePhotoData {
readonly IntPtr jpeg;
- [MarshalAs(UnmanagedType.LPUTF8Str)]
- readonly String description;
- [MarshalAs(UnmanagedType.LPUTF8Str)]
- readonly String json;
- [MarshalAs(UnmanagedType.LPUTF8Str)]
- readonly String header;
- [MarshalAs(UnmanagedType.LPUTF8Str)]
- readonly String title;
+ readonly IntPtr description;
+ readonly IntPtr json;
+ readonly IntPtr header;
+ readonly IntPtr title;
readonly Int32 error;
readonly UInt32 descBuffer;
readonly UInt32 descOffset;
diff --git a/src/dotnet/RagePhotoTypes.cs b/src/dotnet/RagePhotoTypes.cs
new file mode 100644
index 0000000..2a94091
--- /dev/null
+++ b/src/dotnet/RagePhotoTypes.cs
@@ -0,0 +1,63 @@
+using System;
+
+namespace Syping.RagePhoto {
+
+ public enum DefaultSize : UInt32 {
+ DEFAULT_GTA5_PHOTOBUFFER = 524288U,
+ DEFAULT_RDR2_PHOTOBUFFER = 1048576U,
+ DEFAULT_DESCBUFFER = 256U,
+ DEFAULT_JSONBUFFER = 3072U,
+ DEFAULT_TITLBUFFER = 256U,
+ GTA5_HEADERSIZE = 264U,
+ RDR2_HEADERSIZE = 272U
+ }
+
+ public enum PhotoError : Int32 {
+ DescBufferTight = 39,
+ DescMallocError = 31,
+ DescReadError = 32,
+ HeaderBufferTight = 35,
+ HeaderMallocError = 4,
+ IncompatibleFormat = 2,
+ IncompleteChecksum = 7,
+ IncompleteDescBuffer = 30,
+ IncompleteDescMarker = 28,
+ IncompleteDescOffset = 11,
+ IncompleteEOF = 8,
+ IncompleteHeader = 3,
+ IncompleteJendMarker = 33,
+ IncompleteJpegMarker = 12,
+ IncompleteJsonBuffer = 20,
+ IncompleteJsonMarker = 18,
+ IncompleteJsonOffset = 9,
+ IncompletePhotoBuffer = 14,
+ IncompletePhotoSize = 15,
+ IncompleteTitleBuffer = 25,
+ IncompleteTitleMarker = 23,
+ IncompleteTitleOffset = 10,
+ IncorrectDescMarker = 29,
+ IncorrectJendMarker = 34,
+ IncorrectJpegMarker = 13,
+ IncorrectJsonMarker = 19,
+ IncorrectTitleMarker = 24,
+ JsonBufferTight = 37,
+ JsonMallocError = 21,
+ JsonReadError = 22,
+ NoError = 255,
+ NoFormatIdentifier = 1,
+ PhotoBufferTight = 36,
+ PhotoMallocError = 16,
+ PhotoReadError = 17,
+ TitleBufferTight = 38,
+ TitleMallocError = 26,
+ TitleReadError = 27,
+ UnicodeInitError = 5,
+ UnicodeHeaderError = 6,
+ Uninitialised = 0
+ }
+
+ public enum PhotoFormat : UInt32 {
+ GTA5 = 0x01000000U,
+ RDR2 = 0x04000000U
+ }
+}
diff --git a/src/dotnet/Syping.RagePhoto.Core.csproj b/src/dotnet/Syping.RagePhoto.Core.csproj
index 7d2e487..bea75a7 100644
--- a/src/dotnet/Syping.RagePhoto.Core.csproj
+++ b/src/dotnet/Syping.RagePhoto.Core.csproj
@@ -4,13 +4,14 @@
netstandard2.1
Syping.RagePhoto.Core
Syping.RagePhoto
- 0.6.1.1
- 0.6.1.1
- 0.6.1.1
+ 0.6.1.2
+ 0.6.1.2
+ 0.6.1.2
Syping
Copyright © 2025 Syping
Open Source RAGE Photo Parser for GTA V and RDR 2
BSD-2-Clause
+ https://github.com/Syping/libragephoto