image

Flutter Image 参数详解 1.继承关系 Object > Diagnosticablet > DiagnosticableTreet > Widgett > StatefulWidgett > Image 2.介绍 一个显示图片的widget,支持图像格式:JPEG,PNG,GIF,动画GIF,WebP,动画WebP,BMP和WBMP 3.创建Image 一共有五种方法: ... 阅读详情
  1. public class ImageUtil {  
  2.   
  3.     public static InputStream getRequest(String path) throws Exception {  
  4.         URL url = new URL(path);  
  5.         HttpURLConnection conn = (HttpURLConnection) url.openConnection();  
  6.         conn.setRequestMethod("GET");  
  7.         conn.setConnectTimeout(5000);  
  8.         if (conn.getResponseCode() == 200){  
  9.             return conn.getInputStream();  
  10.         }  
  11.         return null;  
  12.     }  
  13.   
  14.     public static byte[] readInputStream(InputStream inStream) throws Exception {  
  15.         ByteArrayOutputStream outSteam = new ByteArrayOutputStream();  
  16.         byte[] buffer = new byte[4096];  
  17.         int len = 0;  
  18.         while ((len = inStream.read(buffer)) != -1) {  
  19.             outSteam.write(buffer, 0, len);  
  20.         }  
  21.         outSteam.close();  
  22.         inStream.close();  
  23.         return outSteam.toByteArray();  
  24.     }  
  25.       
  26.     public static Drawable loadImageFromUrl(String url){  
  27.         URL m;  
  28.         InputStream i = null;  
  29.         try {  
  30.             m = new URL(url);  
  31.             i = (InputStream) m.getContent();  
  32.         } catch (MalformedURLException e1) {  
  33.             e1.printStackTrace();  
  34.         } catch (IOException e) {  
  35.             e.printStackTrace();  
  36.         }  
  37.         Drawable d = Drawable.createFromStream(i, "src");  
  38.         return d;  
  39.     }  
  40.       
  41.     public static Drawable getDrawableFromUrl(String url) throws Exception{  
  42.          return Drawable.createFromStream(getRequest(url),null);  
  43.     }  
  44.       
  45.     public static Bitmap getBitmapFromUrl(String url) throws Exception{  
  46.         byte[] bytes = getBytesFromUrl(url);  
  47.         return byteToBitmap(bytes);  
  48.     }  
  49.       
  50.     public static Bitmap getRoundBitmapFromUrl(String url,int pixels) throws Exception{  
  51.         byte[] bytes = getBytesFromUrl(url);  
  52.         Bitmap bitmap = byteToBitmap(bytes);  
  53.         return toRoundCorner(bitmap, pixels);  
  54.     }   
  55.       
  56.     public static Drawable geRoundDrawableFromUrl(String url,int pixels) throws Exception{  
  57.         byte[] bytes = getBytesFromUrl(url);  
  58.         BitmapDrawable bitmapDrawable = (BitmapDrawable)byteToDrawable(bytes);  
  59.         return toRoundCorner(bitmapDrawable, pixels);  
  60.     }   
  61.       
  62.     public static byte[] getBytesFromUrl(String url) throws Exception{  
  63.          return readInputStream(getRequest(url));  
  64.     }  
  65.       
  66.     public static Bitmap byteToBitmap(byte[] byteArray){  
  67.         if(byteArray.length!=0){   
  68.             return BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length);   
  69.         }   
  70.         else {   
  71.             return null;   
  72.         }    
  73.     }  
  74.       
  75.     public static Drawable byteToDrawable(byte[] byteArray){  
  76.         ByteArrayInputStream ins = new ByteArrayInputStream(byteArray);  
  77.         return Drawable.createFromStream(ins, null);  
  78.     }  
  79.       
  80.     public static byte[] Bitmap2Bytes(Bitmap bm){   
  81.         ByteArrayOutputStream baos = new ByteArrayOutputStream();  
  82.         bm.compress(Bitmap.CompressFormat.PNG, 100, baos);  
  83.         return baos.toByteArray();  
  84.     }  
  85.       
  86.     public static Bitmap drawableToBitmap(Drawable drawable) {  
  87.   
  88.         Bitmap bitmap = Bitmap  
  89.                 .createBitmap(  
  90.                         drawable.getIntrinsicWidth(),  
  91.                         drawable.getIntrinsicHeight(),  
  92.                         drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888  
  93.                                 : Bitmap.Config.RGB_565);  
  94.         Canvas canvas = new Canvas(bitmap);  
  95.         drawable.setBounds(0, 0, drawable.getIntrinsicWidth(),  
  96.                 drawable.getIntrinsicHeight());  
  97.         drawable.draw(canvas);  
  98.         return bitmap;  
  99.     }  
  100.       
  101.         /** 
  102.           * 图片去色,返回灰度图片 
  103.           * @param bmpOriginal 传入的图片 
  104.          * @return 去色后的图片 
  105.          */  
  106.         public static Bitmap toGrayscale(Bitmap bmpOriginal) {  
  107.             int width, height;  
  108.             height = bmpOriginal.getHeight();  
  109.             width = bmpOriginal.getWidth();      
  110.       
  111.             Bitmap bmpGrayscale = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);  
  112.             Canvas c = new Canvas(bmpGrayscale);  
  113.             Paint paint = new Paint();  
  114.             ColorMatrix cm = new ColorMatrix();  
  115.             cm.setSaturation(0);  
  116.             ColorMatrixColorFilter f = new ColorMatrixColorFilter(cm);  
  117.             paint.setColorFilter(f);  
  118.             c.drawBitmap(bmpOriginal, 0, 0, paint);  
  119.             return bmpGrayscale;  
  120.         }  
  121.           
  122.           
  123.         /** 
  124.          * 去色同时加圆角 
  125.          * @param bmpOriginal 原图 
  126.          * @param pixels 圆角弧度 
  127.          * @return 修改后的图片 
  128.          */  
  129.         public static Bitmap toGrayscale(Bitmap bmpOriginal, int pixels) {  
  130.             return toRoundCorner(toGrayscale(bmpOriginal), pixels);  
  131.         }  
  132.           
  133.         /** 
  134.          * 把图片变成圆角 
  135.          * @param bitmap 需要修改的图片 
  136.          * @param pixels 圆角的弧度 
  137.          * @return 圆角图片 
  138.          */  
  139.         public static Bitmap toRoundCorner(Bitmap bitmap, int pixels) {  
  140.       
  141.             Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888);  
  142.             Canvas canvas = new Canvas(output);  
  143.       
  144.             final int color = 0xff424242;  
  145.             final Paint paint = new Paint();  
  146.             final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());  
  147.             final RectF rectF = new RectF(rect);  
  148.             final float roundPx = pixels;  
  149.       
  150.             paint.setAntiAlias(true);  
  151.             canvas.drawARGB(0, 0, 0, 0);  
  152.             paint.setColor(color);  
  153.             canvas.drawRoundRect(rectF, roundPx, roundPx, paint);  
  154.       
  155.             paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));  
  156.             canvas.drawBitmap(bitmap, rect, rect, paint);  
  157.       
  158.             return output;  
  159.         }  
  160.       
  161.           
  162.        /** 
  163.          * 使圆角功能支持BitampDrawable 
  164.          * @param bitmapDrawable  
  165.          * @param pixels  
  166.          * @return 
  167.          */  
  168.         public static BitmapDrawable toRoundCorner(BitmapDrawable bitmapDrawable, int pixels) {  
  169.             Bitmap bitmap = bitmapDrawable.getBitmap();  
  170.             bitmapDrawable = new BitmapDrawable(toRoundCorner(bitmap, pixels));  
  171.             return bitmapDrawable;  
  172.         }  
  173. }  
