借鉴与原始尺寸的帆布位图 [英] draw bitmap on canvas with original dimension
本文介绍了借鉴与原始尺寸的帆布位图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我动用我的画布上的位图,但它与原尺寸显示
i draw a bitmap on my canvas , but it's not display with the original size
http://upload.dinhosting.fr/A/e/3/ Sans_titre.png
这是我的code:
ImageView image = (ImageView) findViewById(R.id.imageView);
Bitmap bmp1 = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
Bitmap bmp = Bitmap.createBitmap(320, 382, Bitmap.Config.ARGB_8888);
SVG svg = SVGParser.getSVGFromResource(getResources(), R.raw.carte);
Canvas canv = new Canvas(bmp);
canv.drawBitmap(bmp1,10,10,null);
Drawable[] layers = new Drawable[2];
layers[0] = svg.createPictureDrawable();
BitmapDrawable drawable = new BitmapDrawable(getResources(), bmp);
layers[1] = drawable;
LayerDrawable layerDrawable = new LayerDrawable(layers);
image.setImageDrawable(layerDrawable);
日Thnx
推荐答案
如果你使用的是这样的:
And if you use something like this:
Bitmap resizedbitmap = Bitmap.createScaledBitmap(bmp1, image.getWidth(), image.getHeight(), true);
您可以得到高和本宽:结果
http://stackoverflow.com/a/9655670/1748764
You can get the height and width with this:
http://stackoverflow.com/a/9655670/1748764
或
<一个href=\"http://developer.android.com/reference/android/graphics/drawable/BitmapDrawable.html#getIntrinsicWidth%28%29\"相对=nofollow> getIntrinsicWidth
<一个href=\"http://developer.android.com/reference/android/graphics/drawable/BitmapDrawable.html#getIntrinsicHeight%28%29\"相对=nofollow> getIntrinsicHeight
这篇关于借鉴与原始尺寸的帆布位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文