嗨,我正在尝试调整图像的大小以将其显示在辅助磁贴中。我的代码工作正常,但我不知道我做错了什么,因为当图像大于 1000*1000 时,图像不会显示在辅助磁贴这是我用来调整大小的代码
//restablecemos el nuevo tamañao 100*100
using (var sourceStream = await file.OpenAsync(FileAccessMode.Read))
{
BitmapDecoder decoder = await BitmapDecoder.CreateAsync(sourceStream);
BitmapTransform transform = new BitmapTransform() { ScaledHeight =100, ScaledWidth= 100 };
PixelDataProvider pixelData = await decoder.GetPixelDataAsync(
BitmapPixelFormat.Rgba8,
BitmapAlphaMode.Straight,
transform,
ExifOrientationMode.RespectExifOrientation,
ColorManagementMode.DoNotColorManage);
using (var destinationStream = await localfile.OpenAsync(FileAccessMode.ReadWrite))
{
BitmapEncoder encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.JpegEncoderId, destinationStream);
encoder.SetPixelData(BitmapPixelFormat.Rgba8, BitmapAlphaMode.Premultiplied, 100,100,96, 96, pixelData.DetachPixelData());
await encoder.FlushAsync();
}
}
这是我用来固定和显示辅助磁贴的代码
private async void btnpin(object sender, RoutedEventArgs e)
{
//mantenmos abierta el appbar
this.miappbar.IsSticky = true;
//obtenemos la imagen del .json y la mostramos en la nota
Uri smalllogo = new Uri(pequeniaImagen);
//creamos el secondary tile
SecondaryTile secondary = new SecondaryTile(logoSecondaryTileld, String.Format("{0} {1:d}",pageTitle.Text,Convert.ToDateTime(tvFecha.Text)),pageTitle.Text,logoSecondaryTileld, TileOptions.ShowNameOnLogo,smalllogo);
secondary.DisplayName =pageTitle.Text;//nombre de la nota
//obtenemos el color de fondo del secondary tile
SolidColorBrush brush= Editor.returnColorfromString(Mcolor);
secondary.BackgroundColor = brush.Color;
//color del texto
secondary.ForegroundText = ForegroundText.Dark;
bool isPinned = await secondary.RequestCreateForSelectionAsync(detalles.GetElementRect((FrameworkElement)sender), Windows.UI.Popups.Placement.Below);
//el usuario pinieo la nota
if (isPinned)
{
//ocultamos el btn pin
btnpin.Visibility = Visibility.Collapsed;
//mostramos el btn unpin
btnunpin.Visibility = Visibility.Visible;
this.firstbord.Visibility = Visibility.Collapsed;
}
this.miappbar.IsSticky = false;
}
有人知道这个错误的原因吗?
我希望你能帮帮我
谢谢