Android, Drawable.createFromStream (is, srcname): what does the second parameter mean?

What is the meaning of the second parameter of the Drawable.createFromStream () method?

From the Android API, I only get:

public static Drawable createFromStream (InputStream is, String srcName) Create a drawable from an inputstream 

In all the examples I read, I see that they use the string "src": is this the name of the directory in which caching is cached, relative to my application root directory?

One parallel question: where should I find the Android source sources (for example, the Drawable.createFromStream () method ...) to avoid such stupid questions in the future?

+42
android drawable
May 25 '11 at 9:58 a.m.
source share
1 answer

This is basically useless :

Based on the source of Froyo , it is used when creating images with nine patches from a resource, but not when creating a regular raster image:

 852 private static Drawable drawableFromBitmap(Resources res, Bitmap bm, byte[] np, 853 Rect pad, String srcName) { 854 855 if (np != null) { 856 return new NinePatchDrawable(res, bm, np, pad, srcName); 857 } 858 859 return new BitmapDrawable(res, bm); 860 } 

You get there by following the schedule:

createFromStream returns:

 return createFromResourceStream(null, null, is, srcName, null); 

which, in turn, uses:

 return drawableFromBitmap(res, bm, np, pad, srcName); 

(np comes from Bitmap#getNinePatchChunk(); ) and this calls:

 return new NinePatchDrawable(res, bm, np, pad, srcName); 

Finally, you get into the NinePatch ad:

 public class NinePatch 

Create a stretch projection from a bitmap to nine patches.

Options

bitmap A bitmap describing patches.

chunk A 9-patch data block describing how the underlying bitmap is split and drawn.

srcName The source name for the bitmap. May be null .

+45
May 25 '11 at 15:58
source share



All Articles