Search in sources :

Example 71 with Point

use of android.graphics.Point in project ExoPlayer by google.

the class MediaCodecInfo method alignVideoSizeV21.

/**
   * Returns the smallest video size greater than or equal to a specified size that also satisfies
   * the {@link MediaCodec}'s width and height alignment requirements.
   * <p>
   * Must not be called if the device SDK version is less than 21.
   *
   * @param width Width in pixels.
   * @param height Height in pixels.
   * @return The smallest video size greater than or equal to the specified size that also satisfies
   *     the {@link MediaCodec}'s width and height alignment requirements, or null if not a video
   *     codec.
   */
@TargetApi(21)
public Point alignVideoSizeV21(int width, int height) {
    if (capabilities == null) {
        logNoSupport("align.caps");
        return null;
    }
    VideoCapabilities videoCapabilities = capabilities.getVideoCapabilities();
    if (videoCapabilities == null) {
        logNoSupport("align.vCaps");
        return null;
    }
    int widthAlignment = videoCapabilities.getWidthAlignment();
    int heightAlignment = videoCapabilities.getHeightAlignment();
    return new Point(Util.ceilDivide(width, widthAlignment) * widthAlignment, Util.ceilDivide(height, heightAlignment) * heightAlignment);
}
Also used : VideoCapabilities(android.media.MediaCodecInfo.VideoCapabilities) Point(android.graphics.Point) Point(android.graphics.Point) TargetApi(android.annotation.TargetApi)

Example 72 with Point

use of android.graphics.Point in project fresco by facebook.

the class MainActivity method getDisplayHeight.

/**
   * Determines display's height.
   */
public int getDisplayHeight() {
    Display display = getWindowManager().getDefaultDisplay();
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR2) {
        return display.getHeight();
    } else {
        final Point size = new Point();
        display.getSize(size);
        return size.y;
    }
}
Also used : Point(android.graphics.Point) Display(android.view.Display)

Example 73 with Point

use of android.graphics.Point in project rebound by facebook.

the class PhotoGalleryExample method layout.

private void layout() {
    float width = getWidth();
    float height = getHeight();
    // Determine the size for each image given the screen dimensions.
    Resources res = getResources();
    mPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 3, res.getDisplayMetrics());
    int colWidth = (int) Math.ceil((width - 2 * mPadding) / COLS) - 2 * mPadding;
    int rowHeight = (int) Math.ceil((height - 2 * mPadding) / ROWS) - 2 * mPadding;
    // Determine the resting position for each view.
    int k = 0;
    int py = 0;
    for (int i = 0; i < ROWS; i++) {
        int px = 0;
        py += mPadding * 2;
        for (int j = 0; j < COLS; j++) {
            px += mPadding * 2;
            ImageView imageView = mImageViews.get(k);
            imageView.setLayoutParams(new LayoutParams(colWidth, rowHeight));
            mPositions.add(new Point(px, py));
            px += colWidth;
            k++;
        }
        py += rowHeight;
    }
}
Also used : Resources(android.content.res.Resources) ImageView(android.widget.ImageView) Point(android.graphics.Point) Point(android.graphics.Point)

Example 74 with Point

use of android.graphics.Point in project ExoPlayer by google.

the class MediaCodecVideoRenderer method getCodecMaxValues.

/**
   * Returns {@link CodecMaxValues} suitable for configuring a codec for {@code format} in a way
   * that will allow possible adaptation to other compatible formats in {@code streamFormats}.
   *
   * @param codecInfo Information about the {@link MediaCodec} being configured.
   * @param format The format for which the codec is being configured.
   * @param streamFormats The possible stream formats.
   * @return Suitable {@link CodecMaxValues}.
   * @throws DecoderQueryException If an error occurs querying {@code codecInfo}.
   */
