Skip to main content
Version: 14.x (API 14) [Current]

Interface ITextureReadbackProvider

Service that grants you to read instances of Dalamud.Interface.Textures.TextureWraps.IDalamudTextureWrap.

Assembly: Dalamud.dll
Declaration
public interface ITextureReadbackProvider : IDalamudService

Methods

GetRawImageAsync(IDalamudTextureWrap, TextureModificationArgs, bool, CancellationToken)

Gets the raw data of a texture wrap.

Declaration
Task<(RawImageSpecification Specification, byte[] RawData)> GetRawImageAsync(IDalamudTextureWrap wrap, TextureModificationArgs args = default, bool leaveWrapOpen = false, CancellationToken cancellationToken = default)
Returns

System.Threading.Tasks.Task<System.ValueTuple<Dalamud.Interface.Textures.RawImageSpecification,System.Byte[]>>: The raw data and its specifications.

Parameters
TypeNameDescription
Dalamud.Interface.Textures.TextureWraps.IDalamudTextureWrapwrapThe source texture wrap.
Dalamud.Interface.Textures.TextureModificationArgsargsThe texture modification arguments.
System.BooleanleaveWrapOpenWhether to leave <code class="paramref">wrap</code> non-disposed when the returned
        `System.Threading.Tasks.Task`1` completes. |

| System.Threading.CancellationToken | cancellationToken | The cancellation token. |

Remarks

<p>The length of the returned RawData may not match Dalamud.Interface.Textures.RawImageSpecification.Height * Dalamud.Interface.Textures.RawImageSpecification.Pitch.</p> <p>Dalamud.Interface.Textures.RawImageSpecification.Pitch may not be the minimal value required to represent the texture bitmap data. For example, if a texture is 4x4 B8G8R8A8, the minimal pitch would be 32, but the function may return 64 instead.</p> <p>This function may throw an exception.</p>

GetSupportedImageEncoderInfos()

Gets the supported bitmap encoders.

Declaration
IEnumerable<IBitmapCodecInfo> GetSupportedImageEncoderInfos()
Returns

System.Collections.Generic.IEnumerable<Dalamud.Interface.Textures.IBitmapCodecInfo>: The supported bitmap encoders.

Remarks

The following functions support the files of the container types pointed by yielded values.

<ul> <li>Dalamud.Plugin.Services.ITextureReadbackProvider.SaveToStreamAsync(Dalamud.Interface.Textures.TextureWraps.IDalamudTextureWrap,System.Guid,System.IO.Stream,System.Collections.Generic.IReadOnlyDictionary&lt;System.String,System.Object&gt;,System.Boolean,System.Boolean,System.Threading.CancellationToken)</li> <li>Dalamud.Plugin.Services.ITextureReadbackProvider.SaveToFileAsync(Dalamud.Interface.Textures.TextureWraps.IDalamudTextureWrap,System.Guid,System.String,System.Collections.Generic.IReadOnlyDictionary&lt;System.String,System.Object&gt;,System.Boolean,System.Threading.CancellationToken)</li> </ul> <p>This function may throw an exception.</p>

SaveToStreamAsync(IDalamudTextureWrap, Guid, Stream, IReadOnlyDictionary<string, object>?, bool, bool, CancellationToken)

Saves a texture wrap to a stream in an image file format.

Declaration
Task SaveToStreamAsync(IDalamudTextureWrap wrap, Guid containerGuid, Stream stream, IReadOnlyDictionary<string, object>? props = null, bool leaveWrapOpen = false, bool leaveStreamOpen = false, CancellationToken cancellationToken = default)
Returns

System.Threading.Tasks.Task: A task representing the save process.

Parameters
TypeNameDescription
Dalamud.Interface.Textures.TextureWraps.IDalamudTextureWrapwrapThe texture wrap to save.
System.GuidcontainerGuidThe container GUID, obtained from Dalamud.Plugin.Services.ITextureReadbackProvider.GetSupportedImageEncoderInfos().
System.IO.StreamstreamThe stream to save to.
System.Collections.Generic.IReadOnlyDictionary<System.String,System.Object>propsProperties to pass to the encoder. See remarks for valid values.
System.BooleanleaveWrapOpenWhether to leave <code class="paramref">wrap</code> non-disposed when the returned
        `System.Threading.Tasks.Task`1` completes. |

