libragephoto: update .NET version to 0.6.1.2

- RagePhoto.cs: add missing [return: MarshalAs(UnmanagedType.Bool)]
- RagePhoto.cs: update filePath instances to path
- RagePhotoData.cs: update Strings to IntPtr (more safe to Marshal)
- RagePhotoTypes.cs: move DefaultSize, PhotoError and PhotoFormat to
here
This commit is contained in:
Syping 2025-10-08 09:19:25 +02:00
parent 59bd3c1249
commit a0ec84cbc8
4 changed files with 84 additions and 77 deletions

View file

@ -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()));
}

View file

@ -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;

View file

@ -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
}
}

View file

@ -4,13 +4,14 @@
<TargetFramework>netstandard2.1</TargetFramework>
<AssemblyName>Syping.RagePhoto.Core</AssemblyName>
<RootNamespace>Syping.RagePhoto</RootNamespace>
<Version>0.6.1.1</Version>
<AssemblyVersion>0.6.1.1</AssemblyVersion>
<FileVersion>0.6.1.1</FileVersion>
<Version>0.6.1.2</Version>
<AssemblyVersion>0.6.1.2</AssemblyVersion>
<FileVersion>0.6.1.2</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>
<RepositoryUrl>https://github.com/Syping/libragephoto</RepositoryUrl>
</PropertyGroup>
<ItemGroup>