隨筆-348  評(píng)論-598  文章-0  trackbacks-0
          public static Image createThumbnail(Image image,int width) {
                  
          int sourceWidth = image.getWidth();
              
          int sourceHeight = image.getHeight();
                  
          int thumbWidth = width;
              
          int thumbHeight = -1;
                  
          if (thumbHeight == -1)
              thumbHeight 
          = thumbWidth * sourceHeight / sourceWidth;
                  Image thumb 
          = Image.createImage(thumbWidth, thumbHeight);
              Graphics g 
          = thumb.getGraphics();
                  
          for (int y = 0; y < thumbHeight; y++{
                      
          for (int x = 0; x < thumbWidth; x++{
                          g.setClip(x, y, 
          11);//設(shè)置該像素點(diǎn)以外的區(qū)域繪制無效
                  
          int dx = x * sourceWidth / thumbWidth;
                          
          int dy = y * sourceHeight / thumbHeight;
                  g.drawImage(image, x 
          - dx, y - dy,Graphics.LEFT | Graphics.TOP);//重繪整張圖,實(shí)際上只是重繪了一個(gè)像素點(diǎn)
                      }

              }

                  
          return thumb;
              }
          上面的代碼用來在J2ME中繪制圖片的縮略圖,CLDC1.0的用法,2.0可以直接操控像素了

          ---------------------------------------------------------
          專注移動(dòng)開發(fā)

          Android, Windows Mobile, iPhone, J2ME, BlackBerry, Symbian
          posted on 2009-12-19 15:42 TiGERTiAN 閱讀(1412) 評(píng)論(0)  編輯  收藏 所屬分類: JavaJ2ME
          主站蜘蛛池模板: 吉隆县| 苏尼特右旗| 漳浦县| 南木林县| 凌云县| 灵丘县| 大英县| 江北区| 阿鲁科尔沁旗| 建昌县| 临洮县| 定兴县| 平阳县| 永安市| 汝阳县| 岳阳市| 八宿县| 芒康县| 徐闻县| 荆门市| 贞丰县| 重庆市| 弥渡县| 阳西县| 永兴县| 栖霞市| 三门县| 泰州市| 迁西县| 阿克| 盐池县| 栖霞市| 博湖县| 湛江市| 西乌珠穆沁旗| 镇雄县| 巴彦淖尔市| 清苑县| 潜山县| 青川县| 娱乐|