Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions core/src/main/java/app/photofox/vipsffm/VImage.java
Original file line number Diff line number Diff line change
Expand Up @@ -10350,6 +10350,20 @@ public MemorySegment writeToMemory() throws VipsError {
return imageMemory.reinterpret(arena, VipsRaw::g_free).asSlice(0, sizeOfImage);
}

/// Renders this VImage into a single contiguous memory buffer and returns a new VImage backed by it,
/// mapping directly to the `vips_image_copy_memory` function. If this image is already a plain memory
/// image, libvips returns a new reference to it instead of copying.
///
/// Use this before the draw operations ([VImage#drawRect], [VImage#drawLine] and friends), which modify
/// pixels in place and need a private memory image. It is also useful for caching an intermediate image
/// that is reused by several later operations, at the cost of holding all of its pixels in memory.
///
/// To copy metadata without materialising pixels, use [VImage#copy] instead.
public VImage copyMemory() throws VipsError {
var imagePointer = VipsHelper.image_copy_memory(arena, this.address);
return new VImage(arena, imagePointer);
}

public static VImage newImage(Arena arena) throws VipsError {
var newImagePointer = VipsHelper.image_new(arena);
return new VImage(arena, newImagePointer);
Expand Down
16 changes: 16 additions & 0 deletions core/src/main/java/app/photofox/vipsffm/VipsHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -1142,6 +1142,22 @@ public static boolean image_hasalpha(MemorySegment image) throws VipsError {
return result == 1;
}

/// Binding for:
/// ```c
/// VipsImage *vips_image_copy_memory(VipsImage *image)
/// ```
public static MemorySegment image_copy_memory(Arena arena, MemorySegment image) throws VipsError {
if(!VipsValidation.isValidPointer(image)) {
VipsValidation.throwInvalidInputError("vips_image_copy_memory", "image");
}
var result = VipsRaw.vips_image_copy_memory(image);
if(!VipsValidation.isValidPointer(result)) {
VipsValidation.throwInvalidOutputError("vips_image_copy_memory", "result");
}
result = result.reinterpret(arena, VipsRaw::g_object_unref);
return result;
}

/// Binding for:
/// ```c
/// VipsImage **vips_value_get_array_image(const GValue *value, int *n)
Expand Down
58 changes: 58 additions & 0 deletions core/src/main/java/app/photofox/vipsffm/jextract/VipsRaw.java
Original file line number Diff line number Diff line change
Expand Up @@ -7493,6 +7493,64 @@ public static int vips_image_hasalpha(MemorySegment image) {
}
}

private static class vips_image_copy_memory {
public static final FunctionDescriptor DESC = FunctionDescriptor.of(
VipsRaw.C_POINTER,
VipsRaw.C_POINTER
);

public static final MemorySegment ADDR = VipsRaw.findOrThrow("vips_image_copy_memory");

public static final MethodHandle HANDLE = Linker.nativeLinker().downcallHandle(ADDR, DESC);
}

/**
* Function descriptor for:
* {@snippet lang=c :
* extern VipsImage *vips_image_copy_memory(VipsImage *image)
* }
*/
public static FunctionDescriptor vips_image_copy_memory$descriptor() {
return vips_image_copy_memory.DESC;
}

/**
* Downcall method handle for:
* {@snippet lang=c :
* extern VipsImage *vips_image_copy_memory(VipsImage *image)
* }
*/
public static MethodHandle vips_image_copy_memory$handle() {
return vips_image_copy_memory.HANDLE;
}

/**
* Address for:
* {@snippet lang=c :
* extern VipsImage *vips_image_copy_memory(VipsImage *image)
* }
*/
public static MemorySegment vips_image_copy_memory$address() {
return vips_image_copy_memory.ADDR;
}

/**
* {@snippet lang=c :
* extern VipsImage *vips_image_copy_memory(VipsImage *image)
* }
*/
public static MemorySegment vips_image_copy_memory(MemorySegment image) {
var mh$ = vips_image_copy_memory.HANDLE;
try {
if (TRACE_DOWNCALLS) {
traceDowncall("vips_image_copy_memory", image);
}
return (MemorySegment)mh$.invokeExact(image);
} catch (Throwable ex$) {
throw new AssertionError("should not reach here", ex$);
}
}

