Showing posts with label white. Show all posts
Showing posts with label white. Show all posts

Convert ImageView to black and white and set brightness using ColorFilter

| 0 comments |


MainActivity.java
package com.blogspot.android_er.androidcolorfilter;

import android.graphics.ColorFilter;
import android.graphics.ColorMatrixColorFilter;
import android.graphics.PorterDuff;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.ImageView;
import android.widget.SeekBar;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

ImageView imageView;
SeekBar brightnessBar;
TextView brightnessInfo;

PorterDuff.Mode[] optMode = PorterDuff.Mode.values();

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

imageView = (ImageView)findViewById(R.id.iv);
brightnessBar = (SeekBar)findViewById(R.id.bar_brightness);
brightnessInfo = (TextView)findViewById(R.id.brightness_info);

brightnessBar.setOnSeekBarChangeListener(brightnessBarChangeListener);

setBlackAndWhite(imageView);
}

SeekBar.OnSeekBarChangeListener brightnessBarChangeListener
= new SeekBar.OnSeekBarChangeListener(){

@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
setBlackAndWhite(imageView);
}

@Override
public void onStartTrackingTouch(SeekBar seekBar) {

}

@Override
public void onStopTrackingTouch(SeekBar seekBar) {

}
};

private void setBlackAndWhite(ImageView iv){

float brightness = (float)(brightnessBar.getProgress() - 255);

float[] colorMatrix = {
0.33f, 0.33f, 0.33f, 0, brightness, //red
0.33f, 0.33f, 0.33f, 0, brightness, //green
0.33f, 0.33f, 0.33f, 0, brightness, //blue
0, 0, 0, 1, 0 //alpha
};

ColorFilter colorFilter = new ColorMatrixColorFilter(colorMatrix);
iv.setColorFilter(colorFilter);

brightnessInfo.setText(String.valueOf(brightness));
}

}


layout/activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout


android_layout_width="match_parent"
android_layout_height="match_parent"
android_padding="16dp"
android_orientation="vertical"
tools_context=".MainActivity">

<TextView
android_layout_width="wrap_content"
android_layout_height="wrap_content"
android_layout_gravity="center_horizontal"
android_autoLink="web"
android_text="http://android-er.blogspot.com/"
android_textStyle="bold" />

<ImageView
android_id="@+id/iv"
android_layout_width="wrap_content"
android_layout_height="wrap_content"
android_src="@mipmap/ic_launcher"/>

<TextView
android_layout_width="wrap_content"
android_layout_height="wrap_content"
android_text="Brightness"/>

<SeekBar
android_id="@+id/bar_brightness"
android_layout_width="match_parent"
android_layout_height="wrap_content"
android_max="512"
android_progress="255"/>

<TextView
android_id="@+id/brightness_info"
android_layout_width="wrap_content"
android_layout_height="wrap_content"
android_text="Brightness"/>
</LinearLayout>


Related:
- Android example code using ColorFilter

Read More..

Trick your brain black and white photo turns to colour! Colour The Spectrum of Science BBC

| 0 comments |

Trick your brain: black and white photo turns to colour! - Colour: The Spectrum of Science - BBC

Programme website: http://bbc.in/1Q7ik5S Look at the photo in the clip. From a picture that contains no colour our brains are able to construct a full colour image.


I tried to develop a example to experience it - Display image in opposite color to Trick your brain.

Read More..

BlackBerry Bold 9900 White Smartphone Launched in India

| 0 comments |

RIM today announced the launch of the BlackBerry Bold 9900 smartphone in Pure White for Indian customers priced at Rs. 34990 .

The new BlackBerry Bold 9900 is the first BlackBerry smartphone to include built in support for NFC (Near Field Communications).

BlackBerry Bold 9900 comes with BlackBerry 7 O.S which is significantly faster vombining the dramatically improved performance of the advanced WebKit browser engine together with powerful hardware enhancements.

RIM claims BlackBerry Bold 9900 smartphone delivers browsing results that are up to 40% faster than BlackBerry 6 based smartphones and up to 100% faster than BlackBerry 5 based smartphones.

Distinguished by its high performance, beautiful design, amazingly effective keyboard and brilliant touch display, the Pure White BlackBerry Bold 9900 is crafted with premium materials including a brushed stainless steel frame that puts the finishing touch on a truly outstanding smartphone.
Read More..