首页 文章 精选 留言 我的

精选列表

搜索[聚类],共10000篇文章
优秀的个人博客,低调大师

SAP ABAP里存在Java List这种集合工具类么?CL_OBJECT_COLLECTION了解一下

文章标题的incident含义:在企业级软件领域里,当客户使用软件提供商的软件,遇到各种问题或故障,可以使用专门的工具,向软件供应商寻求帮助。我们通常称这种工具创建的帮助请求(Support Request)为incident. 今天这篇文章无关具体的技术。Jerry最近使用微软Azure云平台时遇到一个问题,通过Azure提供的Support工具向微软提交incident的过程中,感叹自己十多年来一直是修bug的命,这次终于翻身了,由我给另一家软件公司报bug,体验了一回当上帝的感觉。 我在SAP这些年,一共处理过317个客户incidents(当然并不是所有的都是Jerry修复的,包括我分析后转手到其他部分的也算). 我们Commerce Cloud团队使用Azure提供的Function create API在Azure上创建Lambda Function,过程中遇到一些问题,详见Jerry之前的文章:SAP ABAP应用服务器的HTTP响应状态码(Status Code). 在排除了问题不是我们消费端代码引起之后,我开始给Azure报incident. 虽然Azure的字面意思是天蓝色,但Jerry打开的Azure页面全是下图这种纯黑色背景,只是因为我换了一个黑色主题。 新建一个支持请求(Support Request),类型选择为Technical: 选中之后,Subscription就自动填充为我当前这个用户的订阅ID了。大家可以把Azure Subscription的作用类比成SAP Cloud Platform的Global Account. 然后指定遇到问题的Service类型,和具体的Resource名称。Subscription,Service,Resource这三个字段都是联动的下拉菜单。 Service,Problem type和Problem subtype这三个联动的下拉菜单,共同扮演的角色,类似给SAP产品报incident时需要维护的Application Component. 下图是SAP Application Component的树状关系图。 Jerry个人觉得Azure这种多层级联式下拉菜单的做法,为用户免去了记忆component ID的负担;但作为程序员,我个人还是更喜欢SAP这种通过树形结构维护component的方式。 回到Azure Portal,维护好了问题类型和描述信息后,Azure根据这些信息自动从其后台检索出相关的推荐解决方案。我浏览了一下,发现并不能解决我遇到的问题,于是点Next继续: 这里可以维护明细信息和上传附件。我当时将重现问题的步骤,Postman请求的payload,我的分析,包括我搭建的jMeter等信息全部写到一个PDF文件里了,总共8页,添加到附件里。 然后是选择故障的紧急程度,Azure有四档紧急程度可选:Critical,Urgent,Moderate和Minimal. 而对应的SAP里的术语叫Priority(优先级),SAP incident的优先级也分四档:Very High,High,Medium和Low. Jerry处理过的317个客户incidents中也不乏Very High的,当时处理时承担的压力,至今思之仍觉得后怕。 尽管明白“程序员何苦为难程序员”的道理,我还是选择了最高级别的Critical impact,享受一次7×24小时的服务。留下自己的手机以供联系。 最后点击Next就能成功创建Support Request. 因为我们享受的Support Plan级别是Premier,在这个级别之下,理论上15分钟之内就会收到响应。 果然,几分钟之后Jerry就收到了一个用Teams发起的会议请求: 我心想,微软真是动作神速啊,这么快就派出工程师准备和我一起在线调试了吗?本来我正在吃饭,只得放下碗筷回到电脑面前。 登入Microsoft Teams参加了会议我才知道,这个会的目的首先是,Azure Support工程师确认他们对我附件PDF里描述信息的理解是否正确,然后讨论这个incident的Severity是否应该从Critical降成Urgent. 工程师们详细询问了我们组对这个API的使用场景,以及当前Azure上是否存在已经上线的应用。最终我也同意了这个降级请求,毕竟微软这套衡量incident优先级的标准和SAP类似,都是按照Business Impact来界定的。 这个会刚结束,我手机又接到一个号码显示为美国的来电,一位自称是微软Critical Situation Manager的女士,询问我对刚才和Azure Support工程师开会的体验,以及对这个incident优先级的降低是否有异议。 整体来讲,我对这次向Azure提交incident的体验很满意,无论是响应速度还是同Azure Support工程师及Critical Situation Manager交谈下来感受到的专业程度,都给我留下了深刻的印象。 最后还是再来回顾一下SAP从业者们最熟悉的如何给SAP产品报incident的工具吧。 在SAP Cloud for Customer about菜单里集成了提交incident的功能: 提交界面比较简洁,维护标题和问题详细描述,上传附件。 当然也能使用最统一最通用的SAP One Support Launchpad: https://launchpad.support.sap.com 同Azure一样,SAP Support Launchpad也鼓励用户,在实际提交incident之前,首先去Knowledge Base里查询有无相关线索和解决方案。 不搜不知道,一搜吓一跳,原来HTTP 400 bad request确实是一个普遍问题,在SAP领域也一共存在1400多个相关note和讨论: 如果觉得这些搜索结果没有帮助,点击Submit an Incident. SAP incident也分4档不同的优先级: 关于上图的必填字段Component,如果是基于ABAP的SAP产品,很容易在开发包的Application Component字段找到这个值: 如果是SAP Cloud Platform的某个模块遇到了问题,对应的Application Component在SAP Help上能查到: https://help.sap.com/viewer/65de2977205c403bbc107264b8eccf4b/Cloud/en-US/08d1103928fb42f3a73b3f425e00e13c.html?scp-env=Cloud%20Foundry 回到Jerry给Azure报的那个incident,目前还在处理过程中。对此我也非常能理解,这种不能100%重现的故障是最让程序员头疼的。 我想起之前处理过的一个SAP CRM IBASE问题,应用运行时有一定概率会出现运行时Dump,但不是总能重现。 当年Jerry还在SAP成都研究院CRM开发团队工作,负责SAP CRM IBASE的维护。 当时给我报bug的同事也坦言,这个Dump不能稳定重现。如果试一次是正常工作的话......那就多试几次,直到出现Dump为止...... 最让我抓狂的是,如果单步调试,这个故障100%无法重现。换句话说,我多年积累下来的在文章SAP错误消息调试之七种武器:让所有的错误消息都能被定位里介绍的ABAP单步调试经验,在这个问题的分析上完全派不上用场。 幸运的是我最终通过自己的分析,写了一个脚手架程序,通过该测试程序能够100%重现Dump. 既然能稳定重现,剩下的任务就轻松了,通过单步调试就能找到问题根源。 这个问题折腾了我整整两天,解决完问题之后,我也做了复盘,分析自己为什么会花掉这么多时间。我把我的经验教训,以及最终通过分析找到能够稳定重现问题的突破口,写成了一篇SAP社区博客: My Tips about how to handle complex and tricky issues https://blogs.sap.com/2014/05/01/my-tips-about-how-to-handle-complex-and-tricky-issues/ 我把自己采取的问题定位方式归纳命名为“最小系统法”。本世纪初,国内电脑界流行DIY,大家分别购买自己中意品牌的电脑零配件,自己动手组装,运行时经常出现无法开机(俗称“点不亮”)的情况。电脑发烧友们习惯通过“最小系统法”去逐一排查,最终找到出故障的配件。 我处理那个IBASE bug因为无法单步调试,仅能通过ST22 Dump里的静态信息进行分析,所以我也使用了“最小系统法”,分析出可能引起故障的子模块,再写测试程序运行这些模块,逐一验证我的猜想。 关于我提交的这个不能稳定重现的Azure incident,我也会持续关注。最后祝我的同行,处理这个incident的微软工程师好运。感谢阅读。 本文来自云栖社区合作伙伴“汪子熙”,了解相关信息可以关注微信公众号"汪子熙"。

