2012-01-22 4 views
1

Canvasとcanvas.scale(Scale、Scale)を使用して画質の問題が発生しています。Canvasとcanvas.scale(Scale、Scale)を使用した画質の問題。

アンドロイド:彼らは正確に次のようになり、実行時

私はビットマップのサイズを変更するとき、私は、画像品質の問題のすべての記事を読んでいると信じて、助けていないようにリサイズした画像の品質キャンバススケール(浮動小数点スケール)でスケーリングするとき。

私は、画像品質の投稿で示唆されているように、さまざまなオプションを試しました。

BitmapFactory.Options options = new BitmapFactory.Options(); 
options.inJustDecodeBounds = false; 
options.inDither = false; 
options.inSampleSize = 1; 
options.inScaled = false; 
options.inPreferredConfig = Bitmap.Config.ARGB_8888;//I thought this would do it 
CurrentPicture = BitmapFactory.decodeFile(path, options);//Also tried decodeStream() 


PicturePaint = new Paint(); 
//PicturePaint = new Paint(Paint.FILTER_BITMAP_FLAG); //I also tried this 
//PicturePaint = new Paint(Paint.ANTI_ALIAS_FLAG); //I also tried this 
canvas.scale(Scale, Scale); 
canvas.drawBitmap(CurrentPicture, 0, 0, PicturePaint); 

これは私の目標を達成するための最後の障壁だと思います。私はイメージ品質の問題を解決できない場合、私が困っているのでかなり心配しています。どんな助けもありがとうございます。

ありがとうございます!

システムでは写真を投稿できませんので、以下のリンクがあります。

PictureSample

答えて

3

私は私の答えが正しいかどうかはありませんしていないかどうか、私はキャンバスのためのコードを持っています。これがあなたを助けるかもしれないと思います。

public class FotosurpriseActivity extends Activity { 
    /** Called when the activity is first created. */ 
    Bitmap overlay; 
    Paint pTouch; 
    int X = -100; 
    int Y = -100; 
    Canvas c2; 

    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); 
     requestWindowFeature(Window.FEATURE_NO_TITLE); 
     Bitmap mBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.android); 
     Bitmap mBitmapover = BitmapFactory.decodeResource(getResources(), R.drawable.ss); 
     overlay = BitmapFactory.decodeResource(getResources(), R.drawable.ss).copy(Config.ARGB_8888, true); 
     c2 = new Canvas(overlay); 

     pTouch = new Paint(Paint.ANTI_ALIAS_FLAG); 
     // pTouch.setXfermode(new PorterDuffXfermode(Mode.TARGET); 
     pTouch.setColor(Color.TRANSPARENT); 
     pTouch.setMaskFilter(new BlurMaskFilter(15, Blur.NORMAL)); 
     setContentView(new BitMapView(this, mBitmap, mBitmapover)); 
    } 

    class BitMapView extends View { 
     Bitmap mBitmap = null; 
     Bitmap mBitmapover = null; 

     public BitMapView(Context context, Bitmap bm, Bitmap bmover) { 
      super(context); 
      mBitmap = bm; 
      mBitmapover = bmover; 
     } 

     @Override 
     public boolean onTouchEvent(MotionEvent ev) { 

      switch (ev.getAction()) { 

      case MotionEvent.ACTION_DOWN: { 

       X = (int) ev.getX(); 
       Y = (int) ev.getY(); 
       invalidate(); 

       break; 
      } 

      case MotionEvent.ACTION_MOVE: { 

       X = (int) ev.getX(); 
       Y = (int) ev.getY(); 
       invalidate(); 
       break; 

      } 

      case MotionEvent.ACTION_UP: 

       break; 

      } 
      return true; 
     } 

     @Override 
     protected void onDraw(Canvas canvas) { 
      // called when view is drawn 
      Paint paint = new Paint(); 
      paint.setFilterBitmap(true); 
      // The image will be scaled so it will fill the width, and the 
      // height will preserve the image’s aspect ration 
      /* 
      * double aspectRatio = ((double) mBitmap.getWidth())/
      * mBitmap.getHeight(); Rect dest = new Rect(0, 0, 
      * this.getWidth(),(int) (this.getHeight()/aspectRatio)); double 
      * aspectRatio2 = ((double) mBitmapover.getWidth())/
      * mBitmapover.getHeight(); Rect dest2 = new Rect(0, 0, 
      * this.getWidth(),(int) (this.getHeight()/aspectRatio2)); 
      * canvas.drawBitmap(mBitmap, null, dest, paint); 
      * canvas.drawBitmap(mBitmapover, null, dest2, paint); 
      */ 

      // draw background 
      canvas.drawBitmap(mBitmap, 0, 0, null); 
      // copy the default overlay into temporary overlay and punch a hole 
      // in it 
      c2.drawBitmap(mBitmapover, 0, 0, null); // exclude this line to show 
                // all as you draw 
      c2.drawCircle(X, Y, 80, pTouch); 
      // draw the overlay over the background 
      canvas.drawBitmap(overlay, 0, 0, null); 
     } 
    } 

} 
+1

ありがとうございます。ほんとうにありがとう。私はそれが働いていると信じています。私は試したときに疑わしい。 PicturePaint =新しいペイント(Paint.FILTER_BITMAP_FLAG); PicturePaint =新しいPaintPaint.ANTI_ALIAS_FLAG); BitmapをBitmap.Config.ARGB_8888 – user1133277

+0

として設定していません。ok ................... – Ramz

0

あなたが話している品質の問題を示すスクリーンショットがありますか?ペイントでフィルタリングが有効になっていると、それは問題ありません。

+0

ありがとうございました!私は返事の遅れをお詫び申し上げます。私は休憩を取って、脳が腫れてしまいました。システムは画像を投稿させないので、画像サンプルへのリンクを追加しました。私は受け取った他の返信を見直して、彼らのコメントが助けになるかどうかを調べるつもりです。 – user1133277

0

多くのコードを試しました。 私はこれを私のマニフェストに追加して、私は最高品質の画像を持っていました。

私はキャンバスが低解像度で作成されていると思います。あなたが画面上にあなたのデバイスの解像度を印刷しようとすると、それは間違っていることがわかります。 マニフェストのアドインで解像度が変更されます。