Code example for Bitmap

Methods: compressgetWidthhasAlpha

0
	public static TiBlob blobFromImage(Bitmap image)
	{ 
	 
		ByteArrayOutputStream bos = new ByteArrayOutputStream();
		byte data[] = new byte[0];
		if (image.hasAlpha()) {
			if (image.compress(CompressFormat.PNG, 100, bos)) {
				data = bos.toByteArray();
			} 
		} 
		else { 
			if (image.compress(CompressFormat.JPEG, 100, bos)) {
				data = bos.toByteArray();
			} 
		} 
 
		TiBlob blob = new TiBlob(TYPE_IMAGE, data, "image/bitmap");
		blob.image = image;
		blob.width = image.getWidth();
		blob.height = image.getHeight();
		return blob;
	} 
 
	/** 
Experience pair programming with AI  Get Codota for Java