Java 类android.graphics.Picture 实例源码

项目:gamesboard    文件:ImageUtils.java   
public static Bitmap createBitmap(InputStream in, int w, int h, boolean closeStream) {
        if (in == null) {
            return null;
        }
        com.larvalabs.svgandroid.SVG svg;
        svg = new SVGBuilder().readFromInputStream(in).build();

        Bitmap bitmap = Bitmap.createBitmap(w, h, Config.ARGB_8888);
        Canvas canvas = new Canvas(bitmap);
        Picture pic = svg.getPicture();
//        svg.renderToCanvas(canvas/*, new RectF(0f, 0f, (float)w, (float)h)*/);
//        svg.renderToCanvas(canvas, new RectF(0f, 0f, (float)w, (float)h));
        canvas.drawPicture(pic, new Rect(0, 0, w, h));
        if (closeStream) {
            try {
                in.close();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return bitmap;
    }
项目:ZhidaoDaily-android    文件:DetailActivity.java   
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;
}
项目:TreebolicLib    文件:GraphicsCache.java   
public GraphicsCache(@SuppressWarnings("unused") final Component component, @NonNull final Graphics thatGraphics, final int width0, final int height0)
{
    this.canvas = thatGraphics.canvas;
    if (GraphicsCache.CACHE)
    {
        this.picture = new Picture();
        this.width = width0;
        this.height = height0;
    }
    else
    {
        this.picture = null;
        this.width = 0;
        this.height = 0;
    }
}
项目:RNLearn_Project1    文件:ReactWebViewManager.java   
private WebView.PictureListener getPictureListener() {
  if (mPictureListener == null) {
    mPictureListener = new WebView.PictureListener() {
      @Override
      public void onNewPicture(WebView webView, Picture picture) {
        dispatchEvent(
          webView,
          new ContentSizeChangeEvent(
            webView.getId(),
            webView.getWidth(),
            webView.getContentHeight()));
      }
    };
  }
  return mPictureListener;
}
项目:RNLearn_Project1    文件:ReactWebViewManager.java   
private WebView.PictureListener getPictureListener() {
  if (mPictureListener == null) {
    mPictureListener = new WebView.PictureListener() {
      @Override
      public void onNewPicture(WebView webView, Picture picture) {
        dispatchEvent(
          webView,
          new ContentSizeChangeEvent(
            webView.getId(),
            webView.getWidth(),
            webView.getContentHeight()));
      }
    };
  }
  return mPictureListener;
}
项目:ZzBeeLayout    文件:SVGParser.java   
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);
        }
    }
项目:Ironman    文件:ReactWebViewManager.java   
private WebView.PictureListener getPictureListener() {
  if (mPictureListener == null) {
    mPictureListener = new WebView.PictureListener() {
      @Override
      public void onNewPicture(WebView webView, Picture picture) {
        dispatchEvent(
          webView,
          new ContentSizeChangeEvent(
            webView.getId(),
            webView.getWidth(),
            webView.getContentHeight()));
      }
    };
  }
  return mPictureListener;
}
项目:react-native-x5    文件:RNX5WebViewManager.java   
private WebView.PictureListener getPictureListener() {
    if (mPictureListener == null) {
        mPictureListener = new WebView.PictureListener() {
            @Override
            public void onNewPicture(WebView webView, Picture picture) {
                dispatchEvent(
                        webView,
                        new ContentSizeChangeEvent(
                                webView.getId(),
                                webView.getWidth(),
                                webView.getContentHeight()));
            }
        };
    }
    return mPictureListener;
}
项目:ExhibitionCenter    文件:MapOverlay.java   
public void setData(Picture floorMap)
{
    this.floorMap = floorMap;
    if (this.mapMainView.getWidth() == 0)
    {
        ViewTreeObserver vto = this.mapMainView.getViewTreeObserver();
        vto.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener()
        {
            public boolean onPreDraw()
            {
                if (!hasMeasured)
                {
                    calcRatio();
                }
                return true;
            }
        });
    }
    else
    {
        calcRatio();
    }
}
项目:MapView    文件:MapLayer.java   
public void setImage(Picture image) {
    this.image = image;

    if (mapView.getWidth() == 0) {
        ViewTreeObserver vto = mapView.getViewTreeObserver();
        vto.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
            public boolean onPreDraw() {
                if (!hasMeasured) {
                    initMapLayer();
                    hasMeasured = true;
                }
                return true;
            }
        });
    } else {
        initMapLayer();
    }
}
项目:stepik-android    文件:SVG.java   
/**
 * Renders this SVG document to a Picture object using the specified view defined in the document.
 * <p>
 * A View is an special element in a SVG document that describes a rectangular area in the document.
 * Calling this method with a {@code viewId} will result in the specified view being positioned and scaled
 * to the viewport.  In other words, use {@link #renderToPicture()} to render the whole document, or use this
 * method instead to render just a part of it.
 *
 * @param viewId         the id of a view element in the document that defines which section of the document is to be visible.
 * @param widthInPixels  the width of the initial viewport
 * @param heightInPixels the height of the initial viewport
 * @return a Picture object suitable for later rendering using {@code Canvas.drawPicture()}, or null if the viewId was not found.
 */
