39 Commits

Author SHA1 Message Date
03ac61a4d2 Fix typo in publish.sh.
All checks were successful
Build / build (push) Successful in 1m18s
2024-06-14 18:51:16 +03:00
9dcd5e56fa Rename API key.
Some checks failed
Build / build (push) Failing after 1m17s
2024-06-14 18:48:41 +03:00
018f195000 Make ci run on push to tag.
Some checks failed
Build / build (push) Failing after 1m20s
2024-06-14 18:44:56 +03:00
13ea2941da fix typo in build script. 2024-06-14 18:43:14 +03:00
0c46adc68b Finish rebranding. 2024-06-14 18:40:36 +03:00
e7c90af3ed Fix build scripts. 2024-06-14 18:32:16 +03:00
112c1065b0 Add license. 2024-06-14 18:28:28 +03:00
ede16bc468 Remove all references to Quik. 2024-06-14 18:24:38 +03:00
6ba91c8808 Added icon.
All checks were successful
Build / build (push) Successful in 1m20s
2024-06-11 19:35:10 +03:00
ecab13f766 Added package icon. 2024-06-11 19:32:42 +03:00
50c2ec73e7 Added package icon.
Some checks failed
Build / build (push) Failing after 1m17s
2024-06-11 19:31:33 +03:00
cb896f9cf3 Added package icon.
Some checks failed
Build / build (push) Failing after 1m17s
2024-06-11 19:26:48 +03:00
8c3e723cac Merge remote-tracking branch 'origin/master'
All checks were successful
Build / build (push) Successful in 1m27s
2024-06-11 19:18:28 +03:00
7f8fad146a Add readme.md 2024-06-11 19:17:51 +03:00
themixedupstuff
23d2ce8087 Macos doesn't have dlls ya silly.
All checks were successful
Build / build (push) Successful in 1m34s
2024-06-07 19:06:52 +02:00
3ee0779d66 Roll over version number.
All checks were successful
Build / build (push) Successful in 1m37s
2024-06-01 14:23:32 +03:00
ec09deb438 Update stb. 2024-06-01 14:22:57 +03:00
07d788da25 Disable all instances of potential thread local storage. 2024-06-01 14:22:41 +03:00
bce883028f Added -static-libstdc++ compile flag.
All checks were successful
Build / build (push) Successful in 1m39s
2024-06-01 11:01:53 +03:00
0e1824bdb1 Add osx runtime specifiers
All checks were successful
Build / build (push) Successful in 1m16s
2024-04-06 16:17:05 +03:00
7cd55c8884 Merge branch 'master' into stable
All checks were successful
Build / build (push) Successful in 1m23s
2024-04-06 16:00:05 +03:00
b077e06765 [v1.1.0] Add OSX builds. 2024-04-06 15:58:05 +03:00
1d9f7d2ae6 Move tests to this repository. 2024-03-23 11:59:40 +03:00
bb5b3c638d [v1.0.0] Create Quik.StbImage nuget package.
Some checks failed
Build / build (push) Failing after 1m3s
Make more shell scripts.

Fix removed old function.

Add a workflow.

Add docker-compose.yaml version.

Update .gitea/workflows/build.yaml

Trying to see if this helps.

Add executable bit to shell scripts.

Where did my files go?

Fix executable bit of higher repository.

Change build scripts slightly to maybe fix CI?

Update .gitea/workflows/build.yaml

List all files in home directory of the runner.

Another silly push.

List stuff.

YEss another useless push.

Yet another attempt to fix CI builds.

This is getting out of hand.

Chnage build script.

Use unencrypted storage for the key because Nuget is nuget.
2024-03-23 11:41:10 +03:00
ab1cfe9243 Use unencrypted storage for the key because Nuget is nuget.
All checks were successful
Build / build (push) Successful in 1m2s
2024-03-23 11:36:16 +03:00
2883c7faf8 Chnage build script.
Some checks failed
Build / build (push) Failing after 1m4s
2024-03-23 10:59:23 +03:00
07f6da8ebe This is getting out of hand.
Some checks failed
Build / build (push) Failing after 43s
2024-03-21 18:39:44 +03:00
029375399f Yet another attempt to fix CI builds.
Some checks failed
Build / build (push) Failing after 44s
2024-03-21 18:38:27 +03:00
702083e961 YEss another useless push.
Some checks failed
Build / build (push) Failing after 51s
2024-03-21 18:24:22 +03:00
1ff1603d00 List stuff.
Some checks failed
Build / build (push) Failing after 44s
2024-03-21 18:17:50 +03:00
c41ba068a6 Another silly push.
Some checks failed
Build / build (push) Failing after 41s
2024-03-21 18:16:21 +03:00
33000e5b54 List all files in home directory of the runner.
Some checks failed
Build / build (push) Failing after 52s
2024-03-21 18:13:33 +03:00
4c87a7da1c Merge branch 'stable' of https://git.mixedup.dev/QUIK/Quik.StbImage into stable
Some checks failed
Build / build (push) Failing after 42s
2024-03-21 18:11:30 +03:00
e531ac6d15 Change build scripts slightly to maybe fix CI? 2024-03-21 18:10:55 +03:00
themixedupstuff
ed99bf210b Update .gitea/workflows/build.yaml
Some checks failed
Build / build (push) Failing after 44s
2024-03-19 21:19:55 +01:00
0d3b1760e3 Fix executable bit of higher repository.
Some checks failed
Build / build (push) Failing after 43s
2024-03-19 22:57:40 +03:00
1b0fc116f2 Merge branch 'stable' of https://git.mixedup.dev/QUIK/Quik.StbImage into stable
Some checks failed
Build / build (push) Failing after 41s
2024-03-19 22:50:05 +03:00
f60611e565 Add executable bit to shell scripts. 2024-03-19 22:49:57 +03:00
themixedupstuff
6e670cb57c Where did my files go?
Some checks failed
Build / build (push) Failing after 42s
2024-03-19 20:46:38 +01:00
29 changed files with 385 additions and 140 deletions

