Skip to content

Commit

Permalink
Fix P/Invoke
Browse files Browse the repository at this point in the history
  • Loading branch information
sungaila committed Sep 20, 2024
1 parent d24c3d9 commit 91312ad
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 31 deletions.
14 changes: 2 additions & 12 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,21 +128,11 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [windows-2019, windows-2022, ubuntu-20.04, ubuntu-22.04, ubuntu-24.04, macos-12, macos-13, macos-14]
os: [windows-2019, windows-2022, ubuntu-20.04, ubuntu-22.04, macos-12, macos-13, macos-14]
runs-on: ${{ matrix.os }}
if: success() && (github.event_name != 'workflow_dispatch' && true || inputs.run_tests) == true
steps:
- name: Setup Mono (macOS)
if: runner.os == 'macOS'
run: |
sudo chown -R $(whoami) $(brew --prefix)/*
brew install mono
- name: Setup Mono (Ubuntu)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y mono-devel
- name: Setup Mono (Windows)
- name: Setup Mono
if: runner.os == 'Windows'
run: choco install mono -y && Add-Content $env:GITHUB_PATH "C:\Program Files\Mono\bin"
- name: Setup .NET
Expand Down
23 changes: 4 additions & 19 deletions src/PDFtoImage/Internals/NativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,11 @@ public static IntPtr FPDFBitmap_CreateEx(int width, int height, FPDFBitmap forma
}
}

public static void FPDFBitmap_FillRect(IntPtr bitmapHandle, int left, int top, int width, int height, uint color)
public static bool FPDFBitmap_FillRect(IntPtr bitmapHandle, int left, int top, int width, int height, uint color)
{
lock (LockString)
{
Imports.FPDFBitmap_FillRect(bitmapHandle, left, top, width, height, color);
return Imports.FPDFBitmap_FillRect(bitmapHandle, left, top, width, height, color) != 0;
}
}

Expand All @@ -182,14 +182,6 @@ public static void FPDFBitmap_Destroy(IntPtr bitmapHandle)
}
}

public static uint FPDFDest_GetDestPageIndex(IntPtr document, IntPtr dest)
{
lock (LockString)
{
return Imports.FPDFDest_GetDestPageIndex(document, dest);
}
}

/// <summary>
/// Opens a document using a .NET Stream. Allows opening huge
/// PDFs without loading them into memory first.
Expand Down Expand Up @@ -354,16 +346,12 @@ private static partial class Imports

[LibraryImport("pdfium")]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial void FPDFBitmap_FillRect(IntPtr bitmapHandle, int left, int top, int width, int height, uint color);
public static partial int FPDFBitmap_FillRect(IntPtr bitmapHandle, int left, int top, int width, int height, uint color);

[LibraryImport("pdfium")]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial void FPDFBitmap_Destroy(IntPtr bitmapHandle);

[LibraryImport("pdfium")]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial uint FPDFDest_GetDestPageIndex(IntPtr document, IntPtr dest);

[LibraryImport("pdfium")]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial uint FPDF_GetLastError();
Expand Down Expand Up @@ -442,14 +430,11 @@ private static partial class Imports
public static extern IntPtr FPDFBitmap_CreateEx(int width, int height, int format, IntPtr first_scan, int stride);

[DllImport("pdfium", CallingConvention = CallingConvention.Cdecl)]
public static extern void FPDFBitmap_FillRect(IntPtr bitmapHandle, int left, int top, int width, int height, uint color);
public static extern int FPDFBitmap_FillRect(IntPtr bitmapHandle, int left, int top, int width, int height, uint color);

[DllImport("pdfium", CallingConvention = CallingConvention.Cdecl)]
public static extern void FPDFBitmap_Destroy(IntPtr bitmapHandle);

[DllImport("pdfium", CallingConvention = CallingConvention.Cdecl)]
public static extern uint FPDFDest_GetDestPageIndex(IntPtr document, IntPtr dest);

[DllImport("pdfium", CallingConvention = CallingConvention.Cdecl)]
public static extern uint FPDF_GetLastError();

Expand Down

0 comments on commit 91312ad

Please sign in to comment.