public boolean checkRenderView(WebView view)
{
if(state == null)
{
setBitmap(view);
return false;
}
else
{
Picture p = view.capturePicture();
Bitmap newState = Bitmap.createBitmap(p.getWidth(), p.getHeight(), Bitmap.Config.ARGB_8888);
boolean result = newState.equals(state);
newState.recycle();
return result;
}
}
java类android.graphics.Picture的实例源码
Purity.java 文件源码
项目:cordova-android-chromeview
阅读 17
收藏 0
点赞 0
评论 0
CompassPictureFactory.java 文件源码
项目:osmLib
阅读 16
收藏 0
点赞 0
评论 0
public static Picture createCompassRosePicture(final int mCompassRadius, final float displayDensity, final int northTriangleColor, final int southTriangleColor, final int dotMiddleColor) {
// Paint design of north triangle (it's common to paint north in red
// color)
final Paint northPaint = new Paint();
northPaint.setColor(northTriangleColor);
northPaint.setAntiAlias(true);
northPaint.setStyle(Style.FILL);
northPaint.setAlpha(220);
// Paint design of south triangle (black)
final Paint southPaint = new Paint();
southPaint.setColor(southTriangleColor);
southPaint.setAntiAlias(true);
southPaint.setStyle(Style.FILL);
southPaint.setAlpha(220);
// Create a little white dot in the middle of the compass rose
final Paint centerPaint = new Paint();
centerPaint.setColor(dotMiddleColor);
centerPaint.setAntiAlias(true);
centerPaint.setStyle(Style.FILL);
centerPaint.setAlpha(220);
// Create Compass
return createCompassRosePicture(mCompassRadius, displayDensity, northPaint, southPaint, centerPaint);
}
Purity.java 文件源码
项目:xface-android
阅读 19
收藏 0
点赞 0
评论 0
public boolean checkRenderView(WebView view)
{
if(state == null)
{
setBitmap(view);
return false;
}
else
{
Picture p = view.capturePicture();
Bitmap newState = Bitmap.createBitmap(p.getWidth(), p.getHeight(), Bitmap.Config.ARGB_8888);
boolean result = newState.equals(state);
newState.recycle();
return result;
}
}
DetailFragment.java 文件源码
项目:iZhihu
阅读 27
收藏 0
点赞 0
评论 0
/**
* 截取所有网页内容到 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;
}
}
PictureBitmapTextureAtlasSource.java 文件源码
项目:Killbots
阅读 17
收藏 0
点赞 0
评论 0
@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;
}
SVGParser.java 文件源码
项目:SiyuanGroup
阅读 30
收藏 0
点赞 0
评论 0
private static SVG parse(InputStream in, Integer searchColor, Integer replaceColor, boolean whiteMode,
int targetWidth, int targetHeight) throws SVGParseException {
// Util.debug("Parsing SVG...");
try {
long start = System.currentTimeMillis();
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
XMLReader xr = sp.getXMLReader();
final Picture picture = new Picture();
SVGHandler handler = new SVGHandler(picture, targetWidth, targetHeight);
handler.setColorSwap(searchColor, replaceColor);
handler.setWhiteMode(whiteMode);
xr.setContentHandler(handler);
xr.parse(new InputSource(in));
// Util.debug("Parsing complete in " + (System.currentTimeMillis() - start) + " millis.");
SVG result = new SVG(picture, handler.bounds);
// Skip bounds if it was an empty pic
if (!Float.isInfinite(handler.limits.top)) {
result.setLimits(handler.limits);
}
return result;
} catch (Exception e) {
throw new SVGParseException(e);
}
}
SVGParser.java 文件源码
项目:CustomShapeImageView
阅读 22
收藏 0
点赞 0
评论 0
private static SVG parse(InputStream in, Integer searchColor, Integer replaceColor, boolean whiteMode,
int targetWidth, int targetHeight) throws SVGParseException {
// Util.debug("Parsing SVG...");
try {
long start = System.currentTimeMillis();
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
XMLReader xr = sp.getXMLReader();
final Picture picture = new Picture();
SVGHandler handler = new SVGHandler(picture, targetWidth, targetHeight);
handler.setColorSwap(searchColor, replaceColor);
handler.setWhiteMode(whiteMode);
xr.setContentHandler(handler);
xr.parse(new InputSource(in));
// Util.debug("Parsing complete in " + (System.currentTimeMillis() - start) + " millis.");
SVG result = new SVG(picture, handler.bounds);
// Skip bounds if it was an empty pic
if (!Float.isInfinite(handler.limits.top)) {
result.setLimits(handler.limits);
}
return result;
} catch (Exception e) {
throw new SVGParseException(e);
}
}
SVGTestSupport.java 文件源码
项目:CustomShapeImageView
阅读 16
收藏 0
点赞 0
评论 0
@Before
public void setUp() throws Exception {
canvas = mock(Canvas.class);
PowerMockito.whenNew(Canvas.class).withNoArguments().thenReturn(canvas);
picture = mock(Picture.class);
PowerMockito.whenNew(Picture.class).withNoArguments().thenReturn(picture);
when(picture.beginRecording(anyInt(), anyInt())).thenReturn(canvas);
paint = mock(Paint.class);
PowerMockito.whenNew(Paint.class).withNoArguments().thenReturn(paint);
mockStatic(Log.class);
matrix = mock(android.graphics.Matrix.class);
PowerMockito.whenNew(android.graphics.Matrix.class).withNoArguments().thenReturn(matrix);
path = mock(Path.class);
PowerMockito.whenNew(Path.class).withNoArguments().thenReturn(path);
}
PictureBitmapTextureAtlasSource.java 文件源码
项目:NationSoccer
阅读 19
收藏 0
点赞 0
评论 0
@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;
}
WebImage.java 文件源码
项目:dobroreader-mod
阅读 22
收藏 0
点赞 0
评论 0
private void delaySetup(){
Log.i("WebImage","delaySetup");
wv.setPictureListener(new PictureListener() {
@Override
public void onNewPicture(WebView view, Picture picture) {
Log.i("WebImage","onNewPicture");
wv.setPictureListener(null);
setup();
}
});
//wv.setInitialScale(100);
wv.loadData("<html></html>", "text/html", "utf-8");
wv.setBackgroundColor(color);
}