View File

@@ -1,24 +1,28 @@
name: Build name: Build
run-name: Building docker container. run-name: Building with docker container.
on: on:
workflow_dispatch: workflow_dispatch:
push: push:
branches: stable tags:
- '*'
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
env: container:
QUIK_API_KEY: "${{secrets.QUIK_API_KEY}}" image: git.mixedup.dev/refuel/docker-cross-compiler
env:
REFUEL_API_KEY: "${{secrets.REFUEL_API_KEY}}"
NUGET_USER_NAME: "${{vars.NUGET_USER_NAME}}"
NUGET_INDEX: "${{vars.NUGET_INDEX}}"
volumes:
- ${{ gitea.workspace }}:/home/refuel/src
steps: steps:
- name: Update Package Repository.
run: apt update -y
- name: Gather dependencies.
run: apt install -y docker.io docker-compose
- name: Check repository out. - name: Check repository out.
uses: actions/checkout@v3 uses: actions/checkout@v3
with:
submodules: recursive
- name: Run Build Script - name: Run Build Script
run: docker-compose run build run: "./build_native.sh"
working-directory: ${{ gitea.workspace }} - name: Publish Package
- name: Upload NuGet Package run: "./publish.sh"
run: "bash ${{ gitea.workspace }}/publish.sh"

2
.gitignore vendored
View File

@@ -2,3 +2,5 @@
**/obj **/obj
**/out **/out
**/runtimes **/runtimes
**/.vs*
**/.atom

6
.gitmodules vendored
View File

@@ -1,6 +1,6 @@
[submodule "stb"] [submodule "stb"]
path = stb path = stb
url = https://github.com/nothings/stb.git url = https://github.com/nothings/stb.git
[submodule "Quik.Common"] [submodule "docker-cross-compiler"]
path = Quik.Common path = docker-cross-compiler
url = https://git.mixedup.dev/QUIK/Quik.Common.git url = https://git.mixedup.dev/ReFuel/docker-cross-compiler

47
3RDPARTY.md Normal file
View File

@@ -0,0 +1,47 @@
This package uses 3rd-party software from the following vendors:
-----
* nothings/stb_image.h
* nothigns/stb_image_writer.h
https://raw.githubusercontent.com/nothings/stb/master/LICENSE
This software is available under 2 licenses -- choose whichever you prefer.
ALTERNATIVE A - MIT License
Copyright (c) 2017 Sean Barrett
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
ALTERNATIVE B - Public Domain (www.unlicense.org)
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
software, either in source code form or as a compiled binary, for any purpose,
commercial or non-commercial, and by any means.
In jurisdictions that recognize copyright laws, the author or authors of this
software dedicate any and all copyright interest in the software to the public
domain. We make this dedication for the benefit of the public at large and to
the detriment of our heirs and successors. We intend this dedication to be an
overt act of relinquishment in perpetuity of all present and future rights to
this software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-----

View File

