Example usage for android.graphics PixelFormat RGB_565

List of usage examples for android.graphics PixelFormat RGB_565

Introduction

In this page you can find the example usage for android.graphics PixelFormat RGB_565.

Prototype

int RGB_565

To view the source code for android.graphics PixelFormat RGB_565.

Click Source Link

Usage

From source file:Main.java

@SuppressWarnings("deprecation")
public static Bitmap.Config getBitmapConfig(int pixelFormat) {
    switch (pixelFormat) {
    case PixelFormat.RGBA_4444:
        return Bitmap.Config.ARGB_4444;
    case PixelFormat.RGB_565:
        return Bitmap.Config.RGB_565;
    case PixelFormat.A_8:
        return Bitmap.Config.ALPHA_8;
    default:/*from w w w .  j a va 2 s .c  o  m*/
        return Bitmap.Config.ARGB_8888;
    }
}

From source file:Main.java

@SuppressWarnings("deprecation")
public static int getPixelFormat(Bitmap.Config bitmapConfig) {
    switch (bitmapConfig) {
    case ARGB_4444:
        return PixelFormat.RGBA_4444;
    case RGB_565:
        return PixelFormat.RGB_565;
    case ALPHA_8:
        return PixelFormat.A_8;
    default://  w  w w  . ja v a 2  s. c  o m
        return PixelFormat.RGBA_8888;
    }
}

From source file:Main.java

@TargetApi(Build.VERSION_CODES.KITKAT)
public static ImageReader createImageReader(Activity c) {
    DisplayMetrics metrics = c.getResources().getDisplayMetrics();
    int density = metrics.densityDpi;
    int flags = DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR | DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC; //DisplayManager.VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY | DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC;
    Display display = c.getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);/* w  w w .  ja va  2s.c o  m*/

    return ImageReader.newInstance(size.x, size.y, PixelFormat.RGB_565, 2);
}

From source file:eu.veldsoft.adsbobball.ActivityStateEnum.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);

    setContentView(R.layout.main);/*from w w w. java 2s. co  m*/

    SurfaceView surfaceView = (SurfaceView) findViewById(R.id.surface_view);
    surfaceView.setOnTouchListener(this);
    surfaceHolder = surfaceView.getHolder();
    surfaceHolder.setFormat(PixelFormat.RGB_565);
    surfaceHolder.addCallback(this);

    messageView = (TextView) findViewById(R.id.message_label);
    messageView.bringToFront();

    transparentView = findViewById(R.id.transparent_view);
    numPlayersSelector = (Spinner) findViewById(R.id.num_players);

    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.playerNumber,
            android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    numPlayersSelector.setAdapter(adapter);

    button = (Button) findViewById(R.id.continue_button);
    button.setOnClickListener(this);

    statusTopleft = (TextView) findViewById(R.id.status_topleft);
    statusTopright = (TextView) findViewById(R.id.status_topright);
    statusBotleft = (TextView) findViewById(R.id.status_botleft);
    statusBotright = (TextView) findViewById(R.id.status_botright);

    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawerLayout.setDrawerListener(new DrawerLayout.SimpleDrawerListener() {
        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
            onClick(drawerView);
        }

        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            if (activityState == ActivityStateEnum.GAMERUNNING)
                showPauseScreen();
        }
    });

    statusTopright.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            statusTopright.setTextColor(0xffCCCCFF);
            secretHandshake += 1;
        }
    });

    statusBotright.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            if (secretHandshake > 4) {
                statusBotright.setTextColor(0xffCCCCFF);
                final NetworkIP n = new NetworkIP((int) System.currentTimeMillis());
                n.startServer();
                n.clientConnect("127.0.0.1", 1234);
            }
        }
    });

    scores = new Scores(getSharedPreferences("scores", Context.MODE_PRIVATE));
    scores.loadScores();

    if (savedInstanceState == null) {
        showIntroScreen();
    }
}

