Programmatically Screenshot | Swift 3, macOS

Yes its possible. This function takes all connected monitors screenshots and writes to specified path as jpg file. Generates file name as unix time stamp. func TakeScreensShots(folderName: String){ var displayCount: UInt32 = 0; var result = CGGetActiveDisplayList(0, nil, &displayCount) if (result != CGError.success) { print(“error: \(result)”) return } let allocated = Int(displayCount) let activeDisplays = … Read more

view.getDrawingCache() is deprecated in Android API 28

Two ways to get bitmap of view Using Canvas Using Pixel Api Canvas Java Bitmap getBitmapFromView(View view) { Bitmap bitmap = Bitmap.createBitmap( view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888 ); Canvas canvas = new Canvas(bitmap); view.draw(canvas); return bitmap; } Bitmap getBitmapFromView(View view,int defaultColor) { Bitmap bitmap = Bitmap.createBitmap( view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888 ); Canvas canvas = new Canvas(bitmap); canvas.drawColor(defaultColor); view.draw(canvas); … Read more

How can I take a screenshot and save it as JPEG on Windows?

OK, after a lot of effort here’s the answer: int SaveJpeg(HBITMAP hBmp, LPCWSTR lpszFilename, ULONG uQuality) { ULONG *pBitmap = NULL; CLSID imageCLSID; EncoderParameters encoderParams; int iRes = 0; typedef Status (WINAPI *pGdipCreateBitmapFromHBITMAP)(HBITMAP, HPALETTE, ULONG**); pGdipCreateBitmapFromHBITMAP lGdipCreateBitmapFromHBITMAP; typedef Status (WINAPI *pGdipSaveImageToFile)(ULONG *, const WCHAR*, const CLSID*, const EncoderParameters*); pGdipSaveImageToFile lGdipSaveImageToFile; // load GdipCreateBitmapFromHBITMAP lGdipCreateBitmapFromHBITMAP = … Read more

Disable Screen Capture/ScreenShot in React Native App

Android Inside /android/app/src/main/java/com/{Project_Name}/MainActivity.java you may add the following lines. Prevent capture screen by setFlag FLAG_SECURE, use code below as an example: import android.os.Bundle; import android.view.WindowManager; … @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE); } later when you want to remove secure flag getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SECURE); iOS overlay screen in AppDelegate.m, take this example: – (void)applicationWillResignActive:(UIApplication … Read more

How to take a screenshot and share it programmatically

Try this for taking screenshot of current Activity: Android 2.2 : private static Bitmap takeScreenShot(Activity activity) { View view = activity.getWindow().getDecorView(); view.setDrawingCacheEnabled(true); view.buildDrawingCache(); Bitmap b1 = view.getDrawingCache(); Rect frame = new Rect(); activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(frame); int statusBarHeight = frame.top; DisplayMetrics displaymetrics = new DisplayMetrics(); mContext.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); int width = displaymetrics.widthPixels; int height = displaymetrics.heightPixels; Bitmap b = Bitmap.createBitmap(b1, … Read more

How can I programmatically take a screenshot of a webview, capturing the full page?

Try this one import java.io.FileOutputStream; import android.app.Activity; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Picture; import android.os.Bundle; import android.view.Menu; import android.webkit.WebView; import android.webkit.WebViewClient; public class MainActivity extends Activity { WebView w; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); w = new WebView(this); w.setWebViewClient(new WebViewClient() { public void onPageFinished(WebView view, String url) { Picture picture = view.capturePicture(); Bitmap … Read more

Take a full page screenshot with Firefox on the command-line

The Developer Toolbar GCLI and Shift+F2 shortcut were removed in Firefox version 60. To take a screenshot in 60 or newer: press Ctrl+Shift+K to open the developer console (⌥ Option+⌘ Command+K on macOS) type :screenshot or :screenshot –fullpage Find out more regarding screenshots and other features For Firefox versions < 60: Press Shift+F2 or go … Read more