Form1.cs

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;

namespace WindowsPic
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            this.Load += new EventHandler(Form1_Load);
        }
        // 下载于www.51aspx.com
        void Form1_Load(object sender, EventArgs e)
        {
            //从指定的位图中获取透明度大于 10 的区域;
            Bitmap img = (Bitmap)pictbox.Image;
            GraphicsPath grapth = GetNoneTransparentRegion(img, 10);
            this.Region = new Region(grapth);

            //要显示的图片设置为窗体背景;
            this.BackgroundImage = pictbox.Image;
            this.BackgroundImageLayout = ImageLayout.Zoom;

            //在修改窗体尺寸之前设置窗体为无边框样式;
            this.FormBorderStyle = FormBorderStyle.None;
            this.Width = pictbox.Image.Width;
            this.Height = pictbox.Image.Height;
        }
        // 下载于www.51aspx.com
        /// <summary>
        /// 返回指定图片中的非透明区域;
        /// </summary>
        /// <param name="img">位图</param>
        /// <param name="alpha">alpha 小于等于该值的为透明</param>
        /// <returns></returns>
        public GraphicsPath GetNoneTransparentRegion(Bitmap img, byte alpha)
        {
            int height = img.Height;
            int width = img.Width;

            int xStart, xEnd;
            GraphicsPath grpPath = new GraphicsPath();
            for (int y = 0; y < height; y++)
            {
                //逐行扫描;
                for (int x = 0; x < width; x++)
                {
                    //略过连续透明的部分;
                    while (x < width && img.GetPixel(x, y).A <= alpha)
                    {
                        x++;
                    }
后面还有 22 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。