I try to load bmp file into canvas so I do the following:
CanvasStrokeCollection = new StrokeCollection(new FileStream(fileNameFromOpenFileDialog, FileMode.Open, FileAccess.Read));
FileStream opens correctly but when passing it to StrokeCollection I receive:
InkSerializedFormat operation failed.\r\nParameter name: stream
Any idea what I do not right? I tried bmp with different quality with the same result.
seems like you are trying to load bmp
files which are not supported by the StrokeCollection constructor.
by the error InkSerializedFormat operation failed.
it is confirmed that the file you are trying to load is not supported.
StrokeCollection
may be initialized only with a Ink Serialized Format (ISF)
file stream, typically this is the file which you have saved previously using StrokeCollection.Save
method.
Bitmap (bmp)
is a raster format on other hand Ink Serialized Format (ISF)
is a vector format, so these are two different formats which are not compatible with each other.
sample from MSDN: StrokeCollection Constructor (Stream)
private void SaveStrokes_Click(object sender, RoutedEventArgs e)
{
FileStream fs = null;
try
{
fs = new FileStream(inkFileName, FileMode.Create);
inkCanvas1.Strokes.Save(fs);
}
finally
{
if (fs != null)
{
fs.Close();
}
}
}
...
private void LoadStrokes_Click(object sender, RoutedEventArgs e)
{
FileStream fs = null;
if (!File.Exists(inkFileName))
{
MessageBox.Show("The file you requested does not exist." +
" Save the StrokeCollection before loading it.");
return;
}
try
{
fs = new FileStream(inkFileName,
FileMode.Open, FileAccess.Read);
StrokeCollection strokes = new StrokeCollection(fs);
inkCanvas1.Strokes = strokes;
}
finally
{
if (fs != null)
{
fs.Close();
}
}
}