LEADTOOLS Support
Imaging
Imaging SDK Examples
HOW TO: Use LEADTOOLS To Write an image to a File Stream
#1
Posted
:
Tuesday, June 26, 2018 12:18:32 PM(UTC)
Groups: Registered, Tech Support, Administrators
Posts: 163
Was thanked: 9 time(s) in 9 post(s)
A standard .NET filestream can be opened using FileInfo.OpenWrite(). However, this produces a FileStream which is write-only.
Code:FileInfo f = new FileInfo(tifOutputPath);
using (FileStream fs = f.OpenWrite())
{
codecs.Save(img, fs, frm, bpp);
}
This is an issue when saving to specific formats (such as TIF), as it's necessary for the filter to read some information back regarding the file. Using a write-only stream doesn't permit this and will cause an exception to be generated. Therefore, use a read-write stream when saving to a FileStream:
Code:FileInfo f = new FileInfo(tifOutputPath);
using (FileStream fs = f.Open(FileMode.OpenOrCreate, FileAccess.ReadWrite))
{
codecs.Save(img, fs, frm, bpp);
}
Nick Crook
Developer Support Engineer
LEAD Technologies, Inc.
LEADTOOLS Support
Imaging
Imaging SDK Examples
HOW TO: Use LEADTOOLS To Write an image to a File Stream
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.