日韩天天综合网_野战两个奶头被亲到高潮_亚洲日韩欧美精品综合_av女人天堂污污污_视频一区**字幕无弹窗_国产亚洲欧美小视频_国内性爱精品在线免费视频_国产一级电影在线播放_日韩欧美内地福利_亚洲一二三不卡片区

java圖片處理類(圖片水印,圖片縮放)(3)_JSP教程

編輯Tag賺U幣
教程Tag:暫無Tag,歡迎添加,賺取U幣!

推薦:jsp switch語句的用法
如果希望選擇執(zhí)行若干代碼塊中的一個,你可以使用switch語句: 語法: switch(n) { case 1: 執(zhí)行代碼塊 1 break case 2: 執(zhí)行代碼塊 2 break default: 如果n即不是1也不是2,則執(zhí)行此代碼 } 工作原理:switch后面的(n)可以是表達(dá)式,也可以(并通常)是變量。然后表達(dá)

    /**
     * 圖像切割(指定切片的寬度和高度)
     * @param srcImageFile 源圖像地址
     * @param descDir 切片目標(biāo)文件夾
     * @param destWidth 目標(biāo)切片寬度。默認(rèn)200
     * @param destHeight 目標(biāo)切片高度。默認(rèn)150
     */
    public final static void cut3(String srcImageFile, String descDir,
            int destWidth, int destHeight) {
        try {
            if(destWidth<=0) destWidth = 200; // 切片寬度
            if(destHeight<=0) destHeight = 150; // 切片高度
            // 讀取源圖像
            BufferedImage bi = ImageIO.read(new File(srcImageFile));
            int srcWidth = bi.getHeight(); // 源圖寬度
            int srcHeight = bi.getWidth(); // 源圖高度
            if (srcWidth > destWidth && srcHeight > destHeight) {
                Image img;
                ImageFilter cropFilter;
                Image image = bi.getScaledInstance(srcWidth, srcHeight, Image.SCALE_DEFAULT);
                int cols = 0; // 切片橫向數(shù)量
                int rows = 0; // 切片縱向數(shù)量
                // 計算切片的橫向和縱向數(shù)量
                if (srcWidth % destWidth == 0) {
                    cols = srcWidth / destWidth;
                } else {
                    cols = (int) Math.floor(srcWidth / destWidth) + 1;
                }
                if (srcHeight % destHeight == 0) {
                    rows = srcHeight / destHeight;
                } else {
                    rows = (int) Math.floor(srcHeight / destHeight) + 1;
                }
                // 循環(huán)建立切片
                // 改進的想法:是否可用多線程加快切割速度
                for (int i = 0; i < rows; i++) {
                    for (int j = 0; j < cols; j++) {
                        // 四個參數(shù)分別為圖像起點坐標(biāo)和寬高
                        // 即: CropImageFilter(int x,int y,int width,int height)
                        cropFilter = new CropImageFilter(j * destWidth, i * destHeight,
                                destWidth, destHeight);
                        img = Toolkit.getDefaultToolkit().createImage(
                                new FilteredImageSource(image.getSource(),
                                        cropFilter));
                        BufferedImage tag = new BufferedImage(destWidth,
                                destHeight, BufferedImage.TYPE_INT_RGB);
                        Graphics g = tag.getGraphics();
                        g.drawImage(img, 0, 0, null); // 繪制縮小后的圖
                        g.dispose();
                        // 輸出為文件
                        ImageIO.write(tag, "JPEG", new File(descDir
                                + "_r" + i + "_c" + j + ".jpg"));
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

分享:jsp if else語句使用方法
if else在大部份編程語言中都是這樣使用的,我們今天來簡單的介紹一下關(guān)于jsp教程 中的if else 與多重條件判斷。 HTML HEAD TITLEUsing the if Statement/TITLE /HEAD BODY H1Using the if Statement/H1 % int value = 10; if(value 0) out.println(Absolute value of

來源:模板無憂//所屬分類:JSP教程/更新時間:2013-04-17
相關(guān)JSP教程