免费预览已结束,剩余1页可下载查看
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
几个经典的图像缩放的函数收集了几个图像缩放的函数,可能实现的方式很多,感觉这几个不错的,分享下说明:以下函数都是基于MIDP2.0的,缩放后保留透明色。代码1,函数 resizeImagepublic static Image resizeImage(Image src, int destW, int destH) int srcW = src.getWidth(); int srcH = src.getHeight(); / create pixel arrays int destPixels = new intdestW * destH; / array to hold destination / pixels int srcPixels = new intsrcW * srcH; / array with sources pixels src.getRGB(srcPixels, 0, srcW, 0, 0, srcW, srcH); / simple point smapled resizing / loop through the destination pixels, find the matching pixel on / the source and use that for (int destY = 0; destY destH; +destY) for (int destX = 0; destX desH ? srcH : desH; for (int i = 0; i distance) tems -= distance; sb+; if (temd distance) temd -= distance; db+; sb = 0; db = 0; tems = 0; temd = 0; distance = srcW desW ? srcW : desW; for (int i = 0; i distance) tems -= distance; sb+; if (temd distance) temd -= distance; db+; / 生成放大缩小后图形像素buf int desBuf = new intdesW * desH; int dx = 0; int dy = 0; int sy = 0; int oldy = -1; for (int i = 0; i desH; i+) if (oldy = tabYi) System.arraycopy(desBuf, dy - desW, desBuf, dy, desW); else dx = 0; for (int j = 0; j 0; y-) for (int x = newWidth, XE = 0; x 0; x-) rawOutputoutOffset+ = rawInputinOffset; inOffset += XD; XE += XR; if (XE = newWidth) XE -= newWidth; inOffset+; inOffset += YD; YE += YR; if (YE = newHeight) YE -= newHeight; inOffset += original.getWidth(); return Image.createRGBImage(rawOutput, newWidth, newHeight, true); 我将100*100的图放大到200*200后对比了一下,ZoomImage生成的图片和另外两个函数生成的图像有点区别,感觉ZoomImage的效果好一点。再放大点就基本一样了看不出区别了。代码4 /*图像变换*/ public Image scaleImage(Image src,int scales1,int scales2) return transImage(src,src.getWidth()*scales1/scales2,src.getHeight()*scales1/scales2); public Image transImage(Image src, int w, int h) int srcW = src.getWidth(); int srcH = src.getHeight(); int dstW=w,dstH=h; Image tmp = Image.createImage(dstW, srcH); Graphics g = tmp.getGraphics(); int scale=16; int delta = (srcW scale) / dstW;/扫描长度 int pos = delta / 2;/扫描位置 for (int x = 0; x scale), 0, Graphics.LEFT | Graphics.TOP); pos += delta; Image dst = Image.createImage( dstW, dstH); g = dst.getGraphics(); delta = (srcH sca
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 苏州卫生职业技术学院《思想道德与法治》2024-2025学年期末试卷(A卷)
- 2025年反思会议考试题目及答案
- 物业合同委托付款协议
- 2025年儿科护理查房美篇题目及答案
- 2025年上教师资格笔试考试试题与答案(高中体育考生回忆版)
- 2025年上海市时事政治考试试卷带解析附参考答案
- 2025年高压电工职业技能考试试题(含答案)
- 磁致伸缩材料在可再生能源中的角色分析
- 2026年建筑工程公司施工设备采购论证管理制度
- 生物梯度复合材料在绿色交通设施的构建中
- 2024海康威视DS-K2M062 门控安全模块用户手册
- 同心共育静待花开-2025-2026学年高二上学期家长会
- 半导体产业在智能传感器系统领域的技术创新与发展
- 遗传球形红细胞增多症
- 医院自助机讲解
- 基于膜生物反应器的2025年城市污水处理深度处理工艺研究报告
- 传染病诊断标准
- 胆总管结石伴急性化脓性梗阻性胆管炎的护理课件
- 云南罚没财物管理办法
- 郡县制教学课件
- 2025年新疆中考数学试题(含答案)
评论
0/150
提交评论