• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            逛奔的蝸牛

            我不聰明,但我會很努力

               ::  :: 新隨筆 ::  ::  :: 管理 ::
            1. Bilinear
            2. BiCubic
            3. Area_Average
            4. Progressive Bilinear
            當圖片縮小到原圖的一半以下時,bilinear的效果就不好了,再小下去,bicubic的也不夠好,最好的效果是area_average算法,但是這個需要花太多的時間,可以使用改進過的bilinear算法,效果跟area average差不多,速度在bilinear和bicubic之間,但是當圖片非常大,綻放到非常小時,花的時間比bicubic多得多,但是比area average少得多,效果與area average差不多,還是不錯的

            Progressive Bilinear Scaling

            We know that a significant problem with the quality of the bilinear approach occurs when the downscale is by more than 50 percent. So what if we compen- sated for that problem by scaling iteratively toward the final size, scaling down by exactly 50 percent each time until the final iteration, when we scale by 50 percent or less? Then we would account for all of the pixels along the way that should figure into the final image. 

                // 縮小圖片,縮小時可以使用改進過的bilinear, bicubic插值算法

                // 但是轉換透明圖片時如果使用單緩沖區會出問題,這時每次都要創建一個緩沖區才可以

                public static BufferedImage getFasterDownScaledInstance(BufferedImage img,

                                                                        int targetWidth,

                                                                        int targetHeight,

                                                                        Object hint,

                                                                        boolean progressive) {

                    int type = (img.getTransparency() == Transparency.OPAQUE) ? BufferedImage.TYPE_INT_RGB

                            : BufferedImage.TYPE_INT_ARGB;

                    BufferedImage ret = (BufferedImage) img;

                    BufferedImage scratchImage = null;

                    Graphics2D g2d = null;

                    int w = 0, h = 0;

                    int prevW = ret.getWidth();

                    int prevH = ret.getHeight();


                    if (progressive) {

                        // Use multistep technique: start with original size,

                        // then scale down in multiple passes with drawImage()

                        // until the target size is reached

                        w = img.getWidth();

                        h = img.getHeight();

                    } else {

                        // Use one-step technique: scale directly from original

                        // size to target size with a single drawImage() call

                        w = targetWidth;

                        h = targetHeight;

                    }


                    do {

                        if (targetWidth < img.getWidth() && progressive && w > targetWidth) {

                            // 如果是縮小,寬縮小為原來的一半

                            w >>>= 1;

                            w = (w < targetWidth) ? targetWidth : w;

                        } else {

                            w = targetWidth;

                        }


                        if (targetHeight < img.getHeight() && progressive && h > targetHeight) {

                            // 如果是縮小,高縮小為原來的一半

                            h >>>= 1;

                            h = (h < targetHeight) ? targetHeight : h;

                        } else {

                            h = targetHeight;

                        }


                        if (scratchImage == null) {

                            // Use a single scratch buffer for all iterations

                            // and then copy to the final, correctly sized image before

                            // returning

                            scratchImage = new BufferedImage(w, h, type);

                            g2d = scratchImage.createGraphics();

                        } else if (type == BufferedImage.TYPE_INT_ARGB && scratchImage != null && g2d != null) {

                            // 透明圖片不能使用單緩存

                            g2d.dispose();

                            scratchImage = new BufferedImage(w, h, type);

                            g2d = scratchImage.createGraphics();

                        }


                        g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, hint);

                        g2d.drawImage(ret, 0, 0, w, h, 0, 0, prevW, prevH, null);

                        prevW = w;

                        prevH = h;

                        ret = scratchImage;

                    } while (w != targetWidth || h != targetHeight);


                    if (g2d != null) {

                        g2d.dispose();

                    }


                    // If we used a target size, the results into it

                    if (targetWidth != ret.getWidth() || targetHeight != ret.getHeight()) {

                        scratchImage = new BufferedImage(targetWidth, targetHeight, type);

                        g2d = scratchImage.createGraphics();

                        g2d.drawImage(ret, 0, 0, null);

                        g2d.dispose();

                        ret = scratchImage;

                    }

                    return ret;

                }

            posted on 2011-01-09 18:20 逛奔的蝸牛 閱讀(4264) 評論(0)  編輯 收藏 引用 所屬分類: Java
            久久精品国产影库免费看| 国产精品乱码久久久久久软件| 午夜精品久久久久久中宇| 久久人人爽爽爽人久久久| 久久精品亚洲日本波多野结衣 | 国产精品成人99久久久久91gav| 99热精品久久只有精品| 久久WWW免费人成一看片| 九九久久99综合一区二区| 中文字幕无码久久人妻| 久久夜色精品国产亚洲| 国产成人精品综合久久久| 国产女人aaa级久久久级| 亚洲国产精品无码久久久秋霞2 | 久久精品国产亚洲7777| 久久久女人与动物群交毛片| 久久久久亚洲AV无码专区网站| 久久一日本道色综合久久| 久久久噜噜噜久久| 日韩一区二区久久久久久| 精品久久亚洲中文无码| 看全色黄大色大片免费久久久| 2021精品国产综合久久| 亚洲熟妇无码另类久久久| 日韩精品无码久久一区二区三 | 久久国产精品99精品国产987| 久久亚洲精品成人无码网站| 国产ww久久久久久久久久| 久久99久久99小草精品免视看| 午夜精品久久久久久久久| 99久久国产综合精品女同图片| 久久亚洲av无码精品浪潮| 久久精品国产亚洲精品| 国产福利电影一区二区三区久久久久成人精品综合 | 精品永久久福利一区二区| 久久婷婷人人澡人人爽人人爱| 日本加勒比久久精品| 蜜臀久久99精品久久久久久| 亚洲国产成人久久笫一页| 一级a性色生活片久久无少妇一级婬片免费放 | 亚洲狠狠综合久久|