| System.Boolean | leaveStreamOpen | Whether to leave <code class="paramref">stream</code> open when the returned System.Threading.Tasks.Task1completes. | |System.Threading.CancellationToken` | cancellationToken | The cancellation token. |

Remarks

<p><code class="paramref">wrap</code> must not be disposed until the task finishes.</p> <p>See the following webpages for the valid values for <code class="paramref">props</code> per <code class="paramref">containerGuid</code>.</p> <ul> <li><a href="https://learn.microsoft.com/en-us/windows/win32/wic/native-wic-codecs"> WIC Codecs from Microsoft</a></li> <li><a href="https://learn.microsoft.com/en-us/windows/win32/wic/-wic-creating-encoder#encoder-options"> Image Encoding Overview: Encoder options</a></li> </ul> <p>This function may throw an exception.</p>

SaveToFileAsync(IDalamudTextureWrap, Guid, string, IReadOnlyDictionary<string, object>?, bool, CancellationToken)

Saves a texture wrap to a file as an image file.

Declaration
Task SaveToFileAsync(IDalamudTextureWrap wrap, Guid containerGuid, string path, IReadOnlyDictionary<string, object>? props = null, bool leaveWrapOpen = false, CancellationToken cancellationToken = default)
Returns

System.Threading.Tasks.Task: A task representing the save process.

Parameters
TypeNameDescription
Dalamud.Interface.Textures.TextureWraps.IDalamudTextureWrapwrapThe texture wrap to save.
System.GuidcontainerGuidThe container GUID, obtained from Dalamud.Plugin.Services.ITextureReadbackProvider.GetSupportedImageEncoderInfos().
System.StringpathThe target file path. The target file will be overwritten if it exist.
System.Collections.Generic.IReadOnlyDictionary<System.String,System.Object>propsProperties to pass to the encoder. See remarks for valid values.
System.BooleanleaveWrapOpenWhether to leave <code class="paramref">wrap</code> non-disposed when the returned
        `System.Threading.Tasks.Task`1` completes. |

| System.Threading.CancellationToken | cancellationToken | The cancellation token. |

Remarks

<p><code class="paramref">wrap</code> must not be disposed until the task finishes.</p> <p>If the target file exists, it will be overwritten only if the save operation is successful.</p> <p>See the following webpages for the valid values for <code class="paramref">props</code> per <code class="paramref">containerGuid</code>.</p> <ul> <li><a href="https://learn.microsoft.com/en-us/windows/win32/wic/native-wic-codecs"> WIC Codecs from Microsoft</a></li> <li><a href="https://learn.microsoft.com/en-us/windows/win32/wic/-wic-creating-encoder#encoder-options"> Image Encoding Overview: Encoder options</a></li> </ul> <p>This function may throw an exception.</p>

CopyToClipboardAsync(IDalamudTextureWrap, string?, bool, CancellationToken)

Copies the texture to clipboard.

Declaration
Task CopyToClipboardAsync(IDalamudTextureWrap wrap, string? preferredFileNameWithoutExtension = null, bool leaveWrapOpen = false, CancellationToken cancellationToken = default)
Returns

System.Threading.Tasks.Task: A System.Threading.Tasks.Task representing the status of the operation.

Parameters
TypeNameDescription
Dalamud.Interface.Textures.TextureWraps.IDalamudTextureWrapwrapTexture wrap to copy.
System.StringpreferredFileNameWithoutExtensionPreferred file name.
System.BooleanleaveWrapOpenWhether to leave <code class="paramref">wrap</code> non-disposed when the returned
        `System.Threading.Tasks.Task`1` completes. |

| System.Threading.CancellationToken | cancellationToken | The cancellation token. |