Tpng.net 透明png图片和素材免费下载网站

https://tpng.net

这个网站收集了不少透明背景的png图片和素材,不需要注册可以免费下载。
虽然大部门是国外的素材,但也有通用的可供免费下载。

此外这个网站还提供一个小工具,可免费在线生成基于文本的图标,Logo等,使用非常简单。 https://tpng.net/icons

https://tpng.net

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
procedure BitmapFileToPNG(const Source, Dest: String); var Bitmap: TBitmap; PNG: TPNGObject; begin Bitmap := TBitmap.Create; PNG := TPNGObject.Create; {In case something goes wrong, free booth Bitmap and PNG} try Bitmap.LoadFromFile(Source); PNG.Assign(Bitmap); //Convert data into png PNG.SaveToFile(Dest); finally Bitmap.Free; PNG.Free; end end; Converting from PNG file to Windows bitmap file The above inverse. Loads a png and saves into a bitmap procedure PNGFileToBitmap(const Source, Dest: String); var Bitmap: TBitmap; PNG: TPNGObject; begin PNG := TPNGObject.Create; Bitmap := TBitmap.Create; {In case something goes wrong, free booth PNG and Bitmap} try PNG.LoadFromFile(Source); Bitmap.Assign(PNG); //Convert data into bitmap Bitmap.SaveToFile(Dest); finally PNG.Free; Bitmap.Free; end end; Converting from TImage to PNG file This method converts from TImage to PNG. It has full exception handling and allows converting from file formats other than TBitmap (since they allow assigning to a TBitmap) procedure TImageToPNG(Source: TImage; const Dest: String); var PNG: TPNGObject; BMP: TBitmap; begin PNG := TPNGObject.Create; {In case something goes wrong, free PNG} try //If the TImage contains a TBitmap, just assign from it if Source.Picture.Graphic is TBitmap then PNG.Assign(TBitmap(Source.Picture.Graphic)) //Convert bitmap data into png else begin //Otherwise try to assign first to a TBimap BMP := TBitmap.Create; try BMP.Assign(Source.Picture.Graphic); PNG.Assign(BMP); finally BMP.Free; end; end; //Save to PNG format PNG.SaveToFile(Dest); finally PNG.Free; end end;
.NET MAUI 中,您可以使用自定义渲染器来为 Label 添加背景图片。以下是一个简单的示例: 1. 在您的 MAUI 项目中创建一个名为 "CustomLabel" 的新控件类,并从 Label 类继承。 2. 在 CustomLabel 类中添加一个名为 "BackgroundImage" 的绑定属性,以便您可以在 XAML 中设置背景图片。 ```csharp public class CustomLabel : Label { public static readonly BindableProperty BackgroundImageProperty = BindableProperty.Create(nameof(BackgroundImage), typeof(string), typeof(CustomLabel)); public string BackgroundImage { get => (string)GetValue(BackgroundImageProperty); set => SetValue(BackgroundImageProperty, value); } } ``` 3. 创建一个自定义渲染器,将 Label 控件渲染为具有背景图片的控件。 针对 Android 平台: ```csharp [assembly: ExportRenderer(typeof(CustomLabel), typeof(CustomLabelRenderer))] namespace YourNamespace { public class CustomLabelRenderer : LabelRenderer { protected override void OnElementChanged(ElementChangedEventArgs<Label> e) { base.OnElementChanged(e); if (Control != null && e.NewElement != null) { var customLabel = (CustomLabel)e.NewElement; var backgroundImage = customLabel.BackgroundImage; if (!string.IsNullOrEmpty(backgroundImage)) { Control.Background = new BitmapDrawable(Resources, backgroundImage); } } } } } ``` 针对 iOS 平台: ```csharp [assembly: ExportRenderer(typeof(CustomLabel), typeof(CustomLabelRenderer))] namespace YourNamespace { public class CustomLabelRenderer : LabelRenderer { protected override void OnElementChanged(ElementChangedEventArgs<Label> e) { base.OnElementChanged(e); if (Control != null && e.NewElement != null) { var customLabel = (CustomLabel)e.NewElement; var backgroundImage = customLabel.BackgroundImage; if (!string.IsNullOrEmpty(backgroundImage)) { Control.BackgroundColor = UIColor.FromPatternImage(UIImage.FromFile(backgroundImage)); } } } } } ``` 4. 在 XAML 中使用自定义 Label 控件,并设置 BackgroundImage 属性来添加背景图片。 ```xml <local:CustomLabel BackgroundImage="background.png" Text="Hello, world!" /> ``` 请注意,上述示例仅适用于单个平台。您需要为每个平台创建一个自定义渲染器,以便在所有平台上正确地显示您的自定义 Label 控件。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值