本文整理匯總了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;
}