docker image 保存到本地 保存image 查看本地的docker image: docker images REPOSITORY TAG IMAGE ID CREATED SIZE hello-world latest bf756fb1ae65 5 months ago 13.3kB hyperledger/fabric-javae 阅读详情

相关推荐

unity 动态加载image以及button,实现image在屏幕内移动

unity 动态加载image以及button,实现image在屏幕内移动、 using System.Collections; using System.Collections.Generic; using System.IO; using UnityEngine; using UnityEngine.UI; public class GUI_Test : MonoBehaviour { ...

weixin_38763863的博客 3465

Android仿微信UI布局视图(圆角布局的实现)

圆角button。或布局能够在xml文件里实现,但也能够使用图片直接达到所需的效果,曾经版本号的微信就使用了这样的方法。 实现效果图:    不得不说,这样的做法还是比較方便的。 源码: MainActivity(没写不论什么代码。效果全在布局文件里实现): package com.android_settings; import android.app.Acti...

weixin_34085658的博客 230

OpenHarmony实战开发-image、image-animator组件的使用。

OpenHarmony提供了常用的图片、图片帧动画播放器组件,开发者可以根据实际场景和开发需求,实现不同的界面交互效果,包括:点击阴影效果、点击切换状态、点击动画效果、点击切换动效。

m0_70749039的博客 929

Qt QSS中 background-image,border-image,以及image属性差别

QSS中 background-image,border-image,以及image属性差别

如梦人身 4125

Unity之Image & Raw Image

推荐阅读:  我的优快云  我的博客园  QQ群:704621321  我的个人博客 前言 正文 1Raw Image

爱上游戏开发 5005

用Diffusion Models实现image-to-image转换

Diffusion Models专栏文章汇总:入门与实战 前言:diffusion models诞生到现在,很多论文热衷于把diffusion models带到自己的领域用于生成,也有不少人醉心于用各种奇技淫巧优化采样过程,以改善diffusion models致命的缺点:生成速度太慢。而Palette的诞生意义不亚于pix2pix GANs、cycleGANs,能够实现图像着色、图像修复、图像剪裁恢复、图像解压缩(超分)等等任务。我们第一次发现,原来diffusion models不仅仅能用于生..

沉迷单车的追风少年 1万+

image对象的属性说明

一、image.shape的那些事: 1.image.shape[:2]表示 取彩色图片的高、宽, 2.image.shape[:3] 表示取彩色图片的高、宽、通道 3.image.shape[0], 图片垂直尺寸 4.image.shape[1], 图片水平尺寸 5.image.shape[2], 图片通道数 具体的解释为: 1)输出 height,即获取图像的高度,图像的高度为shape的第一...

