ImageModelpublic class ImageModel extends RegionMediaModel
Fields Summary |
---|
private static final String | TAG | private static final boolean | DEBUG | private static final boolean | LOCAL_LOGV | private static final int | THUMBNAIL_BOUNDS_LIMIT | private int | mWidth | private int | mHeight | private SoftReference | mBitmapCache |
Constructors Summary |
---|
public ImageModel(android.content.Context context, android.net.Uri uri, RegionModel region)
super(context, SmilHelper.ELEMENT_TAG_IMAGE, uri, region);
initModelFromUri(uri);
checkContentRestriction();
| public ImageModel(android.content.Context context, String contentType, String src, android.net.Uri uri, RegionModel region)
super(context, SmilHelper.ELEMENT_TAG_IMAGE,
contentType, src, uri, region);
decodeImageBounds();
| public ImageModel(android.content.Context context, String contentType, String src, com.android.mms.drm.DrmWrapper wrapper, RegionModel regionModel)
super(context, SmilHelper.ELEMENT_TAG_IMAGE, contentType, src,
wrapper, regionModel);
|
Methods Summary |
---|
protected void | checkContentRestriction()
ContentRestriction cr = ContentRestrictionFactory.getContentRestriction();
cr.checkImageContentType(mContentType);
cr.checkResolution(mWidth, mHeight);
| private android.graphics.Bitmap | createThumbnailBitmap(int thumbnailBoundsLimit, android.net.Uri uri)
int outWidth = mWidth;
int outHeight = mHeight;
int s = 1;
while ((outWidth / s > thumbnailBoundsLimit)
|| (outHeight / s > thumbnailBoundsLimit)) {
s *= 2;
}
if (LOCAL_LOGV) {
Log.v(TAG, "outWidth=" + outWidth / s
+ " outHeight=" + outHeight / s);
}
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = s;
InputStream input = null;
try {
input = mContext.getContentResolver().openInputStream(uri);
return BitmapFactory.decodeStream(input, null, options);
} catch (FileNotFoundException e) {
Log.e(TAG, e.getMessage(), e);
return null;
} finally {
if (input != null) {
try {
input.close();
} catch (IOException e) {
Log.e(TAG, e.getMessage(), e);
}
}
}
| private void | decodeImageBounds()
UriImage uriImage = new UriImage(mContext, getUriWithDrmCheck());
mWidth = uriImage.getWidth();
mHeight = uriImage.getHeight();
if (LOCAL_LOGV) {
Log.v(TAG, "Image bounds: " + mWidth + "x" + mHeight);
}
| public android.graphics.Bitmap | getBitmap()
Bitmap bm = mBitmapCache.get();
if (bm == null) {
bm = createThumbnailBitmap(THUMBNAIL_BOUNDS_LIMIT, getUri());
mBitmapCache = new SoftReference<Bitmap>(bm);
}
return bm;
| public android.graphics.Bitmap | getBitmapWithDrmCheck()
Bitmap bm = mBitmapCache.get();
if (bm == null) {
bm = createThumbnailBitmap(THUMBNAIL_BOUNDS_LIMIT, getUriWithDrmCheck());
mBitmapCache = new SoftReference<Bitmap>(bm);
}
return bm;
| public int | getHeight()
return mHeight;
| public int | getWidth()
return mWidth;
| public void | handleEvent(org.w3c.dom.events.Event evt)
if (evt.getType().equals(SmilMediaElementImpl.SMIL_MEDIA_START_EVENT)) {
mVisible = true;
} else if (mFill != ElementTime.FILL_FREEZE) {
mVisible = false;
}
notifyModelChanged(false);
| private void | initModelFromUri(android.net.Uri uri)
UriImage uriImage = new UriImage(mContext, uri);
mContentType = uriImage.getContentType();
if (TextUtils.isEmpty(mContentType)) {
throw new MmsException("Type of media is unknown.");
}
mSrc = uriImage.getSrc();
mWidth = uriImage.getWidth();
mHeight = uriImage.getHeight();
if (LOCAL_LOGV) {
Log.v(TAG, "New ImageModel created:"
+ " mSrc=" + mSrc
+ " mContentType=" + mContentType
+ " mUri=" + uri);
}
|
|