From source file:com.ffmpegtest.VideoActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    this.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFormat(PixelFormat.RGB_565);
    getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DITHER);

    super.onCreate(savedInstanceState);

    this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    this.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
    this.getWindow().setBackgroundDrawable(null);

    this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

    if (sIsSurfaceView)
        this.setContentView(R.layout.video_surfaceview);
    else/*w ww  .  j a v a 2 s .co  m*/
        this.setContentView(R.layout.video_view);

    mSeekBar = (SeekBar) this.findViewById(R.id.seek_bar);
    mSeekBar.setOnSeekBarChangeListener(this);

    mPlayPauseButton = (Button) this.findViewById(R.id.play_pause);
    mPlayPauseButton.setOnClickListener(this);

    mScaleButton = this.findViewById(R.id.scale_type);
    mScaleButton.setOnClickListener(this);

    mControlsView = this.findViewById(R.id.controls);
    mStreamsView = this.findViewById(R.id.streams);
    mLoadingView = this.findViewById(R.id.loading_view);
    mLanguageSpinner = (Spinner) this.findViewById(R.id.language_spinner);
    mSubtitleSpinner = (Spinner) this.findViewById(R.id.subtitle_spinner);

    mLanguageAdapter = new SimpleCursorAdapter(this, android.R.layout.simple_spinner_item, null, PROJECTION,
            new int[] { android.R.id.text1 }, 0);
    mLanguageAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    mLanguageSpinner.setAdapter(mLanguageAdapter);
    mLanguageSpinner.setOnItemSelectedListener(this);

    mSubtitleAdapter = new SimpleCursorAdapter(this, android.R.layout.simple_spinner_item, null, PROJECTION,
            new int[] { android.R.id.text1 }, 0);
    mSubtitleAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    mSubtitleSpinner.setAdapter(mSubtitleAdapter);
    mSubtitleSpinner.setOnItemSelectedListener(this);

    mVideoView = this.findViewById(R.id.video_view);
    ((FFmpegSurfaceView) mVideoView).setScaleType(ScaleType.CENTER_INSIDE, false);
    mMpegPlayer = new FFmpegPlayer((FFmpegDisplay) mVideoView, this);
    mMpegPlayer.setMpegListener(this);
    setDataSource();
}

From source file:org.telegram.ui.LaunchActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ApplicationLoader.postInitApplication();

    this.setTheme(R.style.Theme_TMessages);
    getWindow().setBackgroundDrawableResource(R.drawable.transparent);
    getWindow().setFormat(PixelFormat.RGB_565);

    if (!UserConfig.clientActivated) {
        Intent intent = getIntent();/* w w w . j  a v a  2  s.c  o  m*/
        if (intent != null && intent.getAction() != null && Intent.ACTION_SEND.equals(intent.getAction())
                || intent.getAction().equals(Intent.ACTION_SEND_MULTIPLE)) {
            finish();
            return;
        }
        Intent intent2 = new Intent(this, IntroActivity.class);
        startActivity(intent2);
        finish();
        return;
    }

    int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
    if (resourceId > 0) {
        Utilities.statusBarHeight = getResources().getDimensionPixelSize(resourceId);
    }

    NotificationCenter.getInstance().postNotificationName(702, this);
    currentConnectionState = ConnectionsManager.getInstance().connectionState;
    for (BaseFragment fragment : ApplicationLoader.fragmentsStack) {
        if (fragment.fragmentView != null) {
            ViewGroup parent = (ViewGroup) fragment.fragmentView.getParent();
            if (parent != null) {
                parent.removeView(fragment.fragmentView);
            }
            fragment.fragmentView = null;
        }
        fragment.parentActivity = this;
    }
    setContentView(R.layout.application_layout);
    NotificationCenter.getInstance().addObserver(this, 1234);
    NotificationCenter.getInstance().addObserver(this, 658);
    NotificationCenter.getInstance().addObserver(this, 701);
    NotificationCenter.getInstance().addObserver(this, 702);
    NotificationCenter.getInstance().addObserver(this, 703);
    NotificationCenter.getInstance().addObserver(this, GalleryImageViewer.needShowAllMedia);
    getSupportActionBar().setLogo(R.drawable.ab_icon_fixed2);

    statusView = getLayoutInflater().inflate(R.layout.updating_state_layout, null);
    statusBackground = statusView.findViewById(R.id.back_button_background);
    backStatusButton = statusView.findViewById(R.id.back_button);
    containerView = findViewById(R.id.container);
    statusText = (TextView) statusView.findViewById(R.id.status_text);
    statusBackground.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (ApplicationLoader.fragmentsStack.size() > 1) {
                onBackPressed();
            }
        }
    });

    if (ApplicationLoader.fragmentsStack.isEmpty()) {
        MessagesActivity fragment = new MessagesActivity();
        fragment.onFragmentCreate();
        ApplicationLoader.fragmentsStack.add(fragment);
    }

    handleIntent(getIntent(), false, savedInstanceState != null);
}

