Skip to content

Commit 74b2857

Browse files
committed
Construct ValueBuffer from TiffValue
1 parent 1dab89f commit 74b2857

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/encoder/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ impl<'a, W: 'a + Write + Seek, K: TiffKind> DirectoryEncoder<'a, W, K> {
294294
/// Write a tag-value pair with prepared byte data.
295295
///
296296
/// Note that the library will _not_ attempt to verify that the data type or the count of the
297-
/// opaque value is permissible for the given tag. The data will be associated with the tag
297+
/// buffered value is permissible for the given tag. The data will be associated with the tag
298298
/// exactly as-is.
299299
///
300300
/// An error is returned if the byte order of the presented value does not match the byte order

src/tags.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::decoder::ifd;
1+
use crate::{decoder::ifd, encoder::TiffValue};
22

33
macro_rules! tags {
44
{
@@ -362,6 +362,15 @@ impl ValueBuffer {
362362
}
363363
}
364364

365+
/// Create a value with native byte order from in-memory data.
366+
pub fn from_value<T: TiffValue>(value: &T) -> Self {
367+
ValueBuffer {
368+
bytes: value.data().into_owned(),
369+
ty: <T as TiffValue>::FIELD_TYPE,
370+
byte_order: ByteOrder::native(),
371+
}
372+
}
373+
365374
pub fn byte_order(&self) -> ByteOrder {
366375
self.byte_order
367376
}

0 commit comments

Comments
 (0)