目前主要分享信息学奥赛的知识 1万+

docker 删除image 报:image has dependent child images 错误

问题 在 Docker 中删除 image 时有时会遇到类似 Error response from daemon: conflict: unable to delete 6ec9a5a0fc9f (cannot be forced) - image has dependent child images 这样的错误,原因是有另外的 image FROM 了这个 image,可以使用下面的命令列出所有在指定 image 之后创建的 image 的父 image docker ima..

JineD的博客 7107

【QT】Qt QSS 中 background-image、image 和 border-image 的区别

需要背景纹理或渐变效果 :使用 background-image需要显示图标或内容图片 :使用 image需要创建可伸缩的UI元素 :使用 border-image。

qq_62917398的博客 1105

LabVIEW+数据库应用系列保姆级教程,第一篇数据库连接

目录LabVIEW连接数据库的方法连接MySQL连接Oracle,SQL Server,Access等 LabVIEW连接数据库的方法 1、创建udl(Universal Data Link)是通用数据连接文件。界面操作,简单快捷。 2、编写连接字符串。需要熟悉连接字符串的结构,容易出错。 3、其他… 本教程教你使用第1种方法,也是最简单、最常用的方法。 连接MySQL 1、在MySQL Installer内安装MySQL Connector/ODBC,建议安装32位(X86),如下图: 2、创建ODBC

wwplh5520370的博客 1万+

机器人关节电机发热难题:从工程化角度拆解热管理解决方案(下)

摘要:本文系统分析了机器人关节电机与驱动系统的热管理方案,重点解决局部热点问题。针对不同功率场景提出了热管/均热板散热(适用于中小功率)和液冷散热(适用于高功率)的具体实施方案,详细比较了结构参数、材料选择、安装工艺和散热效果。特别强调了电机-驱动协同热管理的重要性,提出"工况联动+热路径共享"的核心理念,包括一体化散热结构设计和动态控制策略。最后介绍了热仿真与测试验证方法,确保方案的有效落地。通过系统级热管理,可显著降低温升(热点区域降温30-60℃),同时优化体积和能耗。

bother3000的博客 3329

border-image 的正确用法

border-image 的正解用法border-image 边框图片,顾名思义: 指定边框使用的图片。尽管经常使用 border-image(-webkit-border-image),但我们真的了解它的吗?本文分两部分来介绍 border-image:border-image 简史border-image 用法1. border-image 简史CSS3 border 最开始是做为一个独立模块...

凹凸实验室 2万+

CANoe之UDS诊断自动化测试(四):创建诊断自定义Panel发送诊断(替代Session Control窗口)

通过自定义的Panel界面实现诊断发送的功能,并且还可以根据自己的测试需求添加需要的诊断信息,使用非常灵活。

weixin_69677286的博客 1904

grafana的image render设置

Grafana supports automatic rendering of panels as PNG images. This allows Grafana to automatically generate images of your panels to include in alert notifications. Note: Image rendering of dashboards is not supported at this time. Grafana支持将面板自动呈现为PNG图像。

dandanfengyun的博客 1万+

芯片详解——AD7606

AD7606详解

weixin_45661757的博客 5021

Backblaze 2025全年硬盘故障率报告解读

作为长期追踪存储行业动态的科技博主,每年/季度Backblaze的Drive Stats报告都是我重点关注的核心内容——不同于厂商发布的实验室数据,Backblaze以近13年、数十万片企业级硬盘的真实运行数据为基础,其年化故障率(AFR)、寿命趋势等结论,直接反映了硬盘在严苛数据中心环境下的真实表现,无论是企业存储选型还是个人高端存储参考,都具备极高的实用价值。2025年末,Backblaze发布了第13年的年度收官报告,涵盖2025年Q4、全年及终身硬盘可靠性数据。

