Construct ValueBuffer from TiffValue

This commit is contained in:
A. Molzer committed 2026-01-10 01:27:43 +01:00
1 parent 1dab89f10e
commit 74b2857364
2 files changed
+11 -2

No files matched your search

+1 -1
View File
@@ -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
+10 -1
View File
@@ -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<T: TiffValue>(value: &T) -> Self {
ValueBuffer {
bytes: value.data().into_owned(),
ty: <T as TiffValue>::FIELD_TYPE,
byte_order: ByteOrder::native(),
}
}
pub fn byte_order(&self) -> ByteOrder {
self.byte_order
}