private static class vips_value_get_array_image {
public static final FunctionDescriptor DESC = FunctionDescriptor.of(
VipsRaw.C_POINTER,
Expand Down
1,900 changes: 964 additions & 936 deletions docs/app.photofox.vipsffm/app/photofox/vipsffm/VImage.html

Large diffs are not rendered by default.

772 changes: 400 additions & 372 deletions docs/app.photofox.vipsffm/app/photofox/vipsffm/VipsHelper.html

Large diffs are not rendered by default.

106 changes: 106 additions & 0 deletions docs/app.photofox.vipsffm/app/photofox/vipsffm/jextract/VipsRaw.html
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,10 @@
<li><a href="#vips_image_hasalpha$handle()" tabindex="0">vips_image_hasalpha$handle()</a></li>
<li><a href="#vips_image_hasalpha$address()" tabindex="0">vips_image_hasalpha$address()</a></li>
<li><a href="#vips_image_hasalpha(java.lang.foreign.MemorySegment)" tabindex="0">vips_image_hasalpha(MemorySegment)</a></li>
<li><a href="#vips_image_copy_memory$descriptor()" tabindex="0">vips_image_copy_memory$descriptor()</a></li>
<li><a href="#vips_image_copy_memory$handle()" tabindex="0">vips_image_copy_memory$handle()</a></li>
<li><a href="#vips_image_copy_memory$address()" tabindex="0">vips_image_copy_memory$address()</a></li>
<li><a href="#vips_image_copy_memory(java.lang.foreign.MemorySegment)" tabindex="0">vips_image_copy_memory(MemorySegment)</a></li>
<li><a href="#vips_value_get_array_image$descriptor()" tabindex="0">vips_value_get_array_image$descriptor()</a></li>
<li><a href="#vips_value_get_array_image$handle()" tabindex="0">vips_value_get_array_image$handle()</a></li>
<li><a href="#vips_value_get_array_image$address()" tabindex="0">vips_value_get_array_image$address()</a></li>
Expand Down Expand Up @@ -7705,6 +7709,49 @@ <h2>Method Summary</h2>
</div>
</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code>static <a href="https://docs.oracle.com/en/java/javase/23/docs/api/java.base/java/lang/foreign/MemorySegment.html" title="class or interface in java.lang.foreign" class="external-link">MemorySegment</a></code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code><a href="#vips_image_copy_memory(java.lang.foreign.MemorySegment)" class="member-name-link">vips_image_copy_memory</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/23/docs/api/java.base/java/lang/foreign/MemorySegment.html" title="class or interface in java.lang.foreign" class="external-link">MemorySegment</a>&nbsp;image)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4">
<div class="block">
<div class="snippet-container"><button class="copy snippet-copy" aria-label="Copy snippet" onclick="copySnippet(this)"><span data-copied="Copied!">Copy</span><img src="../../../../../resource-files/copy.svg" alt="Copy snippet"></button>
<pre class="snippet" id="snippet-vips_image_copy_memory(java.lang.foreign.MemorySegment)1"><code class="language-c">extern VipsImage *vips_image_copy_memory(VipsImage *image)
</code></pre>
</div>
</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code>static <a href="https://docs.oracle.com/en/java/javase/23/docs/api/java.base/java/lang/foreign/MemorySegment.html" title="class or interface in java.lang.foreign" class="external-link">MemorySegment</a></code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code><a href="#vips_image_copy_memory$address()" class="member-name-link">vips_image_copy_memory$address</a>()</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4">
<div class="block">Address for:

<div class="snippet-container"><button class="copy snippet-copy" aria-label="Copy snippet" onclick="copySnippet(this)"><span data-copied="Copied!">Copy</span><img src="../../../../../resource-files/copy.svg" alt="Copy snippet"></button>
<pre class="snippet" id="snippet-vips_image_copy_memory$address()1"><code class="language-c">extern VipsImage *vips_image_copy_memory(VipsImage *image)
</code></pre>
</div>
</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code>static <a href="https://docs.oracle.com/en/java/javase/23/docs/api/java.base/java/lang/foreign/FunctionDescriptor.html" title="class or interface in java.lang.foreign" class="external-link">FunctionDescriptor</a></code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code><a href="#vips_image_copy_memory$descriptor()" class="member-name-link">vips_image_copy_memory$descriptor</a>()</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4">
<div class="block">Function descriptor for:

<div class="snippet-container"><button class="copy snippet-copy" aria-label="Copy snippet" onclick="copySnippet(this)"><span data-copied="Copied!">Copy</span><img src="../../../../../resource-files/copy.svg" alt="Copy snippet"></button>
<pre class="snippet" id="snippet-vips_image_copy_memory$descriptor()1"><code class="language-c">extern VipsImage *vips_image_copy_memory(VipsImage *image)
</code></pre>
</div>
</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code>static <a href="https://docs.oracle.com/en/java/javase/23/docs/api/java.base/java/lang/invoke/MethodHandle.html" title="class or interface in java.lang.invoke" class="external-link">MethodHandle</a></code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code><a href="#vips_image_copy_memory$handle()" class="member-name-link">vips_image_copy_memory$handle</a>()</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4">
<div class="block">Downcall method handle for:

<div class="snippet-container"><button class="copy snippet-copy" aria-label="Copy snippet" onclick="copySnippet(this)"><span data-copied="Copied!">Copy</span><img src="../../../../../resource-files/copy.svg" alt="Copy snippet"></button>
<pre class="snippet" id="snippet-vips_image_copy_memory$handle()1"><code class="language-c">extern VipsImage *vips_image_copy_memory(VipsImage *image)
</code></pre>
</div>
</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code>static int</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code><a href="#VIPS_IMAGE_ERROR()" class="member-name-link">VIPS_IMAGE_ERROR</a>()</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4">
Expand Down Expand Up @@ -23407,6 +23454,65 @@ <h3>vips_image_hasalpha</h3>
</section>
</li>
<li>
<section class="detail" id="vips_image_copy_memory$descriptor()">
<h3>vips_image_copy_memory$descriptor</h3>
<div class="horizontal-scroll">
<div class="member-signature"><span class="modifiers">public static</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/23/docs/api/java.base/java/lang/foreign/FunctionDescriptor.html" title="class or interface in java.lang.foreign" class="external-link">FunctionDescriptor</a></span>&nbsp;<span class="element-name">vips_image_copy_memory$descriptor</span>()</div>
<div class="block">Function descriptor for:

<div class="snippet-container"><button class="copy snippet-copy" aria-label="Copy snippet" onclick="copySnippet(this)"><span data-copied="Copied!">Copy</span><img src="../../../../../resource-files/copy.svg" alt="Copy snippet"></button>
<pre class="snippet" id="snippet-vips_image_copy_memory$descriptor()2"><code class="language-c">extern VipsImage *vips_image_copy_memory(VipsImage *image)
</code></pre>
</div>
</div>
</div>
</section>
</li>
<li>
<section class="detail" id="vips_image_copy_memory$handle()">
<h3>vips_image_copy_memory$handle</h3>
<div class="horizontal-scroll">
<div class="member-signature"><span class="modifiers">public static</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/23/docs/api/java.base/java/lang/invoke/MethodHandle.html" title="class or interface in java.lang.invoke" class="external-link">MethodHandle</a></span>&nbsp;<span class="element-name">vips_image_copy_memory$handle</span>()</div>
<div class="block">Downcall method handle for:

<div class="snippet-container"><button class="copy snippet-copy" aria-label="Copy snippet" onclick="copySnippet(this)"><span data-copied="Copied!">Copy</span><img src="../../../../../resource-files/copy.svg" alt="Copy snippet"></button>
<pre class="snippet" id="snippet-vips_image_copy_memory$handle()2"><code class="language-c">extern VipsImage *vips_image_copy_memory(VipsImage *image)
</code></pre>
</div>
</div>
</div>
</section>
</li>
<li>
<section class="detail" id="vips_image_copy_memory$address()">
<h3>vips_image_copy_memory$address</h3>
<div class="horizontal-scroll">
<div class="member-signature"><span class="modifiers">public static</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/23/docs/api/java.base/java/lang/foreign/MemorySegment.html" title="class or interface in java.lang.foreign" class="external-link">MemorySegment</a></span>&nbsp;<span class="element-name">vips_image_copy_memory$address</span>()</div>
<div class="block">Address for:

<div class="snippet-container"><button class="copy snippet-copy" aria-label="Copy snippet" onclick="copySnippet(this)"><span data-copied="Copied!">Copy</span><img src="../../../../../resource-files/copy.svg" alt="Copy snippet"></button>
<pre class="snippet" id="snippet-vips_image_copy_memory$address()2"><code class="language-c">extern VipsImage *vips_image_copy_memory(VipsImage *image)
</code></pre>
</div>
</div>
</div>
</section>
</li>
<li>
<section class="detail" id="vips_image_copy_memory(java.lang.foreign.MemorySegment)">
<h3>vips_image_copy_memory</h3>
<div class="horizontal-scroll">
<div class="member-signature"><span class="modifiers">public static</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/23/docs/api/java.base/java/lang/foreign/MemorySegment.html" title="class or interface in java.lang.foreign" class="external-link">MemorySegment</a></span>&nbsp;<span class="element-name">vips_image_copy_memory</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/23/docs/api/java.base/java/lang/foreign/MemorySegment.html" title="class or interface in java.lang.foreign" class="external-link">MemorySegment</a>&nbsp;image)</span></div>
<div class="block">
<div class="snippet-container"><button class="copy snippet-copy" aria-label="Copy snippet" onclick="copySnippet(this)"><span data-copied="Copied!">Copy</span><img src="../../../../../resource-files/copy.svg" alt="Copy snippet"></button>
<pre class="snippet" id="snippet-vips_image_copy_memory(java.lang.foreign.MemorySegment)2"><code class="language-c">extern VipsImage *vips_image_copy_memory(VipsImage *image)
</code></pre>
</div>
</div>
</div>
</section>
</li>
<li>
<section class="detail" id="vips_value_get_array_image$descriptor()">
<h3>vips_value_get_array_image$descriptor</h3>
<div class="horizontal-scroll">
Expand Down
Loading
Loading