public Picture renderViewToPicture(String viewId, int widthInPixels, int heightInPixels) {
    SvgObject obj = this.getElementById(viewId);
    if (obj == null)
        return null;
    if (!(obj instanceof SVG.View))
        return null;

    SVG.View view = (SVG.View) obj;

    if (view.viewBox == null) {
        Log.w(TAG, "View element is missing a viewBox attribute.");
        return null;
    }

    Picture picture = new Picture();
    Canvas canvas = picture.beginRecording(widthInPixels, heightInPixels);
    Box viewPort = new Box(0f, 0f, (float) widthInPixels, (float) heightInPixels);

    SVGAndroidRenderer renderer = new SVGAndroidRenderer(canvas, viewPort, this.renderDPI);

    renderer.renderDocument(this, view.viewBox, view.preserveAspectRatio, false);

    picture.endRecording();
    return picture;
}
项目:PdDroidPublisher    文件:SVGParser.java   
private static SVG parse(InputStream in, Integer searchColor, Integer replaceColor, boolean whiteMode) throws SVGParseException {
//        Util.debug("Parsing SVG...");
        try {
            SAXParserFactory spf = SAXParserFactory.newInstance();
            SAXParser sp = spf.newSAXParser();
            XMLReader xr = sp.getXMLReader();
            final Picture picture = new Picture();
            SVGHandler handler = new SVGHandler(picture);
            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);
        }
    }
项目:ametro    文件:RenderProgram.java   
private List<DrawingElement> createElementsTree(MapContainer container, String schemeName) {
    final List<DrawingElement> elements = new ArrayList<>();
    MapScheme scheme = container.getScheme(schemeName);
    for (MapSchemeLine line : scheme.getLines()) {
        createLine(elements, scheme, line);
    }
    for (MapSchemeTransfer transfer : scheme.getTransfers()) {
        createTransfer(elements, scheme, transfer);
    }
    for (String imageName : scheme.getImageNames()) {
        Object background = scheme.getBackgroundObject(imageName);
        if (background instanceof Picture) {
            elements.add(new PictureBackgroundElement(scheme, (Picture) background));
        } else if (background instanceof Bitmap) {
            elements.add(new BitmapBackgroundElement(scheme, (Bitmap) background));
        }
    }
    return elements;
}
项目:AndroidCourses    文件:PictureBitmapTextureAtlasSource.java   
@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;
}
项目:AndroidCourses    文件:PictureBitmapTextureAtlasSource.java   
@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;
}
项目:ClassicF1    文件:PictureBitmapTextureAtlasSource.java   
@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;
}
项目:tilt-game-android    文件:PictureBitmapTextureAtlasSource.java   
@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;
}
项目:PlayPauseDrawable    文件:PlayPauseDrawable.java   
@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();

}
项目:XDroidAnimation    文件:SVG.java   
/**
 * Renders this SVG document to a Picture object using the specified view defined in the document.
 * <p/>
 * A View is an special element in a SVG document that describes a rectangular area in the document.
 * Calling this method with a {@code viewId} will result in the specified view being positioned and scaled
 * to the viewport.  In other words, use {@link #renderToPicture()} to render the whole document, or use this
 * method instead to render just a part of it.
 *
 * @param viewId         the id of a view element in the document that defines which section of the document is to
 *                       be visible.
 * @param widthInPixels  the width of the initial viewport
 * @param heightInPixels the height of the initial viewport
 * @return a Picture object suitable for later rendering using {@code Canvas.drawPicture()},
 * or null if the viewId was not found.
 */