@@ -1,10 +1,12 @@
cmake_minimum_required(VERSION 3.0) cmake_minimum_required(VERSION 3.0)
project(quik_stbi LANGUAGES C VERSION 1.0) project(rf_stbi LANGUAGES C VERSION 1.0)
add_compile_options(-static-libgcc) if (NOT ("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin"))
add_compile_options(-static-libgcc -static-libstdc++ -fno-exceptions)
endif()
add_library(stbi SHARED "quik_stbi.c") add_library(stbi SHARED "rf_stbi.c")
install( install(
TARGETS stbi TARGETS stbi
RUNTIME DESTINATION . RUNTIME DESTINATION .

19
LICENSE.md Normal file
View File

@@ -0,0 +1,19 @@
Copyright (c) 2024 ReFuel.StbImage - H. Utku Maden
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Also see 3RDPARTY.md

View File

@@ -1,6 +1,6 @@
using System; using System;
namespace Quik.Stb.Image namespace Quik.Stb
{ {
[AttributeUsage(System.AttributeTargets.All, Inherited = false, AllowMultiple = true)] [AttributeUsage(System.AttributeTargets.All, Inherited = false, AllowMultiple = true)]
internal sealed class NativeTypeNameAttribute : System.Attribute internal sealed class NativeTypeNameAttribute : System.Attribute

Submodule Quik.Common deleted from ebfc8a6946

9
README.md Normal file
View File

@@ -0,0 +1,9 @@
ReFuel.StbImage
=============
ReFuel.StbImage is a binary distribution of the popular stb_image.h single header
library. Existing packages were either bad source ports, had odd wrappers or
weren't up to date.
Originally intended for my own purposes, however feel free to view the code at
https://git.mixedup.dev/ReFuel/ReFuel.StbImage, and shoot me patch files through
email.

View File

@@ -5,18 +5,22 @@
<Nullable>disable</Nullable> <Nullable>disable</Nullable>
<LangVersion>7.3</LangVersion> <LangVersion>7.3</LangVersion>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks> <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<RuntimeIdentifiers>linux-arm;linux-arm64;linux-x64;win-x86;win-x64</RuntimeIdentifiers> <RuntimeIdentifiers>linux-arm;linux-arm64;linux-x64;win-x86;win-x64;osx-arm64;osx-x64</RuntimeIdentifiers>
<RootNamespace>ReFuel.Stb</RootNamespace>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<!-- Nuget Properties. --> <!-- Nuget Properties. -->
<GeneratePackageOnBuild>True</GeneratePackageOnBuild> <GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<PackageId>Quik.StbImage</PackageId> <PackageId>ReFuel.StbImage</PackageId>
<Version>1.0.0</Version> <Version>1.0.0</Version>
<Authors>STBI Authors, H. Utku Maden</Authors> <Authors>STBI Authors, H. Utku Maden</Authors>
<Description> <Description>
A C# wrapper for the ubiquitous Stb Image library. A C# wrapper for the ubiquitous stb_image.h and stb_image_write.h library.
</Description> </Description>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
<PackageIcon>images\icon.png</PackageIcon>
</PropertyGroup> </PropertyGroup>
<!-- <!--
@@ -26,6 +30,8 @@
that determines a lot of load paths for projects. that determines a lot of load paths for projects.
--> -->
<ItemGroup> <ItemGroup>
<Content Include="*.md" Pack="true" PackagePath="/"/>
<None Include="rf_stbimage.png" Pack="true" PackagePath="images\icon.png"/>
<Content Include="runtimes/linux-arm/native/*.so"> <Content Include="runtimes/linux-arm/native/*.so">
<PackagePath>runtimes/linux-arm/native/</PackagePath> <PackagePath>runtimes/linux-arm/native/</PackagePath>
<Pack>true</Pack> <Pack>true</Pack>
@@ -56,6 +62,16 @@
<Pack>true</Pack> <Pack>true</Pack>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="runtimes/osx-x64/native/*.dylib">
<PackagePath>runtimes/osx-x64/native/</PackagePath>
<Pack>true</Pack>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="runtimes/osx-arm64/native/*.dylib">
<PackagePath>runtimes/osx-arm64/native/</PackagePath>
<Pack>true</Pack>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@@ -1,25 +1,22 @@
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17 # Visual Studio Version 17
VisualStudioVersion = 17.5.002.0 VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Quik.StbImage", "Quik.StbImage.csproj", "{C808B4BC-C3AF-4682-8EDA-EAAC780800C3}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReFuel.StbImage", "ReFuel.StbImage.csproj", "{413ACBF4-3851-416F-B2A2-F7157EC306B2}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C808B4BC-C3AF-4682-8EDA-EAAC780800C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C808B4BC-C3AF-4682-8EDA-EAAC780800C3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C808B4BC-C3AF-4682-8EDA-EAAC780800C3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C808B4BC-C3AF-4682-8EDA-EAAC780800C3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
SolutionGuid = {B04E5FBA-41E6-4B0B-BC31-F996BE353F5A} {413ACBF4-3851-416F-B2A2-F7157EC306B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{413ACBF4-3851-416F-B2A2-F7157EC306B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{413ACBF4-3851-416F-B2A2-F7157EC306B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{413ACBF4-3851-416F-B2A2-F7157EC306B2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

View File

@@ -2,7 +2,7 @@ using System;
using System.IO; using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Quik.Stb namespace ReFuel.Stb
{ {
/// <summary> /// <summary>
/// A class that encompasses all features of stb_image.h in a safe way. /// A class that encompasses all features of stb_image.h in a safe way.
@@ -31,6 +31,9 @@ namespace Quik.Stb
/// Internal image format. /// Internal image format.
/// </summary> /// </summary>
public StbiImageFormat Format { get; } public StbiImageFormat Format { get; }
/// <summary>
/// True if the image is a floating point image.
/// </summary>
public bool IsFloat { get; } public bool IsFloat { get; }
private StbImage(IntPtr image, int x, int y, StbiImageFormat format, bool isFloat) private StbImage(IntPtr image, int x, int y, StbiImageFormat format, bool isFloat)
@@ -112,6 +115,42 @@ namespace Quik.Stb
} }
} }
/// <summary>
/// Try loading an image, without raising exceptions.
/// </summary>
/// <param name="image">The resulting image.</param>
/// <param name="span">Source memory span.</param>
/// <param name="format">The desired image format.</param>
/// <returns>True on success.</returns>
public static bool TryLoad<T>(out StbImage image, ReadOnlySpan<T> span, StbiImageFormat format = StbiImageFormat.Default, bool isFloat = false)
where T : unmanaged
{
IntPtr imagePtr = IntPtr.Zero;
int x, y, iFormat;
fixed (byte *ptr = MemoryMarshal.AsBytes(span))
{
if (isFloat)
{
imagePtr = (IntPtr)Stbi.loadf_from_memory(ptr, span.Length * sizeof(T), &x, &y, &iFormat, (int)format);
}
else
{
imagePtr = (IntPtr)Stbi.load_from_memory(ptr, span.Length * sizeof(T), &x, &y, &iFormat, (int)format);
}
if (imagePtr != IntPtr.Zero)
{
image = new StbImage(imagePtr, x, y, (StbiImageFormat)iFormat, isFloat);
return true;
}
else
{
image = null;
return false;
}
}
}
/// <summary> /// <summary>
/// Load an image. /// Load an image.
/// </summary> /// </summary>
@@ -129,7 +168,33 @@ namespace Quik.Stb
throw new Exception($"Failed to load image: {reason}"); throw new Exception($"Failed to load image: {reason}");
} }
public bool IsLoadable(Stream stream) /// <summary>
/// Load an image.
/// </summary>
/// <param name="span">The span of memory to load from.</param>
/// <param name="format">The desired image format.</param>
/// <returns>The image object.</returns>
public static StbImage Load<T>(ReadOnlySpan<T> span, StbiImageFormat format = StbiImageFormat.Default, bool isFloat = false)
where T : unmanaged
{
if (TryLoad(out StbImage image, span, format, isFloat))
{
return image;
}
string reason = Marshal.PtrToStringUTF8((IntPtr)Stbi.failure_reason());
throw new Exception($"Failed to load image: {reason}");
}
/// <summary>
/// Peek image info from a stream.
/// </summary>
/// <param name="stream">The stream to peek into.</param>
/// <param name="width">Width of the image.</param>
/// <param name="height">Height of the image.</param>
/// <param name="format">The image format.</param>
/// <returns>True if the stream contained an image.</returns>
public static bool PeekInfo(Stream stream, out int width, out int height, out StbiImageFormat format)
{ {
int x, y, iFormat; int x, y, iFormat;
StbiStreamWrapper wrapper = new StbiStreamWrapper(stream, true); StbiStreamWrapper wrapper = new StbiStreamWrapper(stream, true);
@@ -138,7 +203,32 @@ namespace Quik.Stb
stream.Position = 0; stream.Position = 0;
int result = Stbi.info_from_callbacks(&cb, null, &x, &y, &iFormat); int result = Stbi.info_from_callbacks(&cb, null, &x, &y, &iFormat);
width = x;
height = y;
format = (StbiImageFormat)iFormat;
return result != 0; return result != 0;
} }
/// <summary>
/// Peek image info from a span.
/// </summary>
/// <param name="span">The span to peek into.</param>
/// <param name="width">Width of the image.</param>
/// <param name="height">Height of the image.</param>
/// <param name="format">The image format.</param>
/// <returns>True if the stream contained an image.</returns>
public static bool PeekInfo<T>(ReadOnlySpan<T> span, out int width, out int height, out StbiImageFormat format) where T : unmanaged
{
fixed (byte* ptr = MemoryMarshal.AsBytes(span))
{
int x, y, iFormat;
int result = Stbi.info_from_memory(ptr, span.Length * sizeof(T), &x, &y, &iFormat);
width = x;
height = y;
format = (StbiImageFormat)iFormat;
return result != 0;
}
}
} }
} }

