Hello,
Welcome to Microsoft Q&A.
The following code is based on the code in Scenario3 of the linked sample:
Put an Image
control into the same container as InkCanvas
in Scenario3.xaml
. Note to add the Image
control in the front of InkCanvas
control.
<Grid x:Name="outputGrid" Background="{ThemeResource SystemControlBackgroundChromeWhiteBrush}">
<!-- Inking area -->
<Image x:Name="inkImage" Stretch="None"/>
<InkCanvas x:Name="inkCanvas">
</InkCanvas>
</Grid>
In Scenario3.xaml.cpp
file, find the OnLoadAsync
method. Comment or delete the original return
statement and add a new one:
void Scenario3::OnLoadAsync(Object^ sender, RoutedEventArgs^ e)
{
auto openPicker = ref new FileOpenPicker();
openPicker->SuggestedStartLocation = PickerLocationId::PicturesLibrary;
openPicker->FileTypeFilter->Append(".gif");
openPicker->FileTypeFilter->Append(".isf");
create_task(openPicker->PickSingleFileAsync()).then([this](StorageFile^ file)
{
if (file != nullptr)
{
return create_task(file->OpenAsync(Windows::Storage::FileAccessMode::Read)).then([this](IRandomAccessStream^ fileStream)
{
// Set the image source to the selected bitmap
auto bitmapImage = ref new BitmapImage();
bitmapImage->SetSource(fileStream);
inkImage->Source = bitmapImage;
});
}
else
{
return task_from_result();
}
});
}
Note that changed images are shown in Image
control, and you couldn’t save images again by the Save button which is used to save inks of InkCanvas
in Scenario3.
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.