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
This commit is contained in:
parent
3ea95bab44
commit
c8cd8112f0
6 changed files with 73 additions and 50 deletions
21
src/dotnet/README.md
Normal file
21
src/dotnet/README.md
Normal file
|
|
@ -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);
|
||||
}
|
||||
```
|
||||
|
|
@ -1,16 +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.7.1</Version>
|
||||
<AssemblyVersion>0.7.1</AssemblyVersion>
|
||||
<FileVersion>0.7.1</FileVersion>
|
||||
<Version>0.8.0</Version>
|
||||
<AssemblyVersion>0.8.0</AssemblyVersion>
|
||||
<FileVersion>0.8.0</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>
|
||||
<RepositoryUrl>https://github.com/Syping/libragephoto</RepositoryUrl>
|
||||
<Nullable>disable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
|
@ -20,16 +21,14 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<NativeDlls Include="runtimes\**\libragephoto.*" />
|
||||
<None Include="@(NativeDlls)" Pack="true" PackagePath="runtimes\%(RecursiveDir)%(Filename)%(Extension)">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="RagePhoto.Core.targets" Pack="true" PackagePath="build\net47\RagePhoto.Core.targets">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="RagePhoto.Core.targets" Pack="true" PackagePath="buildTransitive\net47\RagePhoto.Core.targets">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<SharedLibraries Include="runtimes\**\libragephoto.*" />
|
||||
<None Include="@(SharedLibraries)" Pack="true" PackagePath="runtimes\%(RecursiveDir)%(Filename)%(Extension)" />
|
||||
<None Include="net47\RagePhoto.Core.targets" Pack="true" PackagePath="build\net47\RagePhoto.Core.targets" />
|
||||
<None Include="net47\RagePhoto.Core.targets" Pack="true" PackagePath="buildTransitive\net47\RagePhoto.Core.targets" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="README.md" Pack="true" PackagePath="README.md" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,21 +1,28 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Condition="'$(OS)' == 'Windows_NT' AND '$(Platform)' == 'arm64'">
|
||||
|
||||
<!-- Windows arm64 -->
|
||||
<ItemGroup Condition="'$(Platform)' == 'arm64'">
|
||||
<Content Include="$(MSBuildThisFileDirectory)..\..\runtimes\win-arm64\native\libragephoto.dll">
|
||||
<TargetPath>libragephoto.dll</TargetPath>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<Pack>false</Pack>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(OS)' == 'Windows_NT' AND '$(Platform)' == 'x64'">
|
||||
|
||||
<!-- Windows x64 -->
|
||||
<ItemGroup Condition="'$(Platform)' == 'x64'">
|
||||
<Content Include="$(MSBuildThisFileDirectory)..\..\runtimes\win-x64\native\libragephoto.dll">
|
||||
<TargetPath>libragephoto.dll</TargetPath>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<Pack>false</Pack>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(OS)' == 'Windows_NT' AND '$(Platform)' == 'x86'">
|
||||
|
||||
<!-- Windows x86 -->
|
||||
<ItemGroup Condition="'$(Platform)' == 'x86'">
|
||||
<Content Include="$(MSBuildThisFileDirectory)..\..\runtimes\win-x86\native\libragephoto.dll">
|
||||
<TargetPath>libragephoto.dll</TargetPath>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<Pack>false</Pack>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Loading…
Add table
Add a link
Reference in a new issue