private async void ShareMiniProgram() { UIImage videoImage = null; using (System.IO.Stream stream = await SkiaSharpImageHelper.LoadImageStream("https://bopodastoragestaging.blob.core.chinacloudapi.cn/himedia-content/63eab63c-f827-6b6a-4f62-23af0502fca0.jpg")) { NSMutableDictionary shareParams = new NSMutableDictionary(); //videoImage = UIImage.LoadFromData(NSData.FromStream(stream)); NSData finalData = CompressWithMaxLength(NSData.FromStream(stream), 100); shareParams.SSDKSetupWeChatMiniProgramShareParamsByTitle("NET Core 1.1的新增特性", "<p>通过今天的活动,您将了解到科技助力各行各业提高效率成就的不凡之旅。如果您对人工智能,大数据,混合现实,物联网,云计算等最新数字科技在各行业应用感兴趣的话,我们的精心准备一定会使您不虚此行。</p>", NSUrl.FromString("http://mob.com"), $"pages/video/video?scene=209&tenancyName=Demo&isLiveVideo=true", null, finalData, "gh_9c9c75154329", true, 0, SSDKPlatformType.WechatSession); ShareSDKHelper.ShareParams(shareParams, SSDKPlatformType.WechatSession, (state, userData, contentEntity, error) => { switch (state) { case SSDKResponseState.Begin: break; case SSDKResponseState.Success: UIAlertController alert = UIAlertController.Create("Share Success", null, UIAlertControllerStyle.Alert); UIAlertAction action = UIAlertAction.Create("OK", UIAlertActionStyle.Default, null); alert.AddAction(action); this.PresentViewController(alert, true, null); break; case SSDKResponseState.Fail: UIAlertController alert1 = UIAlertController.Create("Share Failed", null, UIAlertControllerStyle.Alert); UIAlertAction action1 = UIAlertAction.Create("OK", UIAlertActionStyle.Default, null); alert1.AddAction(action1); this.PresentViewController(alert1, true, null); break; case SSDKResponseState.Cancel: UIAlertController alert2 = UIAlertController.Create("Share Cancel", null, UIAlertControllerStyle.Alert); UIAlertAction action2 = UIAlertAction.Create("OK", UIAlertActionStyle.Default, null); alert2.AddAction(action2); this.PresentViewController(alert2, true, null); break; default: break; } }); } }
private async void ShareImage() { NSMutableDictionary shareParams = new NSMutableDictionary(); //NSArray images = NSArray.FromObjects("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1522154322305&di=7f4bf3d0803fe8c2c66c140f0a6ea0b4&imgtype=0&src=http%3A%2F%2Fa4.topitme.com%2Fo%2F201007%2F29%2F12803876734174.jpg"); NSData image = null; SkiaSharp.SKBitmap back = await SkiaSharpImageHelper.LoadWebImage("https://msyunkestaging.blob.core.chinacloudapi.cn/himedia-content/a1a5aebc-bfdb-8e6c-7e98-ba635af70616.png"); SkiaSharp.SKBitmap ima = await SkiaSharpImageHelper.LoadWebImage("https://msyunkestaging.blob.core.chinacloudapi.cn/himedia-content/fdc0d632-fcc0-338f-0643-a2bef04964f2.jpg"); int width = back.Width; int height = back.Height; try { using (var tempSurface = SKSurface.Create(new SKImageInfo(width, height))) using (var paint = new SKPaint() { Style = SKPaintStyle.Fill, Color = SKColors.White, }) using (var textPaint = new SKPaint() { Color = SKColors.Black, IsAntialias = true, TextSize = 34, TextAlign = SKTextAlign.Center, FakeBoldText = true, Typeface = SKFontManager.Default.MatchCharacter("Courier New", '中') }) { var canvas = tempSurface.Canvas; canvas.Clear(SKColors.Transparent); string str1 = "美女与IT兽 | Seeed:做物联网应用别"; string str2 = "再把时间花在硬件研发上"; float xText = width / 2; float yText = (722 + 918) / 2; canvas.DrawBitmap(back, SKRect.Create(0, 0, width, height)); canvas.DrawRoundRect(SKRect.Create(32, 420, width - 64, 498), 10, 10, paint); canvas.DrawBitmap(ima, SKRect.Create(32, 420, width - 64, 302)); canvas.DrawText(str1, xText, yText, textPaint); canvas.DrawText(str2, xText, yText + 50, textPaint); image = NSData.FromArray(tempSurface.Snapshot().Encode().ToArray()); } } catch (Exception ex) { } shareParams.SSDKSetupWeChatParamsByText("https://www.baidu.com", "-----------", null, new NSString("image1.jpg"), UIImage.FromFile("image1.jpg"), null, null, null, null, null, null, SSDKContentType.Image, SSDKPlatformType.WechatSession); ShareSDKHelper.ShareParams(shareParams, SSDKPlatformType.WechatSession); }