存储随笔 4014

pygame之image模块

                          image-用于图像传输的Pygame模块 pygame.image.load—从文件加载新图像 pygame.image.save—将图像保存到磁盘 pygame.image.get_extended—测试是否可以加载扩展图像格式 pygame.image.tostring—将图像传输到字符串缓冲区 pygame.image.from...

河间老王的博客 4044

thinkphp 微信商户转账到微信用户零钱(v3密钥版)(含SDK和文档)

一种是用v3密钥的接口:微信商户转账到零钱(听说是v2接口的微信商户容易被限制,后来就改成v3了)这几天做项目有一个需求,小程序用户提交记录后,商家后台审核通过自动转账到用户的微信零钱中.今天分享下如何实现自动打款,v3微信商户转账到零钱。接口返回状态查看原因。

hanzhuhuaa的博客 428

【Flutter】Image 组件 ( Image 组件简介 | Image 构造函数 | Image.network 构造函数 | Image.asset 构造函数 )

一、Image 组件简介、 二、Image 构造函数、 二、Image.network 构造函数、、 四、Image.file 构造函数、 五、Image.asset 构造函数、 六、Image.memory 构造函数、

让 学习 成为一种 习惯 ( 韩曙亮 の 技术博客 ) 4640

2021年03月 C/C++(五级)真题解析#中国电子学会#全国青少年软件编程等级考试

给定一个十进制正整数n(0 < n < 1000000000),每个数位上数字均不为0。n的位数为m。现在从m位中删除k位(0

人生就是一个不断学习的过程 1010

13、基于RBF的自适应鲁棒控制与反步控制方法及实现

本文介绍了基于RBF神经网络的自适应鲁棒控制与反步控制方法,详细阐述了控制系统的程序结构、核心算法及实现流程。通过Simulink搭建仿真系统,利用RBF网络逼近系统中的不确定非线性函数,并结合Lyapunov稳定性理论设计控制律,实现了对倒立摆等复杂非线性系统的高精度跟踪控制。文章还提供了完整的MATLAB/Simulink代码示例和仿真结果分析,验证了该方法的有效性与鲁棒性,为实际工程应用提供了可行的技术路径。

ol789012的博客 87

小程序组件之——cover-image与image

cover-image与image 没错我们就是从头开始往下撸。有啥就讲啥。外带一些扩展。 聊正题因为是第一个组件,不对,应该说是第一组组件,因为image和cover-image是两个组件,不过因为太像啦,所以就拿出来一起讲。因为是第一组,所以我没讲解一下,wxml的代码都写在后缀为wxml中,css代码都写在wxss中,js在后缀是js的文件中,不需要像pc端那样刻意的去引用,只要写好了,系统自己就很聪明,帮你搞定这些事了,前提是文件名相同。 ok,这个东西时间久了 都会用的。咱们聊正事啦,终于开始讲正

morty 1万+

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

Image & Raw Image的区别

一、面板参数 1、Image类型: Source Image:图片资源(sprite) Color:颜色 Material:材质 Raycast Target :是否作为射线目标 Sprite 2D:是贴图的原始大小。 2、Raw Image类型: Source Ima...

weixin_30256505的博客 2356

android 蓝牙通讯demo

android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

border-image-slice

border-image-slice是用来分解引入进来的背景图片,这个参数相对来说比较复杂和特别,主要表现在以下几点: 1、其取值支持: | 其中number是没有单位的,专指像素px,因为其默认的单位就是像素px,所以在使用number时不需要加上单位,如果加上了单位反而是错误的写法。另外我们除了直接用nuember来设置外,我们还可以使用百分比值来表示,百分比的值是相对于边框背景图片而言

dengdai848586的博客 9621

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

border-image属性总结

border-image是一个挺“复杂”的属性,主要使用场景有: 元素边框不规则的情况。这时候,就需要用设计图作为边框背景,border-image与background-image相比,好处是更具灵活性,可以用代码控制边框背景的拉伸和重复,因而能够创造出更多样的效果 按钮宽高不确定的情况。用border-image来制作按钮,可以用同一张背景图,制造出各种宽高的按钮。 菜鸟、W3SCH...

weixin_44099111的博客 3573

QT border-image和background-image引起的边框设置问题

一、border-image 在一个frame中放入一张图片,设置frame的样式表,会发现边框设置没有生效。 border-image:url(:/refresh.png); border:1px solid red; 二、background-image 也在一个frame中放入一张图片,设置frame的样式表,会发现边框确实设置了,但图片没有正确显示。 background-image:...

guorong520的博客 8434
上一篇: 实现像网易和QQ动态导航按钮
下一篇: 实现带有边框的圆角
stonenotes123
博客等级 码龄15年 30粉丝 176原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值