private static CodecMaxValues getCodecMaxValues(MediaCodecInfo codecInfo, Format format, Format[] streamFormats) throws DecoderQueryException {
    int maxWidth = format.width;
    int maxHeight = format.height;
    int maxInputSize = getMaxInputSize(format);
    if (streamFormats.length == 1) {
        // being configured.
        return new CodecMaxValues(maxWidth, maxHeight, maxInputSize);
    }
    boolean haveUnknownDimensions = false;
    for (Format streamFormat : streamFormats) {
        if (areAdaptationCompatible(format, streamFormat)) {
            haveUnknownDimensions |= (streamFormat.width == Format.NO_VALUE || streamFormat.height == Format.NO_VALUE);
            maxWidth = Math.max(maxWidth, streamFormat.width);
            maxHeight = Math.max(maxHeight, streamFormat.height);
            maxInputSize = Math.max(maxInputSize, getMaxInputSize(streamFormat));
        }
    }
    if (haveUnknownDimensions) {
        Log.w(TAG, "Resolutions unknown. Codec max resolution: " + maxWidth + "x" + maxHeight);
        Point codecMaxSize = getCodecMaxSize(codecInfo, format);
        if (codecMaxSize != null) {
            maxWidth = Math.max(maxWidth, codecMaxSize.x);
            maxHeight = Math.max(maxHeight, codecMaxSize.y);
            maxInputSize = Math.max(maxInputSize, getMaxInputSize(format.sampleMimeType, maxWidth, maxHeight));
            Log.w(TAG, "Codec max resolution adjusted to: " + maxWidth + "x" + maxHeight);
        }
    }
    return new CodecMaxValues(maxWidth, maxHeight, maxInputSize);
}
Also used : MediaFormat(android.media.MediaFormat) Format(com.google.android.exoplayer2.Format) Point(android.graphics.Point) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point)

Example 75 with Point

use of android.graphics.Point in project XobotOS by xamarin.

the class View method setLeft.

/**
     * Sets the left position of this view relative to its parent. This method is meant to be called
     * by the layout system and should not generally be called otherwise, because the property
     * may be changed at any time by the layout.
     *
     * @param left The bottom of this view, in pixels.
     */
public final void setLeft(int left) {
    if (left != mLeft) {
        updateMatrix();
        final boolean matrixIsIdentity = mTransformationInfo == null || mTransformationInfo.mMatrixIsIdentity;
        if (matrixIsIdentity) {
            if (mAttachInfo != null) {
                int minLeft;
                int xLoc;
                if (left < mLeft) {
                    minLeft = left;
                    xLoc = left - mLeft;
                } else {
                    minLeft = mLeft;
                    xLoc = 0;
                }
                invalidate(xLoc, 0, mRight - minLeft, mBottom - mTop);
            }
        } else {
            // Double-invalidation is necessary to capture view's old and new areas
            invalidate(true);
        }
        int oldWidth = mRight - mLeft;
        int height = mBottom - mTop;
        mLeft = left;
        onSizeChanged(mRight - mLeft, height, oldWidth, height);
        if (!matrixIsIdentity) {
            if ((mPrivateFlags & PIVOT_EXPLICITLY_SET) == 0) {
                // A change in dimension means an auto-centered pivot point changes, too
                mTransformationInfo.mMatrixDirty = true;
            }
            // force another invalidation with the new orientation
            mPrivateFlags |= DRAWN;
            invalidate(true);
        }
        mBackgroundSizeChanged = true;
        invalidateParentIfNeeded();
    }
}
Also used : Paint(android.graphics.Paint) Point(android.graphics.Point)

Aggregations

Point (android.graphics.Point)1151 Display (android.view.Display)217 Rect (android.graphics.Rect)194 Paint (android.graphics.Paint)170 WindowManager (android.view.WindowManager)138 RemoteException (android.os.RemoteException)76 RectF (android.graphics.RectF)62 Bitmap (android.graphics.Bitmap)54 Resources (android.content.res.Resources)41 View (android.view.View)41 ArrayList (java.util.ArrayList)40 ImageView (android.widget.ImageView)37 Camera (android.hardware.Camera)36 Canvas (android.graphics.Canvas)31 Matrix (android.graphics.Matrix)29 Animator (android.animation.Animator)27 SuppressLint (android.annotation.SuppressLint)27 Configuration (android.content.res.Configuration)26 IOException (java.io.IOException)24 Message (android.os.Message)22