当前位置: 首页 > news >正文

自建购物网站多少钱温州自媒体公司

自建购物网站多少钱,温州自媒体公司,适合大学生做的网站有哪些,做的好的大学生旅行有哪些网站文章目录 XAML.CSToBytes方法使用效果 常试过AcrylicView.MAUI和Sharpnado.MaterialFrame&#xff0c;对于二者教程很少&#xff0c;使用直接写控件然后调属性&#xff0c;没有报错但也并没有效果所幸就自己写一个 XAML <?xml version"1.0" encoding"utf-…

在这里插入图片描述

文章目录

  • XAML
  • .CS
  • ToBytes方法
  • 使用
  • 效果

常试过AcrylicView.MAUI和Sharpnado.MaterialFrame,对于二者教程很少,使用直接写控件然后调属性,没有报错但也并没有效果所幸就自己写一个

XAML

<?xml version="1.0" encoding="utf-8" ?>
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"x:Class="Namespace.BackgroundBlurView"xmlns:skia="clr-namespace:SkiaSharp.Views.Maui.Controls;assembly=SkiaSharp.Views.Maui.Controls"
><ContentView.Content><Grid RowDefinitions="*"><skia:SKCanvasView  Grid.Row="0"x:Name="canvasView"HorizontalOptions="Fill"PaintSurface="OnCanvasViewPaintSurface"VerticalOptions="Fill" /></Grid></ContentView.Content>
</ContentView>

.CS

using CSharpFunctionalExtensions;
using SkiaSharp;
using SkiaSharp.Views.Maui;namespace Namespace ;public partial class BackgroundBlurView : ContentView
{#region 可绑定属性public static readonly BindableProperty PathProperty =BindableProperty.Create(propertyName: nameof(Path),returnType: typeof(string),declaringType: typeof(BackgroundBlurView),defaultBindingMode: BindingMode.OneWay,propertyChanged: PathPropertyChanged);public string Path{get { return (string)base.GetValue(PathProperty); }set { base.SetValue(PathProperty, value); }}private static void PathPropertyChanged(BindableObject bindable, object oldValue, object newValue){var control = (BackgroundBlurView)bindable;MainThread.BeginInvokeOnMainThread(() =>{control.canvasView.InvalidateSurface();});}#endregionbyte[] _musicbgBytes;public BackgroundBlurView(){InitializeComponent();}void OnCanvasViewPaintSurface(object sender, SKPaintSurfaceEventArgs args){SKImageInfo info = args.Info;SKSurface surface = args.Surface;SKCanvas canvas = surface.Canvas;canvas.Clear();float sigmaX = 20f;float sigmaY = 20f;using (SKPaint paint = new SKPaint()){// Set SKPaint propertiespaint.ImageFilter = SKImageFilter.CreateBlur(sigmaX, sigmaY);// Calculate rectangle for bitmapSKRect bitmapRect = new SKRect(0, 0, info.Width, info.Height);//bitmapRect.Inflate(-50, -50);using var stream = FileSystem.OpenAppPackageFileAsync("imgs/"+ Path).Result;_musicbgBytes = stream.ToBytes();if (_musicbgBytes==null){return;}SKBitmap bitmap = SKBitmap.Decode(_musicbgBytes);//SKBitmap.Decode("/Resources/Images/music/yinhe_bg.png");canvas.DrawBitmap(bitmap, bitmapRect, paint: paint);}}
}

ToBytes方法

public static byte[] ToBytes(this Stream stream)
{MemoryStream memoryStream = new MemoryStream();stream.CopyTo(memoryStream);return memoryStream.ToArray();
}

使用

        <view:BackgroundBlurView VerticalOptions="Fill" HorizontalOptions="Fill" Padding="-10" Path="{Binding BGImg}"></view:BackgroundBlurView>

效果

在这里插入图片描述

http://www.yayakq.cn/news/88418/

相关文章:

  • 南通网站建设系统汽配网站源码
  • 采集网站会员wordpress随机文章列表
  • 广州网站制作教程做文库网站怎么赚钱
  • 南阳网站营销外包公司南通高端网站设计建设
  • 网站开发课程建议北京适合穷人逛的商场
  • 做阀门网站中山市中国建设银行网站
  • 白酒网站源码wordpress做物流网站
  • 免费建个人网站上海营销型网站建设费用
  • 广州自助网站推广制作网页游戏大全slg
  • 定州市建设局网站辽宁建设工程信息网项目经理变更
  • 网站建设好友一次备案多个网站
  • 中信建设有限责任公司经济性质宁波网站运营优化系统
  • 个人网站名称wordpress设置付费
  • 建设银行网站流水账单怎么打a5wordpress模板
  • 江苏省 建设 注册中心网站首页王烨烨
  • 企业网站怎么做毕业设计免费的网络营销方式有哪些
  • 网站建设必须买数据库么福田企业网站推广公司
  • 公司内部网站的作用公司企业logo
  • 做网站挣钱快吗iis默认网站打不开
  • 网站名称怎么备案王也电脑壁纸
  • asp 建站wdcp装wordpress
  • 免费网站制作教程单机网页游戏网站
  • 做彩票网站模板快速网站建设
  • 会员网站免费建设wordpress dux3.0主题
  • 台州小型网站建设网站注销申请
  • 网站建设培训费用一级建造师价格最新行情
  • 专注网站开发制作网站语言
  • wordpress怎么代码高亮北京检查站优化
  • 建设 展示型企业网站php做网站基本流程
  • 松岗网站制作网页平台