From 74b285736424c33b45976339f747e2de93648d0a Mon Sep 17 00:00:00 2001 From: "A. Molzer" <5550310+197g@users.noreply.github.com> Date: Thu, 8 Jan 2026 14:24:48 +0100 Subject: [PATCH] Construct ValueBuffer from TiffValue --- src/encoder/mod.rs | 2 +- src/tags.rs | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/encoder/mod.rs b/src/encoder/mod.rs index c5c8e72..e67d76b 100644 --- a/src/encoder/mod.rs +++ b/src/encoder/mod.rs @@ -294,7 +294,7 @@ impl<'a, W: 'a + Write + Seek, K: TiffKind> DirectoryEncoder<'a, W, K> { /// Write a tag-value pair with prepared byte data. /// /// Note that the library will _not_ attempt to verify that the data type or the count of the - /// opaque value is permissible for the given tag. The data will be associated with the tag + /// buffered value is permissible for the given tag. The data will be associated with the tag /// exactly as-is. /// /// An error is returned if the byte order of the presented value does not match the byte order diff --git a/src/tags.rs b/src/tags.rs index fe0c697..aa82e3e 100644 --- a/src/tags.rs +++ b/src/tags.rs @@ -1,4 +1,4 @@ -use crate::decoder::ifd; +use crate::{decoder::ifd, encoder::TiffValue}; macro_rules! tags { { @@ -362,6 +362,15 @@ impl ValueBuffer { } } + /// Create a value with native byte order from in-memory data. + pub fn from_value(value: &T) -> Self { + ValueBuffer { + bytes: value.data().into_owned(), + ty: ::FIELD_TYPE, + byte_order: ByteOrder::native(), + } + } + pub fn byte_order(&self) -> ByteOrder { self.byte_order }