Hi All,
I am trying to add a button to a custom imageview. I have created a
custom view to display an image to the screen, now i wanted to add a
custom button on this veiw and display a layout in onClick. The
following is my custom view.

/** testimgview.java*/
package com.android.testview;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.util.Log;
import android.view.ImageView;

public class testimgview extends ImageView {
     private static final boolean DEBUG = true;

     private Bitmap sourceImage;

     private int pWidth, pHeight;
     private float x, y;

     public testimgview(Context context) {
          super(context);

          BitmapFactory.Options bfo = new BitmapFactory.Options();
          bfo.inPreferredConfig = Bitmap.Config.RGB_565;

          sourceImage = BitmapFactory.decodeResource( getResources
() ,R.drawable.img, bfo);


          }
     }

     @Override
     protected void onDraw(Canvas canvas)
     {
          x = getWidth()*1.0f / pWidth;
          y = getHeight()*1.0f / pHeight;
          canvas.drawBitmap( sourceImage, null , new Rect(0,0,getWidth
(),getHeight()),tmpPaint);
          for (int i = 0; i < eyesMidPts.length; i++)
          {
                    canvas.drawCircle(x, y, 10.0f ,..);
          }
     }
}

/**testview.java*/
package com.android.testview;

import android.app.Activity;
import android.os.Bundle;

public class testview extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
        testimgview test = new (this);
        setContentView(test);
    }
}

Please advice me.

How to save Rect or region to a file as an image file.

Thank you for all support.

SMN.



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to