本文整理汇总了Java中android.graphics.Picture类的典型用法代码示例。如果您正苦于以下问题:Java Picture类的具体用法?Java Picture怎么用?Java Picture使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Picture类属于android.graphics包,在下文中一共展示了Picture类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createBitmap
import android.graphics.Picture; //导入依赖的package包/类
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;
}
示例2: 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;
}
示例3: GraphicsCache
import android.graphics.Picture; //导入依赖的package包/类
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;
}
}
示例4: getPictureListener
import android.graphics.Picture; //导入依赖的package包/类
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;
}
示例5: parse
import android.graphics.Picture; //导入依赖的package包/类
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);
}
}
示例6: getPictureListener
import android.graphics.Picture; //导入依赖的package包/类
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;
}
示例7: setData
import android.graphics.Picture; //导入依赖的package包/类
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();
}
}
示例8: setImage
import android.graphics.Picture; //导入依赖的package包/类
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();
}
}
示例9: renderViewToPicture
import android.graphics.Picture; //导入依赖的package包/类
/**
* 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;
}
示例10: parse
import android.graphics.Picture; //导入依赖的package包/类
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);
}
}
示例11: createElementsTree
import android.graphics.Picture; //导入依赖的package包/类
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;
}
示例12: 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;
}
示例13: 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;
}
示例14: 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();
}
示例15: renderViewToPicture
import android.graphics.Picture; //导入依赖的package包/类
/**
* 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;
}