package com.mpcap.Mapsearch;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.util.AttributeSet;
import android.view.SurfaceHolder;
import android.view.View;
import android.view.SurfaceHolder.Callback;

public class Zoom extends View implements Callback {

    public Zoom(Context context, AttributeSet attrs) {
        super(context, attrs);
        // TODO Auto-generated constructor stub
        BitmapFactory.Options options = new BitmapFactory.Options();
        options.inSampleSize = 4;
        mBitmap = BitmapFactory.decodeFile("/sdcard/Subwaymap_100114.png", options);
        mColors = createColors();
        int[] colors = mColors;
         
        mViewBitmap = Bitmap.createBitmap(colors, 0, mST, mWidth, mHeight, Bitmap.Config.ARGB_8888);
        resize= Bitmap.createScaledBitmap(mViewBitmap, mWidth, mHeight, true);
        System.out.println("Create");
    }
    private Bitmap mBitmap;
    private Bitmap mViewBitmap;
    private int mWidth = 0;
    private int mHeight = 0;
    //private Paint mPaint;
    private int[] mColors;
    private int mST = 0;
    private Bitmap resize;
    private Bitmap resize1;
    private boolean plus;
    private boolean scale=false;
       private int[] createColors(){
            System.out.println("createColors");
           int[] colors = null;
           mWidth = mBitmap.getWidth();
           mHeight = mBitmap.getHeight();
          
           mST = mWidth + 10; // 넓이보다 10을 크게 설정
       
           colors = new int[mST * mHeight];
           for (int y = 0; y < mHeight; y++) {
               for (int x = 0; x < mWidth; x++) {
                  colors[y * mST + x] = mBitmap.getPixel(x, y);
               }
           }
          return colors;
           }
    @Override
    public void draw(Canvas canvas) {
        // TODO Auto-generated method stub
        super.draw(canvas);
        System.out.println("Draw");
        //int winWidth = getWidth();
        //int winHeight = getHeight();
        // 이미지 그리기
        canvas.drawColor(Color.WHITE);
        if(false==scale)
        {
            canvas.drawBitmap(resize, 0,0, null);
            System.out.println("resize.height="+ resize.getHeight()+"resize.width="+resize.getWidth());
            //scale=true;
        }
        else if(true==scale)
        {
            canvas.drawBitmap(resize1, 0,0, null);
            System.out.println("resize1.height="+ resize1.getHeight()+"resize1.width="+resize1.getWidth());
        }
        canvas.translate(0, mViewBitmap.getHeight());
    }
    @Override
    public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3) {
        // TODO Auto-generated method stub
       
    }

    @Override
    public void surfaceCreated(SurfaceHolder arg0) {
        // TODO Auto-generated method stub

    }

    @Override
    public void surfaceDestroyed(SurfaceHolder holder) {
        // TODO Auto-generated method stub

    }
    //이미지 확대
    public void ImageScaleUp()
    {
         scale=true;
         mWidth= mWidth+10;
         mHeight= mHeight+10;
         System.out.println("mheight="+ mHeight+"mWidth="+mWidth);
         resize= Bitmap.createScaledBitmap(mViewBitmap, mWidth,mHeight,true);
         invalidate();
    }
    //이미지 축소
    public void ImageScaleDown()
    {
         scale=true;
         mWidth= mWidth-10;
         mHeight= mHeight-10;
         System.out.println("mheight="+ mHeight+"mWidth="+mWidth);
         resize= Bitmap.createScaledBitmap(mViewBitmap, mWidth,mHeight,true);
         invalidate();
    }
}


이미지 확대혹은 이미지 축소함수가 호출이 되어도 Ondraw함수 호출시에 값이 볗자히 않습니다
이유가 뭘까요?