Search in sources :

Example 21 with Picture

use of android.graphics.Picture in project UltimateAndroid by cymcsg.

the class SVGParser method parse.

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);
    }
}
Also used : InputSource(org.xml.sax.InputSource) Picture(android.graphics.Picture) SAXParser(javax.xml.parsers.SAXParser) XMLReader(org.xml.sax.XMLReader) IOException(java.io.IOException) SAXException(org.xml.sax.SAXException) SAXParserFactory(javax.xml.parsers.SAXParserFactory)

Example 22 with Picture

use of android.graphics.Picture in project chromeview by pwnall.

the class JavaBrowserViewRendererHelper method recordBitmapIntoPicture.

/**
     * Creates a new Picture that records drawing a provided bitmap.
     * Will return an empty Picture if the Bitmap is null.
     */
@CalledByNative
private static Picture recordBitmapIntoPicture(Bitmap bitmap) {
    Picture picture = new Picture();
    if (bitmap != null) {
        Canvas recordingCanvas = picture.beginRecording(bitmap.getWidth(), bitmap.getHeight());
        drawBitmapIntoCanvas(bitmap, recordingCanvas);
        picture.endRecording();
    }
    return picture;
}
Also used : Picture(android.graphics.Picture) Canvas(android.graphics.Canvas) CalledByNative(org.chromium.base.CalledByNative)

Aggregations

Picture (android.graphics.Picture)22 IOException (java.io.IOException)7 Canvas (android.graphics.Canvas)4 FileNotFoundException (java.io.FileNotFoundException)4 Bitmap (android.graphics.Bitmap)3 SAXParser (javax.xml.parsers.SAXParser)3 SAXParserFactory (javax.xml.parsers.SAXParserFactory)3 SAXException (org.xml.sax.SAXException)3 XMLReader (org.xml.sax.XMLReader)3 Bundle (android.os.Bundle)2 WebView (android.webkit.WebView)2 PictureListener (android.webkit.WebView.PictureListener)2 File (java.io.File)2 FileInputStream (java.io.FileInputStream)2 FileOutputStream (java.io.FileOutputStream)2 Test (org.junit.Test)2 InputSource (org.xml.sax.InputSource)2 Paint (android.graphics.Paint)1 Point (android.graphics.Point)1 Rect (android.graphics.Rect)1