图片的缩放

qianhen136 2009-06-27 02:37:12
public Image ZoomIn(Image img){
Image out=null;
int[] rgbOutPut=null;
Graphics g=null;
int width=0,height=0;
try{
width=img.getWidth();
height=img.getHeight();
out=Image.createImage(width, height);
int rgbInPut[]=new int[width*height];
rgbOutPut=new int[width*height*4];
img.getRGB(rgbInPut, 0, width, 0, 0, width, height);
img.getRGB(rgbOutPut, 0, width, 0, 0, width, height);
int i,j,k;
k=0;
int temp[][]=new int[width][height];
for(i=0;i<height;i++){
for(j=0;j<width;j++){
temp[i][j]=rgbInPut[k++];
}
}
for(i=0;i<height;i++){
for(j=0;j<width;j++){
rgbOutPut[k]=temp[j][i];
k++;
}
}
g=out.getGraphics();
}catch(Exception e){}
return out.createRGBImage(rgbOutPut, height, width, true);
}

有这样一个函数,但是输出的图片怎么和没改变过的一样?
请高手指点一下下,,哪里出了问题。
...全文
29 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
qianhen136 2009-06-28
  • 打赏
  • 举报
回复
嗯。。这里是一个错误。。
他的算法也错了。。研究出来了。。呵呵 。
j1223jesus 2009-06-27
  • 打赏
  • 举报
回复
return out.createRGBImage(rgbOutPut, height, width, true);

你最后创建的图像用回原图片的宽和高,怎么会改变呢。。。。
hc0120 2009-06-27
  • 打赏
  • 举报
回复
你的程序很奇怪。

13,100

社区成员

发帖
与我相关
我的任务
社区描述
Java J2ME
社区管理员
  • J2ME社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