1. Download our Official Android App: Forums for Android!

Support surface view snap shot not working programmatically

Discussion in 'Android Help' started by surface view, Dec 8, 2014.

  1. surface view

    surface view Guest
    Thread Starter
    Rank:
    None
    Posts:
    0
    Joined:

    i created surface view to rendering the h264 data as making video using RTSP without using default player for playing video .Now am programmatically takeup the snap shot for surface view that shows black screen for surface view content only, but shows root view content of surface view . But android default screen shot is fine .How to solve this problem on surface view ,please anyone provide solution.

    example:
    mFrameRenderingLayout.addView(mSurfaceView); // add the surface view to framelayout
    View v1 =mSurfaceView.getRootView(); // represent rootview of surface view ie. mFrameRenderingLayout
    v1.setDrawingCacheEnabled(true);
    v1.buildDrawingCache();
    (or)
    mSurfaceView.setDrawingCacheEnabled(true);
    mSurfaceView.buildDrawingCache();

    File mFile;
    BitMap mBitmapTemp;
    String root = Environment.getExternalStorageDirectory() // Create path
    .getAbsolutePath() + "/pictures";

    Calendar newCalendar = Calendar.getInstance();
    Date dt = newCalendar.getTime();
    String tmp = mSDFFileformat.format(dt) + ".PNG"; // create file name
    mFile = new File(root, tmp);
    mBitmapTemp = Bitmap.createBitmap(v1
    .getDrawingCache()); // get the drawing cache of surface view
    v1.setDrawingCacheEnabled(false);
    (or)
    mBitmapTemp = Bitmap.createBitmap(v1
    .getDrawingCache()); // get the drawing cache of surface view
    mSurfaceView.setDrawingCacheEnabled(false);

    FileOutputStream fos = null;
    fos = new FileOutputStream(mFile);
    if (fos != null) {
    mBitmapTemp.compress(Bitmap.CompressFormat.PNG, 100,
    fos); // compress the bitmap
    fos.flush();
    fos.close();


    Finaly this code return black screen for surface view content only
     

    Advertisement

Share This Page

Loading...