Files
android/proprietary/samplePlayer/src/com/widevine/demo/ImageHandler.java
Gloria Wang fc6f6134e9 Widevine sample player
For bug 4245169

Change-Id: Ie110d5603f19cd54878d2c4506e8ffad11207f10
2011-04-07 09:35:25 -07:00

57 lines
1.3 KiB
Java

/*
* (c)Copyright 2011 Widevine Technologies, Inc
*/
package com.widevine.demo;
import java.io.IOException;
import java.net.MalformedURLException;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
public class ImageHandler extends Thread {
private boolean scale;
private String imageUrl;
private Bitmap clipImage = null;
public ImageHandler(String imageUrl) {
this.imageUrl = imageUrl;
this.clipImage = null;
}
public void setScale(boolean scale) {
this.scale = scale;
}
public void run() {
try {
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpGet request = new HttpGet(imageUrl);
HttpResponse response = httpClient.execute(request);
this.clipImage = BitmapFactory.decodeStream(response.getEntity().getContent());
if (scale) {
this.clipImage = Bitmap.createScaledBitmap(this.clipImage, 150, 200, false);
}
} catch (MalformedURLException e) {
this.clipImage = null;
} catch (IOException e) {
this.clipImage = null;
}
}
public Bitmap getBitmap() {
return this.clipImage;
}
}