posts - 3,  comments - 2,  trackbacks - 0
            2008年3月26日
          private void compressImageFile() {
                  JFileChooser fileChooser = new JFileChooser("d://");
                  fileChooser.showOpenDialog(this);
                  File file = fileChooser.getSelectedFile();
          
                  if (null != file && file.exists()) {
                      Toolkit toolkit = Toolkit.getDefaultToolkit();
                      Image srcImage = toolkit.getImage(file.getAbsolutePath()); // 構造Image對象
                      int wideth = -1;
                      int height = -1;
                      boolean flag = true;
                      while (flag) {
                          wideth = srcImage.getWidth(null); // 得到源圖寬
                          height = srcImage.getHeight(null); // 得到源圖長
                          System.out.println("wideth:" + wideth + " height:" + height);
                          if (wideth > 0 && height > 0) { // 因為 Toolkit.getImage 是異步讀取,如果
                                                          // wideth 和 height
                                                          // 都大于0,表明圖片已經加載完畢
                          // imageCanvas.setImage(srcImage);
                              flag = false;
                          } else {
                              try {
                                  Thread.sleep(10);
                              } catch (Exception e) {
                                  e.printStackTrace();
                              }
                          }
                      }
          
                      // 加載完畢,輸出
                      int w = 1024;
                      float s = (float) wideth / 1024.0f;
                      int h = (int) ((float) height / s);
                      BufferedImage bufferedImage = new BufferedImage(w, h,
                              BufferedImage.TYPE_INT_RGB);
                      // bufferedImage.getGraphics().drawImage(srcImage, 0, 0, 1024,
                      // 768, null); // 繪制縮小后的圖
                      boolean flag2 = false;
                      while (!(flag2 = bufferedImage.getGraphics().drawImage(srcImage, 0,
                              0, w, h, this))) {
                          try {
                              Thread.sleep(10);
                          } catch (Exception e) {
                              e.printStackTrace();
                          }
                      }
          
                      try {
          
                          File outputFile = new File("d://hhh.jpg");
                          if (!outputFile.exists()) {
                              outputFile.createNewFile();
                          }
                          FileOutputStream out = new FileOutputStream(outputFile); // 輸出到文件流
                          JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
                          encoder.encode(bufferedImage); // 近JPEG編碼
                          out.close();
                      } catch (Exception e) {
                          e.printStackTrace();
                      }
                  }
              }
          posted @ 2010-02-09 15:37 Mr. Michael.Q 閱讀(216) | 評論 (0)編輯 收藏
              最近老遇到Oracle的兩個驅動選擇,不清楚到底選哪個.. 于是,今天在網上找了一下,在CSDN的論壇中,coolhorse168 在官方網站上找來對這兩驅動的解釋,特地抄過來寫在我的博客里,以備日后查看.

          ojdbc14.jar
              Classes for use with JDK 1.4.  It contains the JDBC driver
              classes, except classes for NLS support in Oracle Object and
              Collection types.

          classes12.jar
              Classes for use with JDK 1.2 and JDK 1.3.  It contains the
              JDBC driver classes, except classes for NLS support in Oracle
              Object and Collection types.

          The Old oracle.jdbc.driver Package Will Go Away Soon !!!
          --------------------------------------------------------

          Beginning in Oracle 9i, Oracle extensions to JDBC are captured in
          the package oracle.jdbc.  This package contains classes and
          interfaces that specify the Oracle extensions in a manner similar
          to the way the classes and interfaces in java.sql specify the
          public JDBC API.

          The use of the package oracle.jdbc.driver has been deprecated
          since the initial version of 9i.  Your code should use the package
          oracle.jdbc instead.  New features since Oracle 9i are incompatible
          with use of the package oracle.jdbc.driver.  Although we continue
          to support the old package oracle.jdbc.driver in this release to
          provide backwards compatibility, the package will definitely be
          removed in the next major release.  If you still have existing
          applications that use the old oracle.jdbc.driver package, now is the
          time to convert your code.

          All that is required to covert your code is to replace
          "oracle.jdbc.driver" with "oracle.jdbc" in the source and recompile.
          This cannot be done piecewise.  You must convert all classes
          and interfaces that are referenced by an application.
          posted @ 2008-03-27 17:18 Mr. Michael.Q 閱讀(331) | 評論 (1)編輯 收藏
               摘要: Tomcat 6.0 的 JNDI數據源 設置  閱讀全文
          posted @ 2008-03-26 21:27 Mr. Michael.Q 閱讀(3745) | 評論 (1)編輯 收藏
          主站蜘蛛池模板: 太原市| 栾城县| 遵义市| 依兰县| 高安市| 呼和浩特市| 桦川县| 稷山县| 华坪县| 杭锦旗| 石门县| 五峰| 金门县| 玛多县| 东山县| 阳谷县| 马龙县| 左云县| 乌拉特前旗| 邹城市| 嘉峪关市| 渝中区| 夹江县| 黑水县| 康马县| 台山市| 盈江县| 阳谷县| 洪洞县| 高雄市| 新津县| 吉林省| 武功县| 昭通市| 利川市| 鄂托克前旗| 陵水| 浠水县| 岚皋县| 昌吉市| 铅山县|