优秀的个人博客,低调大师

Android笔记:bitmap转换与处理相关工具类,Bitmap与DrawAble与byte[]与InputStream之间的转换

1.将view转为bitmap 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 // 将view转为bitmap public static Bitmap getBitmapFromView(View view) { // Define a bitmap with the same size as the view Bitmap returnedBitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888); // Bind a canvas to it Canvas canvas = new Canvas(returnedBitmap); // Get the view's background Drawable bgDrawable = view.getBackground(); if (bgDrawable != null ) // has background drawable, then draw it on the canvas bgDrawable.draw(canvas); else // does not have background drawable, then draw white background on // the canvas canvas.drawColor(Color.WHITE); // draw the view on the canvas view.draw(canvas); // return the bitmap return returnedBitmap; } 2.将view转为bitmap 1 2 3 4 5 6 7 8 // 将view转为bitmap public static Bitmap viewToBitmap(View view) { view.setDrawingCacheEnabled( true ); view.buildDrawingCache(); Bitmap bm = view.getDrawingCache(); return bm; } 3.将xml转为bitmap 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 // 将xml转为bitmap public static Bitmap convertBitmapFromXML(Context context, String clusterSize, Bitmap bm) { View layout = LayoutInflater.from(context).inflate(R.layout.estatecartlist_item, null ); View bitmapView = layout.findViewById(R.id.estatecartlist_item_bitmap); TextView xml_text = (TextView) layout.findViewById(R.id.item_estatecart_tv_name); ImageView image = (ImageView) layout.findViewById(R.id.item_estatecart_iv_main); image.setImageBitmap(bm); xml_text.setText(clusterSize); bitmapView.measure(MeasureSpec.makeMeasureSpec( 0 , MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec( 0 , MeasureSpec.UNSPECIFIED)); bitmapView.layout( 0 , 0 , bitmapView.getMeasuredWidth(), bitmapView.getMeasuredHeight()); final Bitmap clusterBitmap = Bitmap.createBitmap(bitmapView.getMeasuredWidth(), bitmapView.getMeasuredHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(clusterBitmap); bitmapView.draw(canvas); return clusterBitmap; } ==============参考资料=================== * 1.http://stackoverflow.com/questions/7200535/how-to-convert-views-to-bitmap * 2.http://stackoverflow.com/questions/5536066/convert-view-to-bitmap-on-android/9595919#9595919 * 3.http://stackoverflow.com/questions/12402392/android-converting-xml-view-to-bitmap-without-showing-it 4.图片缩放与压缩 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 // 按大小缩放 private Bitmap getimage(String srcPath) { BitmapFactory.Options newOpts = new BitmapFactory.Options(); // 开始读入图片,此时把options.inJustDecodeBounds 设回true了 newOpts.inJustDecodeBounds = true ; Bitmap bitmap = BitmapFactory.decodeFile(srcPath, newOpts); // 此时返回bm为空 newOpts.inJustDecodeBounds = false ; int w = newOpts.outWidth; int h = newOpts.outHeight; // 现在主流手机比较多是800*480分辨率,所以高和宽我们设置为 float hh = 800f; // 这里设置高度为800f float ww = 480f; // 这里设置宽度为480f // 缩放比。由于是固定比例缩放,只用高或者宽其中一个数据进行计算即可 int be = 1 ; // be=1表示不缩放 if (w > h && w > ww) { // 如果宽度大的话根据宽度固定大小缩放 be = ( int ) (newOpts.outWidth / ww); } else if (w < h && h > hh) { // 如果高度高的话根据宽度固定大小缩放 be = ( int ) (newOpts.outHeight / hh); } if (be <= 0 ) be = 1 ; newOpts.inSampleSize = be; // 设置缩放比例 // 重新读入图片,注意此时已经把options.inJustDecodeBounds 设回false了 bitmap = BitmapFactory.decodeFile(srcPath, newOpts); return compressImage(bitmap); // 压缩好比例大小后再进行质量压缩 } // 图片质量压缩 private static Bitmap compressImage(Bitmap image) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); image.compress(Bitmap.CompressFormat.JPEG, 100 , baos); // 质量压缩方法,这里100表示不压缩,把压缩后的数据存放到baos中 int options = 100 ; while (baos.toByteArray().length / 1024 > 100 ) { // 循环判断如果压缩后图片是否大于100kb,大于继续压缩 baos.reset(); // 重置baos即清空baos image.compress(Bitmap.CompressFormat.JPEG, options, baos); // 这里压缩options%,把压缩后的数据存放到baos中 options -= 10 ; // 每次都减少10 } ByteArrayInputStream isBm = new ByteArrayInputStream(baos.toByteArray()); // 把压缩后的数据baos存放到ByteArrayInputStream中 Bitmap bitmap = BitmapFactory.decodeStream(isBm, null , null ); // 把ByteArrayInputStream数据生成图片 return bitmap; } // 图片按比例大小压缩 private static Bitmap comp(Bitmap image) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); image.compress(Bitmap.CompressFormat.JPEG, 100 , baos); if (baos.toByteArray().length / 1024 > 1024 ) { // 判断如果图片大于1M,进行压缩避免在生成图片(BitmapFactory.decodeStream)时溢出 baos.reset(); // 重置baos即清空baos image.compress(Bitmap.CompressFormat.JPEG, 50 , baos); // 这里压缩50%,把压缩后的数据存放到baos中 } ByteArrayInputStream isBm = new ByteArrayInputStream(baos.toByteArray()); BitmapFactory.Options newOpts = new BitmapFactory.Options(); // 开始读入图片,此时把options.inJustDecodeBounds 设回true了 newOpts.inJustDecodeBounds = true ; Bitmap bitmap = BitmapFactory.decodeStream(isBm, null , newOpts); newOpts.inJustDecodeBounds = false ; int w = newOpts.outWidth; int h = newOpts.outHeight; // 现在主流手机比较多是800*480分辨率,所以高和宽我们设置为 float hh = 800f; // 这里设置高度为800f float ww = 480f; // 这里设置宽度为480f // 缩放比。由于是固定比例缩放,只用高或者宽其中一个数据进行计算即可 int be = 1 ; // be=1表示不缩放 if (w > h && w > ww) { // 如果宽度大的话根据宽度固定大小缩放 be = ( int ) (newOpts.outWidth / ww); } else if (w < h && h > hh) { // 如果高度高的话根据宽度固定大小缩放 be = ( int ) (newOpts.outHeight / hh); } if (be <= 0 ) be = 1 ; newOpts.inSampleSize = be; // 设置缩放比例 // 重新读入图片,注意此时已经把options.inJustDecodeBounds 设回false了 isBm = new ByteArrayInputStream(baos.toByteArray()); bitmap = BitmapFactory.decodeStream(isBm, null , newOpts); return compressImage(bitmap); // 压缩好比例大小后再进行质量压缩 } 5.图片转为文件 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 // 图片转为文件 public static boolean saveBitmap2file(Bitmap bmp, String filename) { CompressFormat format = Bitmap.CompressFormat.JPEG; int quality = 100 ; OutputStream stream = null ; try { stream = new FileOutputStream( "/sdcard/" + filename); } catch (FileNotFoundException e) { e.printStackTrace(); } return bmp.compress(format, quality, stream); } 6.屏幕截屏方法 1 2 3 4 5 6 7 8 9 // 屏幕截屏方法 获取当前屏幕bitmap,转换成bytes[] 调用 UI分享方法 public void printscreen_share(View v) { View view1 = getWindow().getDecorView(); Display display = getWindowManager().getDefaultDisplay(); view1.layout( 0 , 0 , display.getWidth(), display.getHeight()); view1.setDrawingCacheEnabled( true ); Bitmap bitmap = Bitmap.createBitmap(view1.getDrawingCache()); } 7.把Bitmap 转成 Byte 1 2 3 4 5 6 7 // 把Bitmap 转成 Byte public static byte [] Bitmap2Bytes(Bitmap bm) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); bm.compress(Bitmap.CompressFormat.PNG, 100 , baos); return baos.toByteArray(); } 8.图片转为文件 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 // 图片转为文件 public static boolean saveBitmap2file(Bitmap bmp) { CompressFormat format = Bitmap.CompressFormat.PNG; int quality = 100 ; OutputStream stream = null ; try { // 判断SDcard状态 if (!Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) { // 错误提示 return false ; } // 检查SDcard空间 File SDCardRoot = Environment.getExternalStorageDirectory(); if (SDCardRoot.getFreeSpace() < 10000 ) { // 弹出对话框提示用户空间不够 Log.e( "Utils" , "存储空间不够" ); return false ; } // 在SDcard创建文件夹及文件 File bitmapFile = new File(SDCardRoot.getPath() + FILE_PATH); bitmapFile.getParentFile().mkdirs(); // 创建文件夹 stream = new FileOutputStream(SDCardRoot.getPath() + FILE_PATH); // "/sdcard/" } catch (FileNotFoundException e) { e.printStackTrace(); } return bmp.compress(format, quality, stream); } 9.下载图片 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 // 下载图片 public static Bitmap loadImage(String... params) { InputStream is = null ; Bitmap bitmap = null ; try { URL url = new URL(params[ 0 ]); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setReadTimeout( 5000 ); conn.setConnectTimeout( 5000 ); if (HttpURLConnection.HTTP_OK != conn.getResponseCode()) { // 网络连接异常 Log.e( "" , "loadImage连接异常" ); return null ; } is = conn.getInputStream(); bitmap = BitmapFactory.decodeStream(is); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { if ( null != is) { try { is.close(); } catch (IOException e) { e.printStackTrace(); } } } return bitmap; } 10.byte[]转换成Bitmap 1 2 3 4 5 6 7 8 9 // byte[]转换成Bitmap public static Bitmap Bytes2Bitmap( byte [] b) { if (b.length != 0 ) { return BitmapFactory.decodeByteArray(b, 0 , b.length); } return null ; } 11.将字符串转换成Bitmap类型 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 public static Bitmap stringtoBitmap(String string) { // 将字符串转换成Bitmap类型 Bitmap bitmap = null ; try { byte [] bitmapArray; bitmapArray = Base64.decode(string, Base64.DEFAULT); bitmap = BitmapFactory.decodeByteArray(bitmapArray, 0 , bitmapArray.length); } catch (Exception e) { e.printStackTrace(); } return bitmap; } 12.将Bitmap转换成字符串 1 2 3 4 5 6 7 8 9 10 public static String bitmaptoString(Bitmap bitmap) { // 将Bitmap转换成字符串 String string = null ; ByteArrayOutputStream bStream = new ByteArrayOutputStream(); bitmap.compress(CompressFormat.PNG, 100 , bStream); byte [] bytes = bStream.toByteArray(); string = Base64.encodeToString(bytes, Base64.DEFAULT); return string; } 13.byte[]转为文件 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 //byte[]转为文件 public static File getFileFromBytes( byte [] b) { BufferedOutputStream stream = null ; File file = null ; try { // 判断SDcard状态 if (!Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) { // 错误提示 return null ; } // 检查SDcard空间 File SDCardRoot = Environment.getExternalStorageDirectory(); if (SDCardRoot.getFreeSpace() < 10000 ) { // 弹出对话框提示用户空间不够 Log.e( "Utils" , "存储空间不够" ); return null ; } // 在SDcard创建文件夹及文件 File bitmapFile = new File(SDCardRoot.getPath() + FILE_PATH); bitmapFile.getParentFile().mkdirs(); // 创建文件夹 FileOutputStream fstream = new FileOutputStream(bitmapFile); stream = new BufferedOutputStream(fstream); stream.write(b); } catch (Exception e) { e.printStackTrace(); } finally { if (stream != null ) { try { stream.close(); } catch (IOException e1) { e1.printStackTrace(); } } } return file; } 14.图片压缩 1 2 3 4 5 6 7 8 9 10 11 12 13 //图片缩放 public static Bitmap scaleDownBitmap(Bitmap photo, int newHeight, Context context) { final float densityMultiplier = context.getResources().getDisplayMetrics().density; int h = ( int ) (newHeight * densityMultiplier); int w = ( int ) (h * photo.getWidth() / (( double ) photo.getHeight())); photo = Bitmap.createScaledBitmap(photo, w, h, true ); return photo; } 15.将byte[]转换成InputStream 1 2 3 4 5 6 // 将byte[]转换成InputStream public InputStream Byte2InputStream( byte [] b) { ByteArrayInputStream bais = new ByteArrayInputStream(b); return bais; } 16.将InputStream转换成byte[] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 // 将InputStream转换成byte[] public byte [] InputStream2Bytes(InputStream is) { String str = "" ; byte [] readByte = new byte [ 1024 ]; int readCount = - 1 ; try { while ((readCount = is.read(readByte, 0 , 1024 )) != - 1 ) { str += new String(readByte).trim(); } return str.getBytes(); } catch (Exception e) { e.printStackTrace(); } return null ; } 17.将Bitmap转换成InputStream 1 2 3 4 5 6 7 8 // 将Bitmap转换成InputStream public InputStream Bitmap2InputStream(Bitmap bm) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); bm.compress(Bitmap.CompressFormat.JPEG, 100 , baos); InputStream is = new ByteArrayInputStream(baos.toByteArray()); return is; } 18.将Bitmap转换成InputStream 1 2 3 4 5 6 7 8 // 将Bitmap转换成InputStream public InputStream Bitmap2InputStream(Bitmap bm, int quality) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); bm.compress(Bitmap.CompressFormat.PNG, quality, baos); InputStream is = new ByteArrayInputStream(baos.toByteArray()); return is; } 19.将InputStream转换成Bitmap 1 2 3 4 5 // 将InputStream转换成Bitmap public Bitmap InputStream2Bitmap(InputStream is) { return BitmapFactory.decodeStream(is); } 20.Drawable转换成InputStream 1 2 3 4 5 6 // Drawable转换成InputStream public InputStream Drawable2InputStream(Drawable d) { Bitmap bitmap = this .drawable2Bitmap(d); return this .Bitmap2InputStream(bitmap); } 21.InputStream转换成Drawable 1 2 3 4 5 6 // InputStream转换成Drawable public Drawable InputStream2Drawable(InputStream is) { Bitmap bitmap = this .InputStream2Bitmap(is); return this .bitmap2Drawable(bitmap); } 22.Drawable转换成byte[] 1 2 3 4 5 6 // Drawable转换成byte[] public byte [] Drawable2Bytes(Drawable d) { Bitmap bitmap = this .drawable2Bitmap(d); return this .Bitmap2Bytes(bitmap); } 23.byte[]转换成Drawable 1 2 3 4 5 6 // byte[]转换成Drawable public Drawable Bytes2Drawable( byte [] b) { Bitmap bitmap = this .Bytes2Bitmap(b); return this .bitmap2Drawable(bitmap); } 24.Drawable转换成Bitmap 1 2 3 4 5 6 7 8 9 10 // Drawable转换成Bitmap public Bitmap drawable2Bitmap(Drawable drawable) { Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565); Canvas canvas = new Canvas(bitmap); drawable.setBounds( 0 , 0 , drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight()); drawable.draw(canvas); return bitmap; } 25.Bitmap转换成Drawable 1 2 3 4 5 6 7 // Bitmap转换成Drawable public Drawable bitmap2Drawable(Bitmap bitmap) { BitmapDrawable bd = new BitmapDrawable(bitmap); Drawable d = (Drawable) bd; return d; } 本文转自 glblong 51CTO博客,原文链接:http://blog.51cto.com/glblong/1304090,如需转载请自行联系原作者

资源下载

更多资源
优质分享App

优质分享App

近一个月的开发和优化,本站点的第一个app全新上线。该app采用极致压缩,本体才4.36MB。系统里面做了大量数据访问、缓存优化。方便用户在手机上查看文章。后续会推出HarmonyOS的适配版本。

Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

用户登录
用户注册
修改密码
忘记密码