星期三, 11月 07, 2012

use intent to share media to YouTube or Facebook

    private void share_media(String outputFile){
        // first check if the outputFile is exists
        if (!new File(outputFile).isFile()){
            return;
        }
        ContentValues content = new ContentValues(4);
        content.put(Video.VideoColumns.TITLE, "My Test");
        content.put(Video.VideoColumns.DATE_ADDED,
        System.currentTimeMillis() / 1000);
        content.put(Video.Media.MIME_TYPE, "video/mp4");
        content.put(MediaStore.Video.Media.DATA, outputFile);
        ContentResolver resolver = getContentResolver();
        Uri uri = resolver.insert(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, content);
     
        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType("video/*");
        intent.putExtra(Intent.EXTRA_STREAM, uri);
        try {
            startActivity(Intent.createChooser(intent, "Share using"));       
        }
        catch (android.content.ActivityNotFoundException ex) {
            Toast.makeText(getApplicationContext(),"No way to share",Toast.LENGTH_LONG).show();
        }
        return;
    }

星期二, 11月 06, 2012

Convert Side by Side image to Blue & Red 3D stereo mode

Convert Side by Side image to Blue & Red 3D stereo mode           

Bitmap dst = null;
int w = src_bitmap.getWidth();
int h = src_bitmap.getHeight();
int [] dst_pixs = new int[w * h];
int[] left_pixs;
int[] right_pixs;
int alpha;
int r;
int g;
int b;
// fix if width or height is odd will cause crash
if (w % 2 == 1){
    w = w-1;
}
if (h % 2 == 1){
    h = h-1;
}
//
int totals = w * h;

left_pixs = new int[(w / 2) * h];
right_pixs = new int[(w / 2) * h];
// Get Left and Right Pixs
src.getPixels(left_pixs, 0, w/2, 0, 0, w/2, h);
src.getPixels(right_pixs, 0, w/2, w/2, 0, w/2, h);
//
dst = Bitmap.createBitmap(w, h, Config.ARGB_8888);

for (i = 0; i < totals - 1; i++) {
                // Convert color , For blue & red ==> (left.a, left.r, right.g, right.b)
                alpha = left_pixs[i/2] & 0xff000000;
                r = (left_pixs[i/2] >> 16) & 0xff;
                g = (right_pixs[i/2] >> 8) & 0xff;
                b = right_pixs[i/2] & 0xff;
                dst_pixs[i] = alpha | (r << 16) | (g << 8) | b;
                // end conver color  
 }
dst.setPixels(dst_pixs, 0, w, 0, 0, w, h);

星期日, 8月 26, 2012

difference between men and women

I am into difficult situation regarding my job, 
there is  a problem that we need to solve as soon as possible, 
but until now, I cannot find the best way to solve it. 
This situation gave me too much anxiety, 
so I asked my boss but he told me that it's alright and that he will try to look for someone to solve it.
Usually men doesn't like to ask for help because that will mean they are weak or useless 
but you can't solve problem by yourself. 
I think this is the biggest difference between men and women. 
I read  a book  informing me about that but I am not sure if that is true, 
but base on my experience it is proven.

coffee

Although I like the taste of coffee, I usually drink coffee at least once a month. 
If I will  drink too much coffee, I usually experience palpitations. 
Often times  after drinking coffee I can't sleep well which makes me feel uncomfortable.
My wife doesn't feel these symptoms and she can even sleep early after drinking coffee.
In spite of she doesn't like to drink too much coffee because we need to control our food expenses.
In fact drinking too much coffee is unhealthy.
In Taiwan some people are thinking that drinking coffee is a fashion trend, 
because whenever they have  a cup of coffee in their hands,it's  a kind of noble moves. 
In my opinion that's not a bad habit, if they will feel happy and will not try to interfere to other people's lives. Why not?