How to draw text On image?

As suggested by Vladislav Skoumal, try this method: public Bitmap drawTextToBitmap(Context mContext, int resourceId, String mText) { try { Resources resources = mContext.getResources(); float scale = resources.getDisplayMetrics().density; Bitmap bitmap = BitmapFactory.decodeResource(resources, resourceId); android.graphics.Bitmap.Config bitmapConfig = bitmap.getConfig(); // set default bitmap config if none if(bitmapConfig == null) { bitmapConfig = android.graphics.Bitmap.Config.ARGB_8888; } // resource bitmaps are … 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

How to make a browser display a “save as dialog” so the user can save the content of a string to a file on his system?

In case anyone is still wondering… I did it like this: <a href=”data:application/xml;charset=utf-8,your code here” download=”filename.html”>Save</a> can’t remember my source but it uses the following techniques\features: html5 download attribute data URI’s Found the reference: http://paxcel.net/blog/savedownload-file-using-html5-javascript-the-download-attribute-2/ EDIT: As you can gather from the comments, this does NOT work in Internet Explorer (however works in Edge v13 … Read more

Storing Python dictionaries

Pickle save: try: import cPickle as pickle except ImportError: # Python 3.x import pickle with open(‘data.p’, ‘wb’) as fp: pickle.dump(data, fp, protocol=pickle.HIGHEST_PROTOCOL) See the pickle module documentation for additional information regarding the protocol argument. Pickle load: with open(‘data.p’, ‘rb’) as fp: data = pickle.load(fp) JSON save: import json with open(‘data.json’, ‘w’) as fp: json.dump(data, fp) … Read more

Image, saved to sdcard, doesn’t appear in Android’s Gallery app

A simpler solution is to use the static convenience method scanFile(): File imageFile = … MediaScannerConnection.scanFile(this, new String[] { imageFile.getPath() }, new String[] { “image/jpeg” }, null); where this is your activity (or whatever context), the mime-type is only necessary if you are using non-standard file extensions and the null is for the optional callback … Read more

How to save all the variables in the current python session?

If you use shelve, you do not have to remember the order in which the objects are pickled, since shelve gives you a dictionary-like object: To shelve your work: import shelve T=’Hiya’ val=[1,2,3] filename=”/tmp/shelve.out” my_shelf = shelve.open(filename,’n’) # ‘n’ for new for key in dir(): try: my_shelf[key] = globals()[key] except TypeError: # # __builtins__, my_shelf, … Read more

Basic http file downloading and saving to disk in python?

A clean way to download a file is: import urllib testfile = urllib.URLopener() testfile.retrieve(“http://randomsite.com/file.gz”, “file.gz”) This downloads a file from a website and names it file.gz. This is one of my favorite solutions, from Downloading a picture via urllib and python. This example uses the urllib library, and it will directly retrieve the file form … Read more

Save An Image To Application Documents Folder From UIView On IOS

It’s all good, man. Don’t harm yourself or others. You probably don’t want to store these images in Core Data, since that can impact performance if the data set grows too large. Better to write the images to files. NSData *pngData = UIImagePNGRepresentation(image); This pulls out PNG data of the image you’ve captured. From here, … Read more