public void buildBlocksFromImage(InputStream imageStream) {
this.originalImageInputStream = imageStream;
BitmapRegionDecoder brp = null;
try {
brp = BitmapRegionDecoder.newInstance(imageStream, false);
} catch (IOException e) {
e.printStackTrace();
}
for(int row = 0;row<this.rowCount;row++) {
for(int col=0;col<this.columnCount; col++) {
int left = col*subdivisionWidth, top = row*subdivisionWidth;
int right = left + subdivisionWidth, bottom = top + subdivisionWidth;
Bitmap region = brp.decodeRegion(new Rect(left, top, right, bottom), null);
RgbColor averageColor = calculateAverageColor(region);
Block bestBlock = Block.bestMatchedBlock(averageColor);
this.setBlockAtIndices(row, col, bestBlock);
}
}
return;
}
BlockBitmap.java 文件源码
java
阅读 15
收藏 0
点赞 0
评论 0
项目:HackISU
作者:
评论列表
文章目录