Sunday, August 26, 2012

ImageView - rotate image


public class ImageLoadActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        LinearLayout m_linear = new LinearLayout(this);
        m_linear.setOrientation(LinearLayout.VERTICAL);
     
        Bitmap image = BitmapFactory.decodeResource(getResources(), R.drawable.akb48);
        Matrix matrix = new Matrix();
        matrix.postRotate(30);

        Bitmap rotated = Bitmap.createBitmap(image, 0, 0, image.getWidth(), image.getHeight(), matrix, true);

        ImageView i = new ImageView(this);
        i.setImageBitmap(rotated);
     
        m_linear.addView(i);
        setContentView(m_linear);
    }
}


No comments:

Post a Comment