MIDP1.0的图片放缩(setClip实现)
|
|
Author: 一滴蔚蓝色 | Date: 2008-01-23 |
View: 1151 |
开发技术 - 程序设计 | Digg:
0
|
|
public Image resizeImage(Image image, int scale) {//scale 是放缩比率哈, 100是正常大小 int sWidth = image.getWidth(); int sHeight = image.getHeight(); int Width = sWidth * scale / 100; int Height = Width * sHeight / sWidth; Image img = Image.createImage(Width, Height); Graphics g = img.getGraphics(); for (int y = 0; y < Height; y++) { for (int x = 0; x < Width; x++) { g.setClip(x, y, 1, 1); int dx = x * sWidth / Width; int dy = y * sHeight / Height; g.drawImage(image, x - dx, y - dy, Graphics.LEFT | Graphics.TOP); } } return img; } OT557上放缩140*140的图片大约需要6秒。 (破机器哈, 最好不要在V878一样的机器上用哈, 那将是NIGHTMARE!) 7610上放缩140*140的图片需要1到2秒 。 (过得去哈) K700上放缩140*140的图片需要1秒 。 (呵呵) 更多阅读: |
尚无评论发表