9patch 在server端应用过程

two kinds 9patch:

There are two types of ninepatch file formats in the Android world ("source" and "compiled"). The source version is where you add the 1px transparency border everywhere-- when you compile your app into a .apk later, aapt will convert your *.9.png files to the binary format that Android expects. This is where the png file gets its "chunk" metadata. (read more)


client code:

InputStream stream = .. //whatever
Bitmap bitmap = BitmapFactory.decodeStream(stream);
byte[] chunk = bitmap.getNinePatchChunk(); //读chunk[]
boolean result = NinePatch.isNinePatchChunk(chunk); //判断是否是编译后的9Patch
NinePatchDrawable patchy = new NinePatchDrawable(bitmap, chunk, new Rect(), //由流创建9Patch图片
Server-side:

      you need to prepare your images. You can use the Android Binary Resource Compiler. This automates some of the pain away from creating a new Android project just to compile some *.9.png files into the Android native format. If you were to do this manually, you would essentially make a project and throw in some *.9.png files ("source" files), compile everything into the .apk format, unzip the .apk file, then find the *.9.png file, and that's the one you send to your clients.


tips:

相关源码在android源码的aapt目录下

 If you really, really need to construct your own chunk byte array, I would start by looking atdo_9patchisNinePatchChunkRes_png_9patch and Res_png_9patch::serialize() in ResourceTypes.cpp. There's also a home-made npTc chunk reader from Dmitry Skiba. I can't post links, so if someone can edit my answer that would be cool.

创建一个基于服务器的通信录通常涉及到设计一个数据库存储联系人信息、构建API以供客户应用程序访问数据以及处理用户的增删改查请求。下面是一个简化的概述: 1. **数据库设计**:你可以选择关系型数据库如MySQL,或者NoSQL数据库如MongoDB来存储联系人的信息。每个联系人可能包括字段如姓名、电话号码、电子邮件等。 ```sql CREATE TABLE contacts ( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100), phone VARCHAR(20), email VARCHAR(100) ); ``` 2. **服务器设置**:使用Node.js、Python、Java等语言编写服务代码,例如使用Express(Node.js)、Django(Python)或Spring Boot(Java),搭建Web服务器并配置路由来处理HTTP请求。 3. **CRUD API**: - **Create**: 用户通过POST请求添加新的联系人信息到数据库。 - **Read**: GET请求获取所有联系人,单个联系人通过ID获取。 - **Update**: PUT或PATCH请求更新特定联系人的信息。 - **Delete**: DELETE请求移除某个联系人。 4. **认证与授权**:为了保护数据安全,可以实现用户登录系统,只有经过身份验证的用户才能操作联系人列表。 5. **客户应用**:开发一个前界面(HTML/CSS/JavaScript 或者使用React、Vue等框架),用户可以通过这个界面浏览、搜索和管理他们的通信录。 6. **安全性**:考虑使用HTTPS来加密通信,防止数据在传输过程中被窃取。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值