Android Bitmap.CompressFormat - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android Bitmap.CompressFormat class.

This code example shows how to use the following methods:ordinal
import android.graphics.BitmapFactory; 
import android.graphics.Bitmap.CompressFormat; 
import android.util.Log; 
 
@Kroll.module(name="ImageFactory", id="ti.imagefactory") 
public class ImageFactoryModule extends KrollModule 
{ 
	// Standard Debugging variables 
	private static final String LCAT = "ImageFactoryModule";
 
	// Transform constants defined to match iOS values 
	@Kroll.constant public static final int TRANSFORM_NONE = 0;
	@Kroll.constant public static final int TRANSFORM_CROP = 1;
	@Kroll.constant public static final int TRANSFORM_RESIZE = 2;
	@Kroll.constant public static final int TRANSFORM_THUMBNAIL = 3;
	@Kroll.constant public static final int TRANSFORM_ROUNDEDCORNER = 4;
	@Kroll.constant public static final int TRANSFORM_TRANSPARENTBORDER = 5;
	@Kroll.constant public static final int TRANSFORM_ALPHA = 6;
 
	// Quality constants defined to match iOS values 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:name
  /** 
   * @see Bitmap#compress(CompressFormat, int, OutputStream) 
   */ 
  public void setCompressFormat(final CompressFormat compressFormat) {
    this.compressFormat = compressFormat;
    setContentType("image/" + compressFormat.name().toLowerCase(Locale.US));
  } 
  /** 
   * @see Bitmap#compress(CompressFormat, int, OutputStream) 
   */ 
  public void setCompressQuality(final int compressQuality) {
    this.compressQuality = compressQuality;
  } 
 
  @Override 
  protected void sendData(final OutputStream out) throws IOException {
    if (compressFormat == null) { throw new IllegalStateException("Compress format is not set"); }
    bitmap.compress(compressFormat, compressQuality, out);
  } 
 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:toString
  public static final String         HTML_EXTENSION  = "html";
 
  public static final String         IMAGE_GIF_EXTENSION = "gif";
 
  public static final CompressFormat IMAGE_PNG_FORMAT    = CompressFormat.PNG;
  public static final String         IMAGE_PNG_EXTENSION = IMAGE_PNG_FORMAT.toString().toLowerCase();
  public static final int            IMAGE_PNG_QUALITY   = 100;
 
  public static final int            IO_BUFFER_SIZE  = 4 * 1024;
 
  public static String makeSerializeFile(String fileName, Object object)
    throws TLSDCardNotFoundException, FileNotFoundException, IOException 
  { 
    if (!isSDCardWriteble() || 
        !makeDirectory(new File(APP_DIR)) ||
        !makeDirectory(new File(DATA_DIR)))
    { 
      throw new TLSDCardNotFoundException(); 
    } 
    String filePath = DATA_DIR + fileName;
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:name
		thread = new Thread(runner);
	} 
	 
	private File getImageFile(String imageUrl) {
        String fileName = Integer.toHexString(imageUrl.hashCode()) + "."
                + compressedImageFormat.name();
        return new File(this.diskurl + "/" + fileName);
    }  
	private String getFullPath(String imageUrl){
		return this.diskurl + "/" + Integer.toHexString(imageUrl.hashCode()) + "."
        + compressedImageFormat.name();
	} 
	 
	public interface ImageLoadedListener { 
		public void imageLoaded(Bitmap imageBitmap );
	} 
	 
	private class QueueRunner implements Runnable {
		public void run() { 
			synchronized(this) { 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:name
		thread = new Thread(runner);
	} 
	 
	private File getImageFile(String imageUrl) {
        String fileName = Integer.toHexString(imageUrl.hashCode()) + "."
                + compressedImageFormat.name();
        return new File(this.diskurl + "/" + fileName);
    }  
	private String getFullPath(String imageUrl){
		return this.diskurl + "/" + Integer.toHexString(imageUrl.hashCode()) + "."
        + compressedImageFormat.name();
	} 
	 
	public interface ImageLoadedListener { 
		public void imageLoaded(Bitmap imageBitmap );
	} 
	 
	private class QueueRunner implements Runnable {
		public void run() { 
			synchronized(this) { 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:name
        return cache.values();
    } 
 
    private File getImageFile(String imageUrl) {
        String fileName = Integer.toHexString(imageUrl.hashCode()) + "."
                + compressedImageFormat.name();
        return new File(secondLevelCacheDir + "/" + fileName);
    } 
} 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:name
 
    @Override 
    public String getFileNameForKey(String imageUrl) {
        // TODO: is hashCode appropriate to avoid collisions? 
        // the key is the image URL 
        return Integer.toHexString(imageUrl.hashCode()) + "." + compressedImageFormat.name();
    } 
 
    @Override 
    protected Bitmap readValueFromDisk(File file) {
        return BitmapFactory.decodeFile(file.getAbsolutePath());
    } 
 
    @Override 
    protected void writeValueToDisk(BufferedOutputStream ostream, Bitmap value) {
        value.compress(compressedImageFormat, cachedImageQuality, ostream);
    } 
} 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:name
			sCurrentUri = Uri.fromFile(tempFile);
			 
			Log.d(TAG, "Creating temporary file for gallery image: " + sCurrentUri.toString());
			 
			intent.putExtra(MediaStore.EXTRA_OUTPUT, sCurrentUri);
			intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.name());
			 
			Log.d(TAG, "Requested gallery intent...");
			startActivityForResult(intent, REQUEST_CODE);
		} catch (IOException e) {
			setResult(RESULT_CANCELED);
			finish();
		} 
	} 
	 
	@Override 
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		super.onActivityResult(requestCode, resultCode, data);
		 
		if (requestCode == REQUEST_CODE) {
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:toString
		if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) {
			if (resultCode == Activity.RESULT_OK) {
				Bitmap bmp = (Bitmap) data.getExtras().get("data");
				ByteArrayOutputStream stream = new ByteArrayOutputStream();
				bmp.compress(Bitmap.CompressFormat.JPEG, 10, stream);
				photoType = CompressFormat.JPEG.toString().toLowerCase();
				byte[] byteArray = stream.toByteArray();
				encodedImage = Base64.encodeToString(byteArray, Base64.DEFAULT);
				Log.d("Act-lifecycle", encodedImage);
			} else if (resultCode == Activity.RESULT_CANCELED) {
				// User cancelled the image capture 
			} else { 
				// Image capture failed, advise user 
			} 
		} 
		finish();
	} 
 
	@Override 
	public boolean onOptionsItemSelected(MenuItem item) {
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Android Bitmap.CompressFormat Questions & Answers:

See Code Examples for Android Bitmap.CompressFormat Methods: