@@ -0,0 +1,2913 @@
+package com.webimageloader.transformation;%0A%0Aimport java.io.IOException;%0Aimport java.io.InputStream;%0A%0Aimport android.graphics.Bitmap;%0Aimport android.graphics.BitmapFactory;%0A%0Aimport com.webimageloader.util.InputSupplier;%0A%0A/**%0A * Scale an image to the specified size, it is safe to use%0A * this transformation on very large images as it loads the%0A * images using a sample size, as descriped in Android Training%0A * %0A * @author Alexander Blom %3Calexanderblom.se%3E%0A */%0Apublic class ScaleTransformation implements Transformation %7B%0A    private int reqWidth;%0A    private int reqHeight;%0A%0A    /**%0A     * Create a new scale transformation which will scale the image to%0A     * the specified required size. The image can however be slightly larger%0A     * than the size specified.%0A     * %0A     * @param reqWidth required width, the image will not be smaller than this%0A     * @param reqHeight required height, the image will not be smaller than this%0A     */%0A    public ScaleTransformation(int reqWidth, int reqHeight) %7B%0A        this.reqWidth = reqWidth;%0A        this.reqHeight = reqHeight;%0A    %7D%0A%0A    @Override%0A    public String getIdentifier() %7B%0A        return %22webimageloader_scale-%22 + reqWidth + %22x%22 + reqHeight;%0A    %7D%0A%0A    @Override%0A    public Bitmap transform(InputSupplier input) throws IOException %7B%0A        return decodeSampledBitmap(input);%0A    %7D%0A%0A    @Override%0A    public Bitmap transform(Bitmap b) %7B%0A        return Bitmap.createScaledBitmap(b, reqWidth, reqHeight, true);%0A    %7D%0A%0A    private Bitmap decodeSampledBitmap(InputSupplier input) throws IOException %7B%0A        // First decode with inJustDecodeBounds=true to check dimensions%0A        final BitmapFactory.Options options = new BitmapFactory.Options();%0A        options.inJustDecodeBounds = true;%0A        %0A        InputStream is = input.getInput();%0A        try %7B%0A            BitmapFactory.decodeStream(is, null, options);%0A        %7D finally %7B%0A            is.close();%0A        %7D%0A%0A        // Calculate inSampleSize%0A        options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight);%0A%0A        // Decode bitmap with inSampleSize set%0A        options.inJustDecodeBounds = false;%0A        %0A        is = input.getInput();%0A        try %7B%0A            return BitmapFactory.decodeStream(is, null, options);%0A        %7D finally %7B%0A            is.close();%0A        %7D%0A    %7D%0A    %0A    private static int calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight) %7B%0A        // Raw height and width of image%0A        final int height = options.outHeight;%0A        final int width = options.outWidth;%0A        int inSampleSize = 1;%0A%0A        if (height %3E reqHeight %7C%7C width %3E reqWidth) %7B%0A            if (width %3E height) %7B%0A                inSampleSize = Math.round((float) height / (float) reqHeight);%0A            %7D else %7B%0A                inSampleSize = Math.round((float) width / (float) reqWidth);%0A            %7D%0A        %7D%0A        return inSampleSize;%0A    %7D%0A%7D%0A

Add efficient scale transformation