View File

@@ -4,7 +4,7 @@ using System.Diagnostics;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Reflection; using System.Reflection;
namespace Quik.Stb namespace ReFuel.Stb
{ {
public unsafe static partial class Stbi public unsafe static partial class Stbi
{ {
@@ -19,7 +19,8 @@ namespace Quik.Stb
"runtimes/linux-arm/native/libstbi.so", "runtimes/linux-arm/native/libstbi.so",
"runtimes/linux-arm64/native/libstbi.so", "runtimes/linux-arm64/native/libstbi.so",
"runtimes/linux-x64/native/libstbi.so", "runtimes/linux-x64/native/libstbi.so",
"runtimes/native/libstbi.dylib", "runtimes/osx-arm64/libstbi.dylib",
"runtimes/osx-x64/libstbi.dylib",
"libstbi.dll", "libstbi.dll",
"libstbi.so", "libstbi.so",
"libstbi.dylib", "libstbi.dylib",
@@ -28,8 +29,6 @@ namespace Quik.Stb
static Stbi() static Stbi()
{ {
NativeLibrary.SetDllImportResolver(Assembly.GetExecutingAssembly(), Resolver); NativeLibrary.SetDllImportResolver(Assembly.GetExecutingAssembly(), Resolver);
// quik_stbi_failed_assert_store(Marshal.GetFunctionPointerForDelegate<FailedAssertProc>(FailedAssert));
} }
private static IntPtr Resolver(string libraryName, Assembly assembly, DllImportSearchPath? searchPath) private static IntPtr Resolver(string libraryName, Assembly assembly, DllImportSearchPath? searchPath)
@@ -47,19 +46,5 @@ namespace Quik.Stb
return NativeLibrary.Load(libraryName); return NativeLibrary.Load(libraryName);
} }
private static void FailedAssert(byte *expression, byte *file, int line, byte *function)
{
string expr = expression == null ? string.Empty : Marshal.PtrToStringUTF8((IntPtr)expression);
string f = file == null ? string.Empty : Marshal.PtrToStringUTF8((IntPtr)file);
string func = function == null ? string.Empty : Marshal.PtrToStringUTF8((IntPtr)function);
Exception ex = new Exception("Assert failed in native stbi code.");
ex.Data.Add("Expression", expr);
ex.Data.Add("File", f);
ex.Data.Add("Line", line);
ex.Data.Add("Function", func);
throw ex;
}
} }
} }

97
Stbi.cs
View File

