本文整理汇总了Java中android.graphics.Picture.draw方法的典型用法代码示例。如果您正苦于以下问题:Java Picture.draw方法的具体用法?Java Picture.draw怎么用?Java Picture.draw使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.graphics.Picture
的用法示例。
在下文中一共展示了Picture.draw方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: captureWebViewall
import android.graphics.Picture; //导入方法依赖的package包/类
private Bitmap captureWebViewall(WebView webView) {
Picture snapShot = webView.capturePicture();
Bitmap bmp = Bitmap.createBitmap(snapShot.getWidth(),
snapShot.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bmp);
snapShot.draw(canvas);
return bmp;
}
示例2: onLoadBitmap
import android.graphics.Picture; //导入方法依赖的package包/类
@Override
public Bitmap onLoadBitmap(final Config pBitmapConfig) {
final Picture picture = this.mPicture;
if (picture == null) {
Debug.e("Failed loading Bitmap in " + this.getClass().getSimpleName() + ".");
return null;
}
final Bitmap bitmap = Bitmap.createBitmap(this.mTextureWidth, this.mTextureHeight, pBitmapConfig);
final Canvas canvas = new Canvas(bitmap);
final float scaleX = (float)this.mTextureWidth / this.mPicture.getWidth();
final float scaleY = (float)this.mTextureHeight / this.mPicture.getHeight();
canvas.scale(scaleX, scaleY, 0, 0);
picture.draw(canvas);
return bitmap;
}
示例3: onLoadBitmap
import android.graphics.Picture; //导入方法依赖的package包/类
@Override
public Bitmap onLoadBitmap(final Config pBitmapConfig) {
final Picture picture = this.mPicture;
if(picture == null) {
Debug.e("Failed loading Bitmap in " + this.getClass().getSimpleName() + ".");
return null;
}
final Bitmap bitmap = Bitmap.createBitmap(this.mTextureWidth, this.mTextureHeight, pBitmapConfig);
final Canvas canvas = new Canvas(bitmap);
final float scaleX = (float)this.mTextureWidth / this.mPicture.getWidth();
final float scaleY = (float)this.mTextureHeight / this.mPicture.getHeight();
canvas.scale(scaleX, scaleY, 0, 0);
picture.draw(canvas);
return bitmap;
}
示例4: draw
import android.graphics.Picture; //导入方法依赖的package包/类
@Override
public void draw(Canvas canvas) {
canvas.drawCircle(mBounds.centerX(), mBounds.centerY(), mBounds.centerX(), mBackgroundPaint);
Picture picture = new Picture() ;
picture.draw(canvas);
canvas.save();
canvas.rotate(180 * mRotation, (x(0) + x(1))/2, (y(0) + y(1))/2);
canvas.drawLine(x(0), y(0), x(1), y(1), mLinePaint);
canvas.restore();
canvas.save();
canvas.rotate(180 * mRotation, (x(2) + x(3)) / 2, (y(2) + y(3)) / 2);
canvas.drawLine(x(2), y(2), x(3), y(3), mLinePaint);
canvas.restore();
canvas.save();
canvas.rotate(180 * mRotation, (x(4) + x(5)) / 2, (y(4) + y(5)) / 2);
canvas.drawLine(x(4), y(4), x(5), y(5), mLinePaint);
canvas.restore();
}
示例5: onLoadBitmap
import android.graphics.Picture; //导入方法依赖的package包/类
@Override
public Bitmap onLoadBitmap(final Config pBitmapConfig) {
final Picture picture = this.mPicture;
if(picture == null) {
Debug.e("Failed loading Bitmap in PictureTextureSource.");
return null;
}
final Bitmap bitmap = Bitmap.createBitmap(this.mWidth, this.mHeight, pBitmapConfig);
final Canvas canvas = new Canvas(bitmap);
final float scaleX = (float)this.mWidth / this.mPicture.getWidth();
final float scaleY = (float)this.mHeight / this.mPicture.getHeight();
canvas.scale(scaleX, scaleY, 0, 0);
picture.draw(canvas);
return bitmap;
}
示例6: genCaptureBitmap
import android.graphics.Picture; //导入方法依赖的package包/类
/**
* 截取所有网页内容到 Bitmap
*
* @return Bitmap
*/
Bitmap genCaptureBitmap() throws OutOfMemoryError {
// @todo Future versions of WebView may not support use on other threads.
try {
Picture picture = getWebView().capturePicture();
int height = picture.getHeight(), width = picture.getWidth();
if (height == 0 || width == 0) {
return null;
}
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
picture.draw(canvas);
return bitmap;
} catch (NullPointerException e) {
return null;
}
}
示例7: onClick
import android.graphics.Picture; //导入方法依赖的package包/类
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.button:
String time = Tools.getCurrentTime();
String version = Tools.getVersion(mContext);
String name = Tools.getName(mContext);
String currentUrl = mWebView.getUrl();
String info = "Application Info: \n\n version: " + version
+ "\n name: " + name
+ "\n curTime: " + time
+ "\n curUrl: " + currentUrl;
mWebView.loadUrl("javascript:showAlert('" + info + "')");
break;
case R.id.save:
Picture snapShot = mWebView.capturePicture();
Bitmap bmp = Bitmap.createBitmap(snapShot.getWidth(), snapShot.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bmp);
snapShot.draw(canvas);
if (!TextUtils.isEmpty(FileUtil.savaBitmap2SDcard(mContext, bmp, "1111"))) {
T.showSToast(mContext, "success");
}
break;
default:
break;
}
}
示例8: getScreenView
import android.graphics.Picture; //导入方法依赖的package包/类
public Bitmap getScreenView(){
Picture snapShot = webView.capturePicture();
Bitmap bmp = Bitmap.createBitmap(snapShot.getWidth(),snapShot.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bmp);
snapShot.draw(canvas);
return bmp;
}
示例9: getBitmapOfWebView
import android.graphics.Picture; //导入方法依赖的package包/类
/**
* Returns a bitmap of a given WebView.
*
* @param webView the webView to save a bitmap from
* @return a bitmap of the given web view
*
*/
private Bitmap getBitmapOfWebView(final WebView webView){
Picture picture = webView.capturePicture();
Bitmap b = Bitmap.createBitmap( picture.getWidth(), picture.getHeight(), Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(b);
picture.draw(c);
return b;
}
示例10: getBitmapFromWebView
import android.graphics.Picture; //导入方法依赖的package包/类
private Bitmap getBitmapFromWebView(WebView webView) {
try {
float scale = 1.0f / getResources().getDisplayMetrics().density;
Picture picture = webView.capturePicture();
Bitmap bitmap = Bitmap.createBitmap((int) (picture.getWidth() * scale), (int) (picture.getHeight() * scale), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
canvas.scale(scale, scale);
picture.draw(canvas);
return bitmap;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
示例11: takeScreenshot
import android.graphics.Picture; //导入方法依赖的package包/类
private Bitmap takeScreenshot (WebView page) {
Picture picture = page.capturePicture();
Bitmap bitmap = Bitmap.createBitmap(picture.getWidth(), picture.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
picture.draw(canvas);
return bitmap;
}
示例12: getDrawable
import android.graphics.Picture; //导入方法依赖的package包/类
@Override
public Drawable getDrawable(final InputStream aFileInputStream) {
// try {
// default implementation will load the file as a bitmap and create
// a BitmapDrawable from it
// Log.d(TAG, "Get Drawable Vector");
SVG svg = SVGParser.getSVGFromInputStream(aFileInputStream);
Picture pic = svg.getPicture();
Bitmap bm = Bitmap.createBitmap(pic.getWidth(), pic.getHeight(), Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(bm);
pic.draw(c);
return new BitmapDrawable(bm);
// return bm;
// Log.d(TAG, "SVG is create");
// try {
// PictureDrawable draw = svg.createPictureDrawable();
// Log.d(TAG, "Get Drawable Vector : " + draw.getBounds());
// return draw;
// } catch (java.lang.UnsupportedOperationException e) {
// Log.e(TAG, e.getMessage());
// return null;
// }
// final Bitmap bitmap = BitmapFactory.decodeStream(aFileInputStream);
// if (bitmap != null) {
// return new ExpirableBitmapDrawable(bitmap);
// }
// } catch (final OutOfMemoryError e) {
// logger.error("OutOfMemoryError loading bitmap");
// System.gc();
// throw new LowMemoryException(e);
// }
// return null;
}
示例13: convertPictureToBitmap
import android.graphics.Picture; //导入方法依赖的package包/类
public static Bitmap convertPictureToBitmap(Picture mCompassRose) {
Bitmap bm = Bitmap.createBitmap(mCompassRose.getWidth(), mCompassRose.getHeight(), Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(bm);
mCompassRose.draw(c);
return bm;
}