Android take screen shot programmatically

Here you go…I used this: View v = view.getRootView(); v.setDrawingCacheEnabled(true); Bitmap b = v.getDrawingCache(); String extr = Environment.getExternalStorageDirectory().toString(); File myPath = new File(extr, getString(R.string.free_tiket)+”.jpg”); FileOutputStream fos = null; try { fos = new FileOutputStream(myPath); b.compress(Bitmap.CompressFormat.JPEG, 100, fos); fos.flush(); fos.close(); MediaStore.Images.Media.insertImage( getContentResolver(), b, “Screen”, “screen”); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); … Read more

Android Tile Bitmap

You would do this in the xml instead of the java code. I haven’t attempted this myself but I did find this example. <xml version=”1.0″ encoding=”utf-8″?> <LinearLayout android:id=”@+id/MainLayout” xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”fill_parent” android:layout_height=”fill_parent” android:orientation=”vertical” android:background=”@drawable/backrepeat” > then in an xml called backrepeat.xml <bitmap xmlns:android=”http://schemas.android.com/apk/res/android” android:src=”https://stackoverflow.com/questions/1311042/@drawable/back” android:tileMode=”repeat” /> reference

What is the fastest way I can compare two equal-size bitmaps to determine whether they are identical?

Edit 8-31-12: per Joey’s comment below, be mindful of the format of the bitmaps you compare. They may contain padding on the strides that render the bitmaps unequal, despite being equivalent pixel-wise. See this question for more details. Reading this answer to a question regarding comparing byte arrays has yielded a MUCH FASTER method: using … Read more

Fast work with Bitmaps in C#

You can do it a couple of different ways. You can use unsafe to get direct access to the data, or you can use marshaling to copy the data back and forth. The unsafe code is faster, but marshaling doesn’t require unsafe code. Here’s a performance comparison I did a while back. Here’s a complete … Read more

Save bitmap to file function

You need an appropriate permission in manifest.xml: <uses-permission android:name=”android.permission.WRITE_EXTERNAL_STORAGE”/> out.flush() check the out is not null.. String file_path = Environment.getExternalStorageDirectory().getAbsolutePath() + “/PhysicsSketchpad”; File dir = new File(file_path); if(!dir.exists()) dir.mkdirs(); File file = new File(dir, “sketchpad” + pad.t_id + “.png”); FileOutputStream fOut = new FileOutputStream(file); bmp.compress(Bitmap.CompressFormat.PNG, 85, fOut); fOut.flush(); fOut.close();

Save and retrieve image (binary) from SQL Server using Entity Framework 6

Convert the image to a byte[] and store that in the database. Add this column to your model: public byte[] Content { get; set; } Then convert your image to a byte array and store that like you would any other data: public byte[] ImageToByteArray(System.Drawing.Image imageIn) { using(var ms = new MemoryStream()) { imageIn.Save(ms, System.Drawing.Imaging.ImageFormat.Gif); … Read more

MAT (Eclipse Memory Analyzer) – how to view bitmaps from memory dump

I have found a way to view such bitmaps: First, you need to download and install GIMP Next, find your Bitmap object in MAT, right-click on mBuffer field, in the popup menu choose “Copy” -> “Save Value To File” menu item and save value of this array to some file give extension .data to that … Read more

How to save a bitmap on internal storage

To Save your bitmap in sdcard use the following code Store Image private void storeImage(Bitmap image) { File pictureFile = getOutputMediaFile(); if (pictureFile == null) { Log.d(TAG, “Error creating media file, check storage permissions: “);// e.getMessage()); return; } try { FileOutputStream fos = new FileOutputStream(pictureFile); image.compress(Bitmap.CompressFormat.PNG, 90, fos); fos.close(); } catch (FileNotFoundException e) { Log.d(TAG, … Read more