@@ -1,10 +1,8 @@
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Quik.Stb.Image;
namespace Quik.Stb namespace ReFuel.Stb
{ {
[NativeTypeName("unsigned int")]
public enum StbiEnum : uint public enum StbiEnum : uint
{ {
STBI_default = 0, STBI_default = 0,
@@ -16,65 +14,62 @@ namespace Quik.Stb
public partial struct stbi_io_callbacks public partial struct stbi_io_callbacks
{ {
[NativeTypeName("int (*)(void *, char *, int)")]
public IntPtr read; public IntPtr read;
[NativeTypeName("void (*)(void *, int)")]
public IntPtr skip; public IntPtr skip;
[NativeTypeName("int (*)(void *)")]
public IntPtr eof; public IntPtr eof;
} }
public static unsafe partial class Stbi public static unsafe partial class Stbi
{ {
[DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_load_from_memory", ExactSpelling = true)] [DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_load_from_memory", ExactSpelling = true)]
[return: NativeTypeName("stbi_uc *")]
public static extern byte* load_from_memory([NativeTypeName("const stbi_uc *")] byte* buffer, int len, int* x, int* y, int* channels_in_file, int desired_channels); public static extern byte* load_from_memory(byte* buffer, int len, int* x, int* y, int* channels_in_file, int desired_channels);
[DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_load_from_callbacks", ExactSpelling = true)] [DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_load_from_callbacks", ExactSpelling = true)]
[return: NativeTypeName("stbi_uc *")]
public static extern byte* load_from_callbacks([NativeTypeName("const stbi_io_callbacks *")] stbi_io_callbacks* clbk, void* user, int* x, int* y, int* channels_in_file, int desired_channels); public static extern byte* load_from_callbacks(stbi_io_callbacks* clbk, void* user, int* x, int* y, int* channels_in_file, int desired_channels);
[DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_load", ExactSpelling = true)] [DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_load", ExactSpelling = true)]
[return: NativeTypeName("stbi_uc *")]
public static extern byte* load([NativeTypeName("const char *")] sbyte* filename, int* x, int* y, int* channels_in_file, int desired_channels); public static extern byte* load(sbyte* filename, int* x, int* y, int* channels_in_file, int desired_channels);
[DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_load_from_file", ExactSpelling = true)] [DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_load_from_file", ExactSpelling = true)]
[return: NativeTypeName("stbi_uc *")]
public static extern byte* load_from_file([NativeTypeName("FILE *")] void* f, int* x, int* y, int* channels_in_file, int desired_channels); public static extern byte* load_from_file(void* f, int* x, int* y, int* channels_in_file, int desired_channels);
[DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_load_gif_from_memory", ExactSpelling = true)] [DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_load_gif_from_memory", ExactSpelling = true)]
[return: NativeTypeName("stbi_uc *")]
public static extern byte* load_gif_from_memory([NativeTypeName("const stbi_uc *")] byte* buffer, int len, int** delays, int* x, int* y, int* z, int* comp, int req_comp); public static extern byte* load_gif_from_memory(byte* buffer, int len, int** delays, int* x, int* y, int* z, int* comp, int req_comp);
[DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_load_16_from_memory", ExactSpelling = true)] [DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_load_16_from_memory", ExactSpelling = true)]
[return: NativeTypeName("stbi_us *")]
public static extern ushort* load_16_from_memory([NativeTypeName("const stbi_uc *")] byte* buffer, int len, int* x, int* y, int* channels_in_file, int desired_channels); public static extern ushort* load_16_from_memory(byte* buffer, int len, int* x, int* y, int* channels_in_file, int desired_channels);
[DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_load_16_from_callbacks", ExactSpelling = true)] [DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_load_16_from_callbacks", ExactSpelling = true)]
[return: NativeTypeName("stbi_us *")]
public static extern ushort* load_16_from_callbacks([NativeTypeName("const stbi_io_callbacks *")] stbi_io_callbacks* clbk, void* user, int* x, int* y, int* channels_in_file, int desired_channels); public static extern ushort* load_16_from_callbacks(stbi_io_callbacks* clbk, void* user, int* x, int* y, int* channels_in_file, int desired_channels);
[DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_load_16", ExactSpelling = true)] [DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_load_16", ExactSpelling = true)]
[return: NativeTypeName("stbi_us *")]
public static extern ushort* load_16([NativeTypeName("const char *")] sbyte* filename, int* x, int* y, int* channels_in_file, int desired_channels); public static extern ushort* load_16(sbyte* filename, int* x, int* y, int* channels_in_file, int desired_channels);
[DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_load_from_file_16", ExactSpelling = true)] [DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_load_from_file_16", ExactSpelling = true)]
[return: NativeTypeName("stbi_us *")]
public static extern ushort* load_from_file_16([NativeTypeName("FILE *")] void* f, int* x, int* y, int* channels_in_file, int desired_channels); public static extern ushort* load_from_file_16(void* f, int* x, int* y, int* channels_in_file, int desired_channels);
[DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_loadf_from_memory", ExactSpelling = true)] [DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_loadf_from_memory", ExactSpelling = true)]
public static extern float* loadf_from_memory([NativeTypeName("const stbi_uc *")] byte* buffer, int len, int* x, int* y, int* channels_in_file, int desired_channels); public static extern float* loadf_from_memory(byte* buffer, int len, int* x, int* y, int* channels_in_file, int desired_channels);
[DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_loadf_from_callbacks", ExactSpelling = true)] [DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_loadf_from_callbacks", ExactSpelling = true)]
public static extern float* loadf_from_callbacks([NativeTypeName("const stbi_io_callbacks *")] stbi_io_callbacks* clbk, void* user, int* x, int* y, int* channels_in_file, int desired_channels); public static extern float* loadf_from_callbacks(stbi_io_callbacks* clbk, void* user, int* x, int* y, int* channels_in_file, int desired_channels);
[DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_loadf", ExactSpelling = true)] [DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_loadf", ExactSpelling = true)]
public static extern float* loadf([NativeTypeName("const char *")] sbyte* filename, int* x, int* y, int* channels_in_file, int desired_channels); public static extern float* loadf(sbyte* filename, int* x, int* y, int* channels_in_file, int desired_channels);
[DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_loadf_from_file", ExactSpelling = true)] [DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_loadf_from_file", ExactSpelling = true)]
public static extern float* loadf_from_file([NativeTypeName("FILE *")] void* f, int* x, int* y, int* channels_in_file, int desired_channels); public static extern float* loadf_from_file(void* f, int* x, int* y, int* channels_in_file, int desired_channels);
[DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_hdr_to_ldr_gamma", ExactSpelling = true)] [DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_hdr_to_ldr_gamma", ExactSpelling = true)]
public static extern void hdr_to_ldr_gamma(float gamma); public static extern void hdr_to_ldr_gamma(float gamma);
@@ -89,47 +84,47 @@ namespace Quik.Stb
public static extern void ldr_to_hdr_scale(float scale); public static extern void ldr_to_hdr_scale(float scale);
[DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_is_hdr_from_callbacks", ExactSpelling = true)] [DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_is_hdr_from_callbacks", ExactSpelling = true)]
public static extern int is_hdr_from_callbacks([NativeTypeName("const stbi_io_callbacks *")] stbi_io_callbacks* clbk, void* user); public static extern int is_hdr_from_callbacks(stbi_io_callbacks* clbk, void* user);
[DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_is_hdr_from_memory", ExactSpelling = true)] [DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_is_hdr_from_memory", ExactSpelling = true)]
public static extern int is_hdr_from_memory([NativeTypeName("const stbi_uc *")] byte* buffer, int len); public static extern int is_hdr_from_memory(byte* buffer, int len);
[DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_is_hdr", ExactSpelling = true)] [DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_is_hdr", ExactSpelling = true)]
public static extern int is_hdr([NativeTypeName("const char *")] sbyte* filename); public static extern int is_hdr(sbyte* filename);
[DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_is_hdr_from_file", ExactSpelling = true)] [DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_is_hdr_from_file", ExactSpelling = true)]
public static extern int is_hdr_from_file([NativeTypeName("FILE *")] void* f); public static extern int is_hdr_from_file(void* f);
[DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_failure_reason", ExactSpelling = true)] [DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_failure_reason", ExactSpelling = true)]
[return: NativeTypeName("const char *")]
public static extern sbyte* failure_reason(); public static extern sbyte* failure_reason();
[DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_image_free", ExactSpelling = true)] [DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_image_free", ExactSpelling = true)]
public static extern void image_free(void* retval_from_stbi_load); public static extern void image_free(void* retval_from_stbi_load);
[DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_info_from_memory", ExactSpelling = true)] [DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_info_from_memory", ExactSpelling = true)]
public static extern int info_from_memory([NativeTypeName("const stbi_uc *")] byte* buffer, int len, int* x, int* y, int* comp); public static extern int info_from_memory(byte* buffer, int len, int* x, int* y, int* comp);
[DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_info_from_callbacks", ExactSpelling = true)] [DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_info_from_callbacks", ExactSpelling = true)]
public static extern int info_from_callbacks([NativeTypeName("const stbi_io_callbacks *")] stbi_io_callbacks* clbk, void* user, int* x, int* y, int* comp); public static extern int info_from_callbacks(stbi_io_callbacks* clbk, void* user, int* x, int* y, int* comp);
[DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_is_16_bit_from_memory", ExactSpelling = true)] [DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_is_16_bit_from_memory", ExactSpelling = true)]
public static extern int is_16_bit_from_memory([NativeTypeName("const stbi_uc *")] byte* buffer, int len); public static extern int is_16_bit_from_memory(byte* buffer, int len);
[DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_is_16_bit_from_callbacks", ExactSpelling = true)] [DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_is_16_bit_from_callbacks", ExactSpelling = true)]
public static extern int is_16_bit_from_callbacks([NativeTypeName("const stbi_io_callbacks *")] stbi_io_callbacks* clbk, void* user); public static extern int is_16_bit_from_callbacks(stbi_io_callbacks* clbk, void* user);
[DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_info", ExactSpelling = true)] [DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_info", ExactSpelling = true)]
public static extern int info([NativeTypeName("const char *")] sbyte* filename, int* x, int* y, int* comp); public static extern int info(sbyte* filename, int* x, int* y, int* comp);
[DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_info_from_file", ExactSpelling = true)] [DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_info_from_file", ExactSpelling = true)]
public static extern int info_from_file([NativeTypeName("FILE *")] void* f, int* x, int* y, int* comp); public static extern int info_from_file(void* f, int* x, int* y, int* comp);
[DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_is_16_bit", ExactSpelling = true)] [DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_is_16_bit", ExactSpelling = true)]
public static extern int is_16_bit([NativeTypeName("const char *")] sbyte* filename); public static extern int is_16_bit(sbyte* filename);
[DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_is_16_bit_from_file", ExactSpelling = true)] [DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_is_16_bit_from_file", ExactSpelling = true)]
public static extern int is_16_bit_from_file([NativeTypeName("FILE *")] void* f); public static extern int is_16_bit_from_file(void* f);
[DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_set_unpremultiply_on_load", ExactSpelling = true)] [DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_set_unpremultiply_on_load", ExactSpelling = true)]
public static extern void set_unpremultiply_on_load(int flag_true_if_should_unpremultiply); public static extern void set_unpremultiply_on_load(int flag_true_if_should_unpremultiply);
@@ -150,25 +145,25 @@ namespace Quik.Stb
public static extern void set_flip_vertically_on_load_thread(int flag_true_if_should_flip); public static extern void set_flip_vertically_on_load_thread(int flag_true_if_should_flip);
[DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_zlib_decode_malloc_guesssize", ExactSpelling = true)] [DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_zlib_decode_malloc_guesssize", ExactSpelling = true)]
[return: NativeTypeName("char *")]
public static extern sbyte* zlib_decode_malloc_guesssize([NativeTypeName("const char *")] sbyte* buffer, int len, int initial_size, int* outlen); public static extern sbyte* zlib_decode_malloc_guesssize(sbyte* buffer, int len, int initial_size, int* outlen);
[DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_zlib_decode_malloc_guesssize_headerflag", ExactSpelling = true)] [DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_zlib_decode_malloc_guesssize_headerflag", ExactSpelling = true)]
[return: NativeTypeName("char *")]
public static extern sbyte* zlib_decode_malloc_guesssize_headerflag([NativeTypeName("const char *")] sbyte* buffer, int len, int initial_size, int* outlen, int parse_header); public static extern sbyte* zlib_decode_malloc_guesssize_headerflag(sbyte* buffer, int len, int initial_size, int* outlen, int parse_header);
[DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_zlib_decode_malloc", ExactSpelling = true)] [DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_zlib_decode_malloc", ExactSpelling = true)]
[return: NativeTypeName("char *")]
public static extern sbyte* zlib_decode_malloc([NativeTypeName("const char *")] sbyte* buffer, int len, int* outlen); public static extern sbyte* zlib_decode_malloc(sbyte* buffer, int len, int* outlen);
[DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_zlib_decode_buffer", ExactSpelling = true)] [DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_zlib_decode_buffer", ExactSpelling = true)]
public static extern int zlib_decode_buffer([NativeTypeName("char *")] sbyte* obuffer, int olen, [NativeTypeName("const char *")] sbyte* ibuffer, int ilen); public static extern int zlib_decode_buffer(sbyte* ibuffer, int ilen);
[DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_zlib_decode_noheader_malloc", ExactSpelling = true)] [DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_zlib_decode_noheader_malloc", ExactSpelling = true)]
[return: NativeTypeName("char *")]
public static extern sbyte* zlib_decode_noheader_malloc([NativeTypeName("const char *")] sbyte* buffer, int len, int* outlen); public static extern sbyte* zlib_decode_noheader_malloc(sbyte* buffer, int len, int* outlen);
[DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_zlib_decode_noheader_buffer", ExactSpelling = true)] [DllImport("stbi", CallingConvention = CallingConvention.Cdecl, EntryPoint = "stbi_zlib_decode_noheader_buffer", ExactSpelling = true)]
public static extern int zlib_decode_noheader_buffer([NativeTypeName("char *")] sbyte* obuffer, int olen, [NativeTypeName("const char *")] sbyte* ibuffer, int ilen); public static extern int zlib_decode_noheader_buffer(sbyte* ibuffer, int ilen);
} }
} }

