2012-02-03 5 views
2

I가, 화상 폭 (290) 하나 개의 이미지하고 비트 맵의 ​​폭으로 변환을위한 전 맵 공장 사용 높이 increasing.My 코드이다 330.when 높이이고,비트 맵 공장 이미지를 사용한 후 너비와 높이가 증가하고 있습니까?

  mILearnBitmap = BitmapFactory.decodeResource(getResources(), 
      R.drawable.capital_a_1); 
     mILearnBitmap = mILearnBitmap.copy(Bitmap.Config.ARGB_8888, true); 
     mILearnPixelsArry = new int[mILearnBitmap.getWidth() * mILearnBitmap.getHeight()]; 
     mILearnBitmap.getPixels(mILearnPixelsArry, 0, mILearnBitmap.getWidth(), 0, 0,mILearnBitmap.getWidth(), mILearnBitmap.getHeight()); 
     Log.d("mILearnPixelsArry", "---" + mILearnPixelsArry.length); 
    Log.d("Width", "---" + mILearnBitmap.getWidth()); 
    Log.d("Height", "---" + mILearnBitmap.getHeight()); 

사용 후 코드 폭은 435로 증가 높이가 495로 증가했습니다. 제발 저를 도와주세요. 제발 저를 도와주세요.

답변

4

당신은 이것을 사용할 수 있습니다 이미지를

 public Bitmap getResizedBitmap(Bitmap bm, int newHeight, int newWidth) { 

    int width = bm.getWidth(); 

    int height = bm.getHeight(); 

    float scaleWidth = ((float) newWidth)/width; 

    float scaleHeight = ((float) newHeight)/height; 

    // create a matrix for the manipulation 
    Matrix matrix = new Matrix(); 
    // resize the bit map 

    matrix.postScale(scaleWidth, scaleHeight); 
    // matrix.postRotate(90); 
    // recreate the new Bitmap 
    Bitmap resizedBitmap = Bitmap.createBitmap(bm, 0, 0, width, height, 
      matrix, false); 

    return resizedBitmap; 

} 
+0

안녕하세요 Ramesh 님, 답장을 보내 주셔서 감사합니다. 여기 newWidth 및 newHeight는 실제 이미지 크기를 나타냅니다. –

+0

아니요,이 항목은 원하는대로 새 크기가 아닙니다. 이미지 크기를 500x300으로 조정하고 이미지의 크기를 조정하려면 newheight = 500, newwidth = 300 ok? –

+0

어디에서이 메서드를 호출할까요? bitmapfactory 또는 after.please 전에 도움을 요청하십시오. –

0

의 크기를 조정하기 위해이 기능을 사용하시기 바랍니다 -

Bitmap.createScaledBitmap (BM, INT destinationWidth, INT destinationHeight, 부울 필터);

관련 문제