Drawable createFromStream - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Drawable createFromStream method.

This code example shows how to use the following methods:createFromStream, close, read
			java.io.File newFile=new java.io.File(SDFile.getAbsolutePath()+java.io.File.separatorChar+"bbs"+
					java.io.File.separatorChar+"image"+java.io.File.separatorChar+fileName) ;
 
			if(newFile.exists()){
 
				FileInputStream inputStream = new FileInputStream(newFile);
				 byte[] buffer = new byte[1024];
                 inputStream.read(buffer);
                 Drawable d= Drawable.createFromStream(inputStream, fileName);
                 inputStream.close();
				 return d;
			}	 
		} 
		return null; 
 
	} 
 
	/** 
	 * 从SDCard中读取文件 
	 * @param fileName 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:createFromStream
        assertEquals("Bitmap for resource:drawable/an_image", shadowOf(canvas).getDescription());
    } 
 
    @Test
    public void shouldInheritSourceStringFromDrawableDotCreateFromStream() throws Exception {
        InputStream emptyInputStream = new ByteArrayInputStream("".getBytes());
        BitmapDrawable drawable = (BitmapDrawable) Drawable.createFromStream(emptyInputStream, "source string value");
        assertEquals("source string value", shadowOf(drawable).getSource());
    } 
 
    @Test
    public void withColorFilterSet_draw_shouldCopyDescriptionToCanvas() throws Exception {
        BitmapDrawable drawable = (BitmapDrawable) resources.getDrawable(R.drawable.an_image);
        drawable.setColorFilter(new ColorMatrixColorFilter(new ColorMatrix()));
        Canvas canvas = new Canvas();
        drawable.draw(canvas);
 
        assertEquals("Bitmap for resource:drawable/an_image with ColorMatrixColorFilter<1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0>", 
                shadowOf(canvas).getDescription());
    } 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:createFromStream
	 * @param byteArray 
	 * @return 
	 */ 
	public static Drawable byteToDrawable(byte[] byteArray) {
		if (byteArray != null && byteArray.length > 0) {
			ByteArrayInputStream ins = new ByteArrayInputStream(byteArray);
			return Drawable.createFromStream(ins, null);
		}else { 
			return null; 
		} 
		 
	} 
 
	/** 
	 * Bitmap convert to bytes 
	 *  
	 * @param byteArray 
	 * @return 
	 */ 
	public static byte[] bitmapToBytes(Bitmap bm) {
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:createFromStream, close
     * @return 
     */ 
    public static Drawable getDrawableFromUrl(String imageUrl, int readTimeOutMillis,
                                              Map<String, String> requestProperties) {
        InputStream stream = getInputStreamFromUrl(imageUrl, readTimeOutMillis, requestProperties);
        Drawable d = Drawable.createFromStream(stream, "src");
        closeInputStream(stream);
        return d;
    } 
 
    /** 
     * get Bitmap by imageUrl 
     *  
     * @param imageUrl 
     * @param readTimeOut 
     * @return 
     * @see ImageUtils#getBitmapFromUrl(String, int, boolean) 
     */ 
    public static Bitmap getBitmapFromUrl(String imageUrl, int readTimeOut) {
        return getBitmapFromUrl(imageUrl, readTimeOut, null);

5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:createFromStream
		try { 
			vCard.load(mConn, mJid);
			byte[] avatarBytes = vCard.getAvatar();
			if (avatarBytes != null) {
				ByteArrayInputStream bais = 
					new ByteArrayInputStream(avatarBytes);
				d = Drawable.createFromStream(bais, "src");
			} 
		} catch (XMPPException e) {
			Log.e(TAG, "Failed to load avatar for " + mJid, e);
		} 
		return d;
	} 
 
	@Override 
	public String getKey() {
		return this.getClass().getName() + ":" + mJid;
	} 
 
} 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:createFromStream
		bitmap.compress(Bitmap.CompressFormat.PNG, 100, baos);
		return baos.toByteArray();
	} 
	 
	public static Drawable bitmap2Drawable(Bitmap bitmap){
		InputStream is = new ByteArrayInputStream(Bitmap2Bytes(bitmap));
		return Drawable.createFromStream(is, "src");
	} 
	 
	 
	 
} 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:createFromStream
  } 
 
  public boolean thumbnail(int size) {
    Drawable image;
    try { 
      image = Drawable.createFromStream(
          new FileInputStream(this.getImageFile()), "src");
    } catch (FileNotFoundException e) {
      // TODO Auto-generated catch block 
      e.printStackTrace();
      return false; 
    } 
 
    if (image == null) {
      return false; 
    } 
 
    Bitmap bitmapOrg = ((BitmapDrawable) image).getBitmap();
 
    if (bitmapOrg == null) {
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:createFromStream
            return null;  
        }   
	} 
	 
	public static Drawable byteToDrawable(byte[] byteArray){
		ByteArrayInputStream ins = new ByteArrayInputStream(byteArray);
		return Drawable.createFromStream(ins, null);
	} 
	 
	//��byteArray�õ�Drawable 
	public static Drawable byteToRoundDrawable(byte [] byteArray,int pixel)
	{ 
	   Bitmap bitmap = byteToBitmap(byteArray);
	   Bitmap roundMap = toRoundCorner(bitmap,pixel);
	   return new BitmapDrawable(roundMap);
	} 
	 
	public static byte[] Bitmap2Bytes(Bitmap bm){ 
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		bm.compress(Bitmap.CompressFormat.PNG, 100, baos);
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:createFromStream
            return null;  
        }   
	} 
	 
	public static Drawable byteToDrawable(byte[] byteArray){
		ByteArrayInputStream ins = new ByteArrayInputStream(byteArray);
		return Drawable.createFromStream(ins, null);
	} 
	 
	public static byte[] Bitmap2Bytes(Bitmap bm){ 
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		bm.compress(Bitmap.CompressFormat.PNG, 100, baos);
		return baos.toByteArray();
	} 
	 
	public static Bitmap drawableToBitmap(Drawable drawable) {
 
		Bitmap bitmap = Bitmap
				.createBitmap(
						drawable.getIntrinsicWidth(),
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:createFromStream
	 * @return 
	 */ 
	public static Drawable byteToDrawable(byte[] byteArray) {
		ByteArrayInputStream ins = null;
		if (byteArray != null) {
			ins = new ByteArrayInputStream(byteArray);
		} 
		return Drawable.createFromStream(ins, null);
	} 
 
	/** 
	 * bitmap transfer to bytes 
	 *  
	 * @param byteArray 
	 * @return 
	 */ 
	public static byte[] bitmapToBytes(Bitmap bm) {
		byte[] bytes = null;
		if (bm != null) {
			ByteArrayOutputStream baos = new ByteArrayOutputStream();
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java

Related Drawable createFromStream Questions & Answers:

createFromStream Method Overview
Create a drawable from an inputstream
See Code Examples for other Android Drawable Methods: