如何将图像合并到视频缩略图的中心?
我创建了一个媒体播放器,它对我来说工作得很好。媒体播放器显示视频缩略图的数量。我需要在视频缩略图中心添加一个播放按钮,因此我添加了一张图像(播放按钮)。它显示视频缩略图右侧角,我希望创建中心...我不知道如何更改...请帮助我...
我的工作源代码:-
private Bitmap getImage(int id) {
Bitmap thumb = MediaStore.Video.Thumbnails.getThumbnail(getContentResolver(),id,
MediaStore.Video.Thumbnails.MICRO_KIND, null);
System.out.println("ff"+MediaStore.Video.Thumbnails
.getThumbnail(getContentResolver(),id, MediaStore.Video.Thumbnails.MICRO_KIND, null));
Bitmap bmp2 = BitmapFactory.decodeResource(getResources(),
R.drawable.play1);
// canvas.drawColor(Color.BLACK);
// canvas.drawBitmap(_scratch, 10, 10, null);
Bitmap bmOverlay = Bitmap.createBitmap(thumb.getWidth(), thumb
.getHeight(), thumb.getConfig());
// Canvas cs = new Canvas(bmp2);
Canvas canvas= new Canvas(bmOverlay);
canvas.scale((float) 1.0, (float) 1.0);
//canvas.scale((float) 1.0,(float) 1.0,(float) 0.1,(float) 0.1);
//canvas.skew((float)0.5,(float)0.5);
//canvas.drawBitmap(bmp2, 0f, 0f, null);
canvas.drawBitmap(thumb, new Matrix(), null);
canvas.drawBitmap(bmp2, new Matrix(), null);
canvas.save();
return bmOverlay;
}
I created one media player, it's working fine for me. The media player display number of video thumbnails. I need one play button in center of the videothumbnails so, I added one image(play button). It's display videothumbnails right side corner, i wish to create center...i don't know how to change....please help me.....
my working source code:-
private Bitmap getImage(int id) {
Bitmap thumb = MediaStore.Video.Thumbnails.getThumbnail(getContentResolver(),id,
MediaStore.Video.Thumbnails.MICRO_KIND, null);
System.out.println("ff"+MediaStore.Video.Thumbnails
.getThumbnail(getContentResolver(),id, MediaStore.Video.Thumbnails.MICRO_KIND, null));
Bitmap bmp2 = BitmapFactory.decodeResource(getResources(),
R.drawable.play1);
// canvas.drawColor(Color.BLACK);
// canvas.drawBitmap(_scratch, 10, 10, null);
Bitmap bmOverlay = Bitmap.createBitmap(thumb.getWidth(), thumb
.getHeight(), thumb.getConfig());
// Canvas cs = new Canvas(bmp2);
Canvas canvas= new Canvas(bmOverlay);
canvas.scale((float) 1.0, (float) 1.0);
//canvas.scale((float) 1.0,(float) 1.0,(float) 0.1,(float) 0.1);
//canvas.skew((float)0.5,(float)0.5);
//canvas.drawBitmap(bmp2, 0f, 0f, null);
canvas.drawBitmap(thumb, new Matrix(), null);
canvas.drawBitmap(bmp2, new Matrix(), null);
canvas.save();
return bmOverlay;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
找到了这个问题的答案。
在绘制第二个位图时,我们可以使用
插入的
这个 30,30 是宽度和高度。你可以放任何你喜欢的东西。
Found the answer for this.
while drawing second bitmap we can use
inseted of
This 30,30 is Width and Height. you can put whatever you like.