From source file:org.bobstuff.bobball.ActivityStateEnum.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);

    setContentView(R.layout.main);/*from   w  w w .j a v  a 2  s .  c  om*/

    SurfaceView surfaceView = (SurfaceView) findViewById(R.id.surface_view);
    surfaceView.setOnTouchListener(this);
    surfaceHolder = surfaceView.getHolder();
    surfaceHolder.setFormat(PixelFormat.RGB_565);
    surfaceHolder.addCallback(this);

    messageView = (TextView) findViewById(R.id.message_label);
    percentageCleared = (TextView) findViewById(R.id.percentageCleared);
    totalPercentageCleared = (TextView) findViewById(R.id.totalPercentageCleared);
    bonusPoints = (TextView) findViewById(R.id.bonusPoints);

    button = (Button) findViewById(R.id.continue_button);
    button.setOnClickListener(this);

    retryButton = (Button) findViewById(R.id.retryButton);
    backToLevelSelectButton = (Button) findViewById(R.id.backToLevelSelectButton);

    statusTopleft = (TextView) findViewById(R.id.status_topleft);
    statusTopright = (TextView) findViewById(R.id.status_topright);
    statusBotleft = (TextView) findViewById(R.id.status_botleft);
    statusBotright = (TextView) findViewById(R.id.status_botright);

    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawerLayout.setDrawerListener(new DrawerLayout.SimpleDrawerListener() {

        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
            if (gameManager.isPaused()) {
                gameManager.togglePauseGameLoop();
            }
            changeToPauseScreen();
            onClick(drawerView);
        }

        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            if (activityState == ActivityStateEnum.GAMERUNNING) {
                if (!gameManager.isPaused()) {
                    gameManager.togglePauseGameLoop();
                }
                showPauseScreen();
            }
        }
    });

    drawerLayout.setFocusableInTouchMode(false); // if set to false, the drawer doesn't react to pressing the back key by default

    statusTopright.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            statusTopright.setTextColor(0xffCCCCFF);
            secretHandshake += 1;
        }
    });

    statusBotright.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            if (secretHandshake > 4) {
                statusBotright.setTextColor(0xffCCCCFF);
                //request a hidden service
                Intent intent = new Intent("org.torproject.android.REQUEST_HS_PORT");
                intent.setPackage("org.torproject.android");
                intent.putExtra("hs_port", 8477);
                startActivityForResult(intent, 9999);
            }
        }
    });

    Bundle extras = getIntent().getExtras();
    level = extras.getInt("level");
    numPlayers = extras.getInt("numPlayers");

    scores = new Scores(numPlayers);
    scores.loadScores();
}

From source file:org.telegram.ui.LoginActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.login_layout);
    ApplicationLoader.applicationContext = this.getApplicationContext();

    getSupportActionBar().setLogo(R.drawable.ab_icon_fixed2);
    getSupportActionBar().show();//from  w ww . j av  a 2  s  .  c  om

    ImageView view = (ImageView) findViewById(16908332);
    if (view == null) {
        view = (ImageView) findViewById(R.id.home);
    }
    if (view != null) {
        view.setPadding(Utilities.dp(6), 0, Utilities.dp(6), 0);
    }

    views[0] = (SlideView) findViewById(R.id.login_page1);
    views[1] = (SlideView) findViewById(R.id.login_page2);
    views[2] = (SlideView) findViewById(R.id.login_page3);

    getSupportActionBar().setTitle(views[0].getHeaderName());

    if (savedInstanceState != null) {
        currentViewNum = savedInstanceState.getInt("currentViewNum", 0);
    }
    for (int a = 0; a < views.length; a++) {
        SlideView v = views[a];
        if (v != null) {
            v.delegate = this;
            v.setVisibility(currentViewNum == a ? View.VISIBLE : View.GONE);
        }
    }

    getWindow().setBackgroundDrawableResource(R.drawable.transparent);
    getWindow().setFormat(PixelFormat.RGB_565);
}