View File

@@ -1,4 +1,4 @@
namespace Quik.Stb namespace ReFuel.Stb
{ {
public enum StbiImageFormat public enum StbiImageFormat
{ {

View File

@@ -2,17 +2,21 @@ using System;
using System.IO; using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Quik.Stb namespace ReFuel.Stb
{ {
public unsafe delegate int StbiReadProc(void *userdata, byte* buffer, int count);
public unsafe delegate void StbiSkipProc(void *userdata, int count);
public unsafe delegate int StbiEofProc(void *userdata);
public unsafe class StbiStreamWrapper : IDisposable public unsafe class StbiStreamWrapper : IDisposable
{ {
private Stream _stream; private Stream _stream;
private bool _keepOpen; private bool _keepOpen;
private bool _isDisposed; private bool _isDisposed;
private delegate int ReadProc(void *userdata, byte* buffer, int count); private StbiReadProc _readCb;
private delegate void SkipProc(void *userdata, int count); private StbiSkipProc _skipCb;
private delegate int Eof(void *userdata); private StbiEofProc _eofCb;
public StbiStreamWrapper(Stream stream, bool keepOpen = false) public StbiStreamWrapper(Stream stream, bool keepOpen = false)
{ {
@@ -20,14 +24,18 @@ namespace Quik.Stb
_stream = stream; _stream = stream;
_keepOpen = keepOpen; _keepOpen = keepOpen;
_readCb = ReadCb;
_skipCb = SkipCb;
_eofCb = EofCb;
} }
public void CreateCallbacks(out stbi_io_callbacks cb) public void CreateCallbacks(out stbi_io_callbacks cb)
{ {
cb = default; cb = default;
cb.read = Marshal.GetFunctionPointerForDelegate<ReadProc>(ReadCb); cb.read = Marshal.GetFunctionPointerForDelegate<StbiReadProc>(_readCb);
cb.skip = Marshal.GetFunctionPointerForDelegate<SkipProc>(SkipCb); cb.skip = Marshal.GetFunctionPointerForDelegate<StbiSkipProc>(_skipCb);
cb.eof = Marshal.GetFunctionPointerForDelegate<Eof>(EofCb); cb.eof = Marshal.GetFunctionPointerForDelegate<StbiEofProc>(_eofCb);
} }
private int ReadCb(void *userdata, byte* buffer, int count) private int ReadCb(void *userdata, byte* buffer, int count)

11
build_ci_cd.sh Normal file
View File

@@ -0,0 +1,11 @@
#!/bin/bash
cd $(dirname "$0")
if [ -z "$QUIK_API_KEY" ]
then
echo "Please define QUIK_API_KEY"
exit 1
fi
pwd
docker-compose run build && docker-compose run publish

2
build_native.sh Normal file → Executable file
View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/bin/bash
cd $(dirname "$0") cd $(dirname "$0")
Quik.Common/sh/quik_build_native.sh . ./docker-cross-compiler/sh/build_native.sh .
dotnet build dotnet build

View File

@@ -2,7 +2,15 @@ version: "2"
services: services:
build: build:
image: git.mixedup.dev/quik/docker-cross-compiler image: git.mixedup.dev/refuel/docker-cross-compiler
command: "/home/quik/src/build_native.sh" command: "/home/refuel/src/build_native.sh"
volumes: volumes:
- .:/home/quik/src - .:/home/refuel/src
publish:
image: git.mixedup.dev/refuel/docker-cross-compiler
command: "/home/refuel/src/publish.sh"
environment:
QUIK_API_KEY: ${QUIK_API_KEY}
volumes:
- .:/home/refuel/src

1
docker-cross-compiler Submodule

Submodule docker-cross-compiler added at caafc898f3

24
publish.sh Normal file → Executable file
View File

@@ -1,11 +1,27 @@
#!/bin/bash #!/bin/bash
cd $(dirname "$0") cd $(dirname "$0")
if [ -z "$QUIK_API_KEY" ]
if [ -z "$REFUEL_API_KEY" ]
then then
echo "Please define QUIK_API_KEY" echo "Please define REFUEL_API_KEY"
exit 1 exit 1
fi fi
dotnet nuget add source -n QUIK -u themixedupstuff -p "$QUIK_API_KEY" https://git.mixedup.dev/api/packages/QUIK/nuget/index.json if [ -z "$NUGET_USER_NAME" ]
dotnet nuget push -s QUIK then
echo "Please define NUGET_USER_NAME"
exit 1
fi
if [ -z "$NUGET_INDEX" ]
then
echo "Please define NUGET_INDEX"
exit 1
fi
dotnet nuget add source \
-n ReFuel -u "$NUGET_USER_NAME" -p "$REFUEL_API_KEY" \
--store-password-in-clear-text \
"$NUGET_INDEX"
dotnet nuget push -s ReFuel bin/*/*.nupkg

View File

@@ -1,4 +0,0 @@
#include "quik_stbi.h"
#define STB_IMAGE_IMPLEMENTATION 1
#include "stb/stb_image.h"

View File

@@ -1,10 +0,0 @@
#ifndef _QUIK_STBI_H_
#define _QUIK_STBI_H_
#include "Quik.Common/include/quik_common.h"
#define STBIDEF QEXTERN
#include "stb/stb_image.h"
#endif

7
rf_stbi.c Normal file
View File

@@ -0,0 +1,7 @@
#include "rf_stbi.h"
#define STB_IMAGE_IMPLEMENTATION 1
#include "stb/stb_image.h"
#define STB_IMAGE_WRITE_IMPLEMENTATION 1
#include "stb/stb_image_write.h"

13
rf_stbi.h Normal file
View File

@@ -0,0 +1,13 @@
#ifndef _REFUEL_STBI_H_
#define _REFUEL_STBI_H_
#include "docker-cross-compiler/include/rf_common.h"
#define STBIDEF RFEXTERN
#define STBI_NO_THREAD_LOCALS 1
#include "stb/stb_image.h"
#define STBI_WRITE_NO_STDIO 1
#include "stb/stb_image_write.h"
#endif

BIN
rf_stbimage.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

2
stb

Submodule stb updated: ae721c50ea...013ac3bedd

View File

@@ -10,18 +10,18 @@
generate-setslastsystemerror-attribute generate-setslastsystemerror-attribute
unix-types unix-types
--include-directory --include-directory
../lib stb
--include-directory --include-directory
../Quik.StbImage .
--include-directory --include-directory
/usr/lib/llvm-14/lib/clang/14.0.6/include /usr/lib/llvm-14/lib/clang/14.0.6/include
--file --file
../Quik.StbImage.redist/quik_stbi.h rf_stbi.h
../lib/stb/stb_image.h stb/stb_image.h
--methodClassName --methodClassName
Stbi Stbi
--namespace --namespace
Quik.Stb ReFuel.Stb
--output --output
Stbi.cs Stbi.cs
--prefixStrip --prefixStrip

30
stb_image_write.rsp Normal file
View File

@@ -0,0 +1,30 @@
-x
c
-l
stbi
--config
compatible-codegen
single-file
exclude-fnptr-codegen
generate-aggressive-inlining
generate-setslastsystemerror-attribute
unix-types
--include-directory
stb
--include-directory
.
--include-directory
/usr/lib/llvm-14/lib/clang/14.0.6/include
--file
rf_stbi.h
stb/stb_image_write.h
--methodClassName
StbiWrite
--namespace
ReFuel.Stb
--output
StbiWrite.cs
--prefixStrip
stbi_write_
--with-type
FILE=void