Tag Archives: draw

8,791 views

Draw Bitmap with Alpha opacity ratio Android

Bitmap bgr = BitmapFactory.decodeResource(getResources(),R.drawable.background); Paint transparentpaint = new Paint(); transparentpaint.setAlpha(100); // 0 – 255 canvas.drawBitmap(bgr, 0, 0, transparentpaint); public void setAlpha (int a) Since: API Level 1 Helper to setColor(), that only assigns the color’s alpha value, leaving its r,g,b … Continue reading

Posted in Android Examples Code, Bitmap, drawing | Tagged , | Comments Off on Draw Bitmap with Alpha opacity ratio Android
18,382 views

Convert Drawable to Bitmap to Drawable

Context context = getApplicationContext(); Drawable drawable = context.getResources().getDrawable(R.drawable.my_image); // convert drawable to bitmap Bitmap bitmap = ((BitmapDrawable)drawable).getBitmap(); // convert bitmap to drawable Drawable d = new BitmapDrawable(bitmap); Android example source code.

Posted in Android Examples Code, Bitmap, drawing | Tagged , , | Comments Off on Convert Drawable to Bitmap to Drawable
20,210 views

Hue saturation, color, colored filtering Bitmap Image Android example

/* Copyright (C) 2011 The Android Open Source Project http://www.apache.org/licenses/LICENSE-2.0 */ public class MainActivity extends Activity { private ImageView imageView; private Button button1; Drawable bitmapOrg; private final int[] mColors = {Color.BLUE, Color.GREEN, Color.RED, Color.LTGRAY, Color.MAGENTA, Color.CYAN, Color.YELLOW, Color.WHITE};   @Override … Continue reading

Posted in Android Examples Code, Bitmap, drawing | Tagged , , | Comments Off on Hue saturation, color, colored filtering Bitmap Image Android example
21,275 views

Create own custom Title Bar TitleBar with a Icon Android example

onCreate in MainActivity.java @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);   requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); setContentView(R.layout.main.xml); getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title); } You can add to titlebar different Views by xml file. custom_title.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/screen" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <TextView android:id="@+id/left_text" android:layout_width="wrap_content" android:layout_height="wrap_content" … Continue reading

Posted in Android Examples Code, Bitmap, drawing | Tagged , , | Comments Off on Create own custom Title Bar TitleBar with a Icon Android example
12,285 views

Rotate Canvas with Bitmap Android example

drawPath, canvas.rotate, lineTo basic Android example for your testing. // http://www.apache.org/licenses/LICENSE-2.0 // The Android Open Source Project public class MainActivity extends Activity {   @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(new SampleView(this)); }   private static class SampleView extends … Continue reading

Posted in Android Examples Code, Bitmap, drawing | Tagged , , | Comments Off on Rotate Canvas with Bitmap Android example
25,746 views

Color Picker Dialog Android example

Select color from menu and touch the screen. // MainActivity.java public class MainActivity extends Activity implements ColorPickerDialog.OnColorChangedListener { // http://www.apache.org/licenses/LICENSE-2.0 protected int _color = Color.GREEN;   @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mPaint = new Paint(); mPaint.setColor(Color.RED); setContentView(new SampleView(this)); … Continue reading

Posted in Android Examples Code | Tagged , , | Comments Off on Color Picker Dialog Android example
14,462 views

Bitmap Canvas Color Gradient linear radial sweep rounded corner Android example

public class MainActivity extends Activity { // http://www.apache.org/licenses/LICENSE-2.0 @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(new SampleView(this)); }   private static class SampleView extends View { private Rect mRect; private GradientDrawable mDrawable;   public SampleView(Context context) { super(context); setFocusable(true);   … Continue reading

Posted in Android Examples Code, Bitmap, drawing | Tagged , , | Comments Off on Bitmap Canvas Color Gradient linear radial sweep rounded corner Android example
16,923 views

drawBitmap, clipPath, UNION, DIFFERENCE, INTERSECT, REPLACE, XOR Android example

public class MainActivity extends Activity {   @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(new SampleView(this)); }   private static class SampleView extends View {   // CONSTRUCTOR public SampleView(Context context) { super(context); setFocusable(true);   }   @Override protected void … Continue reading

Posted in Android Examples Code | Tagged , , | Comments Off on drawBitmap, clipPath, UNION, DIFFERENCE, INTERSECT, REPLACE, XOR Android example
15,675 views

Convert a Bitmap to Gray Scale Android example

Black and white bitmap image pictures, gray scale colormatrix Android example. public class ApokusActivity extends Activity {   @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(new SampleView(this)); }   private static class SampleView extends View {   // CONSTRUCTOR public … Continue reading

Posted in Android Examples Code, Bitmap, drawing | Tagged , , | Comments Off on Convert a Bitmap to Gray Scale Android example
30,499 views

Crop cropped cut bitmap image pictures Android example

Cut, shear, clip, snip, crop a bitmap, picture, image Android example public class ApokusActivity extends Activity {   @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(new SampleView(this)); }   private static class SampleView extends View {   // CONSTRUCTOR public … Continue reading

Posted in Android Examples Code | Tagged , , | Comments Off on Crop cropped cut bitmap image pictures Android example