From source file:com.yahala.ui.LoginActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.login_layout);
    ApplicationLoader.applicationContext = this.getApplicationContext();

    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(mToolbar);/*w  w w.  ja va 2  s  . c  o  m*/
    mToolbar.setLogo(R.drawable.ab_icon_fixed2);
    getSupportActionBar().show();

    ImageView view = (ImageView) findViewById(16908332);
    if (view == null) {
        view = (ImageView) findViewById(R.id.home);
    }
    if (view != null) {
        view.setPadding(OSUtilities.dp(6), 0, OSUtilities.dp(6), 0);
    }

    views[0] = (SlideView) findViewById(R.id.login_page1);
    views[1] = (SlideView) findViewById(R.id.login_page2);
    views[2] = (SlideView) findViewById(R.id.login_page3);

    getSupportActionBar().setTitle(views[0].getHeaderName());

    if (savedInstanceState != null) {
        currentViewNum = savedInstanceState.getInt("currentViewNum", 0);
    }
    for (int a = 0; a < views.length; a++) {
        SlideView v = views[a];
        if (v != null) {
            v.delegate = this;
            v.setVisibility(currentViewNum == a ? View.VISIBLE : View.GONE);
        }
    }

    getWindow().setBackgroundDrawableResource(R.drawable.transparent);
    getWindow().setFormat(PixelFormat.RGB_565);
}

From source file:com.yahala.ui.CountrySelectActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    searching = false;//from  w  w  w  . j  a  v a  2  s.co m
    searchWas = false;

    try {
        BufferedReader reader = new BufferedReader(
                new InputStreamReader(getResources().getAssets().open("countries.txt")));
        String line;
        while ((line = reader.readLine()) != null) {
            String[] args = line.split(";");
            Country c = new Country();
            c.name = args[2];
            c.code = args[0];
            c.shortname = args[1];
            String n = c.name.substring(0, 1).toUpperCase();
            ArrayList<Country> arr = countries.get(n);
            if (arr == null) {
                arr = new ArrayList<Country>();
                countries.put(n, arr);
                sortedCountries.add(n);
            }
            arr.add(c);
        }
    } catch (Exception e) {
        FileLog.e("tmessages", e);
    }

    Collections.sort(sortedCountries, new Comparator<String>() {
        @Override
        public int compare(String lhs, String rhs) {
            return lhs.compareTo(rhs);
        }
    });

    for (ArrayList<Country> arr : countries.values()) {
        Collections.sort(arr, new Comparator<Country>() {
            @Override
            public int compare(Country country, Country country2) {
                return country.name.compareTo(country2.name);
            }
        });
    }

    setContentView(R.layout.country_select_layout);

    emptyTextView = (TextView) findViewById(R.id.searchEmptyView);
    searchListViewAdapter = new SearchAdapter(this);

    listView = (PinnedHeaderListView) findViewById(R.id.CoListView);
    listView.setEmptyView(emptyTextView);
    listView.setVerticalScrollBarEnabled(false);

    listView.setAdapter(listViewAdapter = new ListAdapter(this));
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            if (searching && searchWas) {
                if (i < searchResult.size()) {
                    Country c = searchResult.get(i);
                    Intent intent = new Intent();
                    intent.putExtra("country", c.name);
                    setResult(RESULT_OK, intent);
                    finish();
                }
            } else {
                int section = listViewAdapter.getSectionForPosition(i);
                int row = listViewAdapter.getPositionInSectionForPosition(i);
                if (section < sortedCountries.size()) {
                    String n = sortedCountries.get(section);
                    ArrayList<Country> arr = countries.get(n);
                    if (row < arr.size()) {
                        Country c = arr.get(row);
                        Intent intent = new Intent();
                        intent.putExtra("country", c.name);
                        setResult(RESULT_OK, intent);
                        finish();
                    }
                }
            }
        }
    });

    getWindow().setBackgroundDrawableResource(R.drawable.transparent);
    getWindow().setFormat(PixelFormat.RGB_565);
}