public Picture renderViewToPicture(String viewId, int widthInPixels, int heightInPixels) {
    SvgObject obj = this.getElementById(viewId);
    if (obj == null)
        return null;
    if (!(obj instanceof SVG.View))
        return null;

    SVG.View view = (SVG.View) obj;

    if (view.viewBox == null) {
        Log.w(TAG, "View element is missing a viewBox attribute.");
        return null;
    }

    Picture picture = new Picture();
    Canvas canvas = picture.beginRecording(widthInPixels, heightInPixels);
    Box viewPort = new Box(0f, 0f, (float) widthInPixels, (float) heightInPixels);

    SVGAndroidRenderer renderer = new SVGAndroidRenderer(canvas, viewPort, this.renderDPI);

    renderer.renderDocument(this, view.viewBox, view.preserveAspectRatio, false);

    picture.endRecording();
    return picture;
}
项目:itmarry    文件:PictureTextureSource.java   
@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;
}
项目:30-android-libraries-in-30-days    文件:PictureBitmapTextureAtlasSource.java   
@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;
}
项目:appdeck-android    文件:SmartWebView.java   
@Override
public void onNewPicture(WebView view, Picture arg1)
{
    // put code here that needs to run when the page has finished loading and
    // a new "picture" is on the webview.      

    if (shouldSrollToX != -1 && shouldSrollToX != -1)
    {
        view.scrollTo(shouldSrollToX, shouldSrollToY);
        shouldSrollToX = -1;
        shouldSrollToY = -1;
    }

    if (onNewPictureCalled == false)
    {
        root.progressSet(view, 101);
        onNewPictureCalled = true;
    }
    //root.webviewIsReady(this);

}
项目:pixate-freestyle-android    文件:PXImagePaint.java   
public void applyFillToPath(Path path, Paint paint, Canvas context) {
    context.save();
    // clip to path
    context.clipPath(path);
    // do the gradient
    Rect bounds = new Rect();
    context.getClipBounds(bounds);
    Picture image = imageForBounds(bounds);
    // draw
    if (image != null) {
        // TODO - Blending mode? We may need to convert the Picture to a
        // Bitmap and then call drawBitmap
        context.drawPicture(image);
    }
    context.restore();
}
项目:cordova-amazon-fireos    文件:Purity.java   
public boolean checkRenderView(AmazonWebView 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;
    }
}
项目:UltimateAndroid    文件:SVGParser.java   
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);
        }
    }
项目:UltimateAndroid    文件:SVGParser.java   
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);
        }
    }
项目:NeXT_pyp    文件:WebImage.java   
private void delaySetup() {

        wv.setPictureListener(new PictureListener() {

            @Override
            public void onNewPicture(WebView view, Picture picture) {
                wv.setPictureListener(null);
                setup();
            }

        });

        // wv.setInitialScale(100);
        wv.loadData("<html></html>", "text/html", "utf-8");
        wv.setBackgroundColor(color);

    }
项目:NeXT_pyp    文件:WebImage.java   
private void delaySetup() {

        wv.setPictureListener(new PictureListener() {

            @Override
            public void onNewPicture(WebView view, Picture picture) {
                wv.setPictureListener(null);
                setup();
            }

        });

        // wv.setInitialScale(100);
        wv.loadData("<html></html>", "text/html", "utf-8");
        wv.setBackgroundColor(color);

    }
项目:egg-android    文件:SVGParser.java   
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);
        }
    }
项目:our_days    文件:SVGParser.java   
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);
        }
    }
项目:cordova-android-chromeview    文件:Purity.java   
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;
    }
}
项目:osmLib    文件:CompassPictureFactory.java   
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);
}
项目:xface-android    文件:Purity.java   
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;
    }
}
项目:iZhihu    文件:DetailFragment.java   
/**
 * 截取所有网页内容到 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;
    }
}
项目:Killbots    文件:PictureBitmapTextureAtlasSource.java   
@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;
}
项目:SiyuanGroup    文件:SVGParser.java   
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);
        }
    }
项目:CustomShapeImageView    文件:SVGParser.java   
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);
        }
    }
项目:CustomShapeImageView    文件:SVGTestSupport.java   
@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);
}
项目:NationSoccer    文件:PictureBitmapTextureAtlasSource.java   
@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;
}
项目:dobroreader-mod    文件:WebImage.java   
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);

}