nine_image_tools 1.0.2 nine_image_tools: ^1.0.2 copied to clipboard
The flutter 9 image Stretch Fill processing tool.
9图工具 #
Version[1.0.1] #
在Flutter中并不能直接使用 .9.png
;这里通过ImageProvider
获取到图片的所有像素点的坐标系,并且判断出每个边界一个像素的黑色区域边界坐标轴,这样我们就知道了9图的填充区域和拉升区域。
- 拉伸区域只能使用
centerSlice
这个属性来是图片的进行拉伸大小。我们根据属性填充我们需要拉伸的区域填充进去即可Rect.fromLTRB(this.left, this.top, this.right, this.bottom)
- 填充区域,拉伸区域有了之后需要再处理填充区域,这里使用的
Container
中padding
属性来填充四个边,使得我们内容展示区域就是我们想要的区域,EdgeInsets.fromLTRB(this.left, this.top, this.right, this.bottom)
- 我们在裁切9图边缘区域,去掉黑色像素即获得了我们想要干净可拉伸区域。
1.使用方式如下:
NineImage(
//imageProvider 图像处理
imageProvider: AssetImage("images/private_bubble_baron.9.png"),
//内容填充区域
child: Text(
"sadasdasdasdas",
style: TextStyle(color: Colors.white),
),
)
目前还有个问题就是关于像素倍率压缩问题。目前推荐使用一倍图。