关于J2ME图片放大缩小算法的疑问!!
private Image ZoomImage(Image srcImg, int desW, int desH) {
int srcW = srcImg.getWidth(); //原始图像宽
int srcH = srcImg.getHeight(); //原始图像高
//计算插值表
int[] tabY = new int[desH];
int[] tabX = new int[desW];
int sb = 0;
int db = 0;
int tems = 0;
int temd = 0;
int distance = srcH > desH ? srcH : desH;
for (int i = 0; i <= distance; i++) { /*垂直方向*/
tabY[db] = sb;
tems += srcH;
temd += desH;
if (tems > 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; i++) { /*水平方向*/
tabX[db] = sb;
tems += srcW;
temd += desW;
if (tems > distance) {
tems -= distance;
sb++;
}
if (temd > distance) {
temd -= distance;
db++;
}
}
System.out.println((Runtime.getRuntime().freeMemory()/1024));
//生成放大缩小后图形像素buf
Image desImg = Image.createImage(desW,desH);
Graphics gs= desImg.getGraphics();
int dx = 0;