/**
* Set the Background bitmap
*
* @param inputStream InputStream to the raw data of the bitmap
*/
public void setBitmap(InputStream inputStream) throws IOException {
FlushedInputStream fixedInput = new FlushedInputStream(inputStream);
BitmapFactory.Options opt = new BitmapFactory.Options();
decoder = BitmapRegionDecoder.newInstance(fixedInput, false);
fixedInput.reset();
// Grab the bounds of the background bitmap
opt.inPreferredConfig = DEFAULT_CONFIG;
opt.inJustDecodeBounds = true;
GameLog.d(TAG, "Decode inputStream for Background Bitmap");
BitmapFactory.decodeStream(fixedInput, null, opt);
fixedInput.reset();
backgroundSize.set(opt.outWidth, opt.outHeight);
GameLog.d(TAG, "Background Image: w=" + opt.outWidth + " h=" + opt.outHeight);
// Create the low resolution background
opt.inJustDecodeBounds = false;
opt.inSampleSize = 1 << sampleSize;
lowResBitmap = BitmapFactory.decodeStream(fixedInput, null, opt);
GameLog.d(TAG, "Low Res Image: w=" + lowResBitmap.getWidth() + " h=" + lowResBitmap.getHeight());
// Initialize cache
if (cachedBitmap.getState() == CacheState.NOT_INITIALIZED) {
synchronized (cachedBitmap) {
cachedBitmap.setState(CacheState.IS_INITIALIZED);
}
}
}
BitmapSurfaceRenderer.java 文件源码
java
阅读 128
收藏 0
点赞 0
评论 0
项目:lib_game